Logging on to Azure with PowerShell

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

Login-AzureRmAccount

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:

Login-AzureRmAccount output

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>

or

Select-AzureRmSubscription -SubscriptionName <em>name</em>

The output of that command is the same as above.

Multifactor

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.

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s