Monday, December 03, 2018

Microsoft Azure and installing Azure PowerShell on Windows





Microsoft Azure and installing Azure PowerShell on Windows


Cloud Computing and Microsoft Azure



In modern IT industry the cloud computing is a trending buzzword which makes the development and deployment significantly stress-free. The cloud computing platform works a bit different in comparison to classical way to manage different types of hardware’s as well software’s.  It gives the facility and feasibility access a massive pool of computing resources provided by the Cloud Providers such as Microsoft, Amazon or Google on the basis of something Pay-As-You-Go model.

Microsoft Azure, formerly known as Windows Azure, is a leading cloud computing platform created by Microsoft. It provides a wide range of cloud services counting with Platform as a Service (PaaS) and Infrastructure as a Service (IaaS) to develop and scale applications as well deploy and manage through a global network of data centers.

The Azure cloud offers a lot of different services for diverse scenario and almost covers the necessities, Microsoft categorizes these cloud services into different product types like – 

  • Compute – Deploy and manage VMs.
  • Web and Mobile – Development and deployment of web or mobile apps.
  • Data Storage – Scalable cloud storage.
  • Analytics – Real-time analytics and data warehousing etc.
  • Networking – Virtual network and connection etc.
  • Internet of Things (IoT) – Capture and manage IoT data.
  • Containers – Huge volume of containers like Docker etc.,
  • Databases – Includes Azure SQL, NoSQL etc.
  • DevOps – Project and collaboration tools.
  • Monitoring - Manage and monitor Azure instances.
  • Security and Identity – User authentication or access management.

Cloud Computing and Microsoft Azure




Azure PowerShell - Introduction


Apart from the Azure Portal, there are other ways to manage and administer Azure resources from the command line such as – 
  • Azure PowerShell
  • Azure CLI
  • Azure Cloud Shell etc.


Here we will talk about Azure PowerShell and will see how to install it on top of the Windows machine. It is particularly designed for orchestrating Azure resources and build automation script.

Fundamentally Azure PowerShell is an extended version of Windows PowerShell platform and scripting language to deliver cmdlets to accomplish a robust task in the context of Azure cloud services. Cmdlets are preset scripts through which an Azure PowerShell programmer can perform diverse tasks like provisioning VMs, automate jobs, backup and restore, etc.

Pre-requisite - Windows PowerShell

Azure PowerShell - Introduction

Windows PowerShell is a task-based command-line shell and scripting language designed especially for system administration. 

It comes installed by default on every Windows, but sometimes locating PowerShell console or ISE (Integrated Scripting Environment) can be a bit difficult due to the movement of its location from one version to another version of Windows.

For example - 
  • Windows 10 - left lower corner Windows icon, start typing PowerShell
  • Windows 8.1, 8.0 - the start screen, start typing PowerShell.
  • Windows 7 SP1 - left lower corner Windows icon, on the search box start typing PowerShell 

Install Azure PowerShell


We will continue to install the Azure PowerShell modules in a Windows environment through the PowerShellGet.  PowerShellGet is an in-box module management, the preferred way to install Azure PowrShell, though we can go ahead to install using Web Platform Installer or MSI package.

STEP – 1 

In fact, Azure PowerShell (starting version 6.0) requires PowerShell version 5.0, henceforth execute following command to check the version of PowerShell running on your machine.

$PSVersionTable

STEP – 1

If you see an outdated version, then go Microsoft official page to upgrade existing Windows PowerShell.

STEP – 2

Execute following command to install Azure PowerShell from the PowerShell Gallery, required elevated privileges – 

Install-Module -Name AzureRM –AllowClobber

STEP – 2

Post execution of above command console will return a prompt about Untrusted repository. In fact, by default, the PowerShell gallery isn't configured as a trusted repository for PowerShellGet.

STEP – 2 Install Module

Simply need to answer with either Y or A to go ahead.

STEP – 3

Post acknowledgement with Yes or Yes to All, the AzureRM module will start to download all of the available Azure Resource Manager modules, and makes their cmdlets available for use.

STEP – 3

 Sooner it will install the Azure PowerShell.

STEP – 3 Install Azure

You can do verify the installed version using the execution of following command.

Get-InstalledModule -Name AzureRM –AllVersions

Installed Version

Congratulation, Azure PowerShell installed!! 😊

Update the Azure PowerShell module


The Update-Module cmdlet installs a newer version of a PowerShell module that was installed from the online gallery by running Install-Module on the local computer. However, the newest version of the stated module available by default in the gallery, unless you specify a required version. 

Execute following command to update your Azure PowerShell installation by running Update-Module, this command does not uninstall earlier versions.

Update-Module -Name AzureRM

Update the Azure PowerShell module

Install different versions of Azure PowerShell


Due to some specific Azure Stack resources it is quite possible to install more than one version of Azure PowerShell. 

STEP – 1

Execute following command to verify if you have installed multiple versions of Azure PowerShell.

Get-Module -Name AzureRM -List | select Name,Version

Verify installed multiple versions

In my case there is only one version exist – 6.13.1

STEP – 2

Supposed, you are working with on-premises Azure Stack Resource or Azure classic deployment model and required an older version 2.3.0, then execute the following command with RequiredVersion argument.

Install-Module -Name AzureRM -RequiredVersion 2.3.0

Install an older version

Sooner it will ask the same confirmation about the Untrusted repository, go ahead with Yest to All.

STEP – 3

Post confirmation the said version of the installation will proceed and simply complete the installation. 

Installation


Installation Done

STEP – 4

Next, repeat the step 1’s execution of command to do verify the existence of installed multiple versions of Azure PowerShell.

Get-Module -Name AzureRM -List 

Verify version

Connect with Azure 


Execute following command to connect with Azure and start working with Azure PowerShell, it will open an interactive dialog for sign-in, sign in with your Azure credentials subsequently.

Connect-AzureRmAccount

Connect with Azure

Post submission of credentials, it will be connected and display your account details such as – 

Azure account details

Congratulation, Azure Cloud connected!! 😊

In case of multiple versions, the latest version of the Azure PowerShell module will be loaded by default. If required, to load another version, then execute following steps.

STEP – 1

Execute following command to verify the installed multiple versions of Azure PowerShell.

Get-Module -Name AzureRM -List | select Name,Version

Installed multiple versions

STEP – 2

Supposed need to load the old version of Azure PowerShell 3.2.0, then execute the following command with RequiredVersion argument.

Import-Module -Name AzureRM -RequiredVersion 3.2.0

Load an older version



Azure Resources and Azure PowerShell – Hands on activity  


Here we can execute few basic Azure PowerShell commands to retrieve information as well as perform some specific tasks to utilize the services.

Task – 1 : Execute the following command to list the current Subscription.

Get-AzureRmSubscription

Current Subscription

Task – 2 : Execute the following command to list the all Azure PowerShell installed.

Get-InstalledModule -Name AzureRM –AllVersions

List all versions
  
Task – 3 : Execute the following command to Uninstall a specific version of the Azure PowerShell module, supposed to remove the version 2.3.0.

Uninstall-Module -Name AzureRm -RequiredVersion 2.3.0 –Force
  


Task – 4 : Execute the following command to display all region/locations.

Get-AzureRmLocation |Format-Table
  

Task – 5 : Execute the following command to create a Resource Group, providing its name and the location parameters to specify the region location.

New-AzureRmResourceGroup -Name 'demoResource' -Location 'Central India'




You can do verify the same using Azure Portal also.




Task – 6 : Execute following command to get all resources in a resource group, for example, my resource group is raj_resource.

Get-AzureRmResource -ResourceGroupName raj_resource | FT




Task – 7 : Execute following command to start and stop the Virtual Machine under a specific Resource Group.

Step – 1 

List all VMs under a Resource Group to select the particular VM.

Get-AzureRmVM -ResourceGroupName raj_resource


Step – 2 

Stop the particular VM under the specified Resource Group.

Stop-AzureRmVM -ResourceGroupName raj_resource -Name rajvirtual

It will ask the confirmation to stop the VM, go ahead with Yes.



You can do verify the same using Azure Portal also.




Step – 3

Start the particular VM under the specified Resource Group.

Start-AzureRmVM -ResourceGroupName raj_resource -Name rajvirtual


 You can do verify the same using Azure Portal also.


 Stay in touch with us for further articles ! 😊



5 comments:

  1. Glad to know that you liked it, thanks for the appreciation!

    ReplyDelete
  2. This information is meaningful and magnificent which you have shared here about the Microsoft Azure. I am impressed by the details that you have shared in this post and It reveals how nicely you understand this subject. I would like to thanks for sharing this article here. Simply2cloud offers the Best Microsoft Azure Training in Delhi.

    ReplyDelete
  3. Great job for publishing such a nice article. Your article isn’t only useful but it is additionally really informative. Thank you because you have been willing to share information about microsoft azure. oracle financial training

    ReplyDelete
  4. very nice, thanks a lot for everything you wrote here. you gave the right info about it. you sharing such a great blogs to us. Policy Creation Software Online

    ReplyDelete