Thursday, October 26, 2017

How to Login to Azure using PowerShell?

The Azure PowerShell cmdlets support two authentication techniques: AAD (Azure Active Directory) and self-signed X.509 certificates. AAD authentication can be used for both the classic Azure Service Management (ASM) mode and the new Azure Resource Manager (ARM) mode of the Azure. Certificate authentication can be used only for ASM mode.

Here we will using AAD to get into our Azure subscription. For this to work you should be an Administrator or Co-administrator for relevant subscription. More info related to Azure Access rights can be found here  http://rajeshkamalakshan.blogspot.in/2017/08/managing-azure-subscriptions-and-access.html .

If you don’t have AAD module installed then the same can be installed as below

In Powershell Run

Install-Module AzureAD

Once the above module is installed run the below command in power shell. This cmdlet prompts you for the login credentials for your Azure account. After logging in, it downloads your account settings so they are available to Azure PowerShell.

Add-AzureAccount

Once logged in successfully , if necessary, the following Azure cmdlets can be used to select the desired subscription

Get-AzureSubscription
Select-AzureSubscription -SubscriptionName "SomeSubscription"

There are other ways to login to Azure subscription  by using  Login-AzureRmAccount. This will work only forAzure Resource Manager”(ARM).but the above approach works for both ASM and ARM

More Reading