Monday, August 15, 2016

Azure PowerShell Installation & Getting Help

  1. What is Windows Powershell..?

It is a Windows command-line shell designed for an interactive prompt and a scripting environment that can be used independently or in combination by administrators and developers.


It is built on top of the .NET Framework common language runtime (CLR) and the .NET Framework, and accepts and returns .NET Framework objects; which bring entirely new tools and methods to the management and configuration of Windows.


Windows PowerShell introduces the concept of a cmdlet (pronounced "command-let"), a simple, single-function command-line too. It includes more than one hundred basic core cmdlets, and you can write your own cmdlets and share them with other users. It gives you access to the file system on the computer. Also it's "providers" enable you to access other data stores, such as the registry and the digital signature certificate stores, as easily as you access the file system.


    1. And What is Azure PowerShell..?

Azure PowerShell is a module that provides cmdlets to manage Microsoft Azure through Windows PowerShell. It’s a Azure-flavored PowerShell. You can use the cmdlets to create, test, deploy, and manage solutions and services on Azure. In most cases, you can use the cmdlets to perform the same tasks that you can perform through the Azure Management Portal. For example, you can create and configure cloud services, virtual machines, virtual networks, and web apps.


    1. Download and Installing Azure PowerShell

Beginning in version 0.8.5, the Azure PowerShell modules require Microsoft .NET Framework 4.5. When you install the module, the installer checks your system for the required software and installs all dependencies, such as the correct version of Windows PowerShell and .NET Framework.


For download and install the Azure PowerShell modules on Development VM - http://go.microsoft.com/fwlink/p/?LinkId=320376










Installing of command line tools can be done as –


Installing the module also installs a customized console for Azure PowerShell. You can run the cmdlets from either the standard Windows PowerShell console or the Azure PowerShell console.


Starting powershell –


Searching powershell will show up -
  1. Windows Powershell
  2. Azure Powershell


You need to select Azure powershell




Azure powershell window –




You are in. Happy cmdlets.
  1. How to get help inside cmdlets (pronounce it as command lets)

Syntax is –
Get-Help -Detailed


For help about “Add-AzureAccount” cmdlets
Following screen is shown because no updated help was installed. I said “yes” to download latest help.
So it downloaded latest help for me –
Once the installation is done, the command prompt shows examples with commands to achieve results. This is the help you can keep reference as, maybe in a .txt document by copy-pasting contents from this window -  
  1. Modes of Azure Powershell

There are mainly 2 modes of Azure Powershell –
  1. Service Management
  2. Resource Manager
Beginning in version 0.8.0, the Azure PowerShell installation includes more than one PowerShell module. You must explicitly decide whether to use the commands that are available in the Azure module or the Azure Resource Manager module. To make it easy to switch between them, they’ve added a new cmdlet, Switch-AzureMode, to the Azure Profile module.
When you use Azure PowerShell, the cmdlets in the Azure module are imported by default. To switch to the Azure Resource Manager module, use the Switch-AzureMode cmdlet as shown below –
  1. Which version of Azure powershell you are running on

What if for a given VM, you wish to check which version of Azure Powershell is running..?
Fire following command for the same and the snapshot shows the Powershell version
Get-Module –ListAvailable –Name Azure
So, we are on version 0.9.5
  1. Add AzureAccount and change the default subscription

Now I want to add another AzureAccount then, following command needs to be added
Then it will ask for credentials; provide required credentials –
Success –
But the default subscription got selected was for “Ultimate”, but I wanted to have a “Professional” subscription.
You must be thinking how I knew it, just enter following command to powershell, to view all the subscription –
“Get-azureSubscription”
This lists all the subscriptions linked to the credentials with I am logged in –
To switch to different subscription, you need to go for “Select –AzureSubscription” command. But I don’t know the syntax. So go for help with example with the following command -
This will give you with the result as -
So, as per the help, change the subscription

No comments:

Post a Comment