I am preparing some posts about managing aspects of Azure services with PowerShell. Before you can do that, you’ll need to authenticate to Azure. In this “prereq” blog post, I’ll briefly walk through the process of authenticating to your Azure subscription from PowerShell. This blog post will only use the “newer” Azure Resource Manager (AzureRm) commandlets.
Logging On to an Azure AD Account
The command to log on is
Type the command in a PowerShell window and press Enter. You’ll be asked for your username and password using a popup dialog box. The dialog box may flash off and on the screen a few times while the authentication process completes.
Selecting a Subscription
The Azure AD account you just signed in with may have access to multiple Azure subscriptions. The active subscription is shown by name and ID as output of the
Login-AzureRmAccount commandlet, as in the figure below:
To change your subscription, you can use either the name or the GUID of the desired subscription using the Select-AzureRmSubscription cmdlet. So use either
Select-AzureRmSubscription -SubscriptionId <em>guid</em>
Select-AzureRmSubscription -SubscriptionName <em>name</em>
The output of that command is the same as above.
If multifactor authentication is set up for your Azure AD account, this same method will work. You will of course need to provide the second factor authentication.