Powershell Authentication to Classic Azure portal

Today I am going to show you how to start working with the Powershell when your resources are in Classic Azure portal. Before you begin, do not forget to check Powershell prerequisites, which you can find in my previous blog post.

First, as you might know, almost every powershell command, that does not have RM (Resource Manager) will be applied to the old Classic portal. There is no exception and for the login. By typing the following command into your Powershell console you will be logging into your Classic Azure portal in Windows Powershell.


This command in the background downloads your Azure account information and gets the access token that allows you to manage your Azure resources. When you execute the command, you will be prompted with the window where you have to provide your Azure credentials.

When the access token is expired you will to run Powershell command again and provide your credentials. If you want to log out, use the following cmdlet.


Check the whole description by typing the following in your Powershell console.

help Add-AzureAccount -ShowWindow

Another way to login to your Azure subscription is via publish setting file. By using publish setting file you don’t need to login every time. Simply you can import it in the beginning of your script or session.

Publish setting file uses management certificate for authentication. For the very first time you will need to get the publish setting file. You can do that by the following cmdlet.


You will be forwarded to login to your Azure subscription where you will have to download the subscription file.

Now you need to import the file.

Import-AzurePublishSettingsFile D:\ps\login.publishsettings

That is it. Every time you execute the Import command you are authenticated to your Azure Classic portal without providing the credentials.

If you have many subscriptions, don’t forget to select the working one. First of all, get all the available subscriptions

PS D:\PS> Get-AzureSubscription

SubscriptionId            : xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx
SubscriptionName          : SubscriptionName1
Environment               : AzureCloud
DefaultAccount            : 1111111111111111111111111111111111111111
IsDefault                 : False
IsCurrent                 : False
TenantId                  : aaaaaaaa-aaaa-aaaa-aaaa-aaaaaaaaaaaa
CurrentStorageAccountName : 

SubscriptionId            : yyyyyyyy-yyyy-yyyy-yyyy-yyyyyyyyyyyy
SubscriptionName          : SubscriptionName2
Environment               : AzureCloud
DefaultAccount            : 2222222222222222222222222222222222222222
IsDefault                 : False
IsCurrent                 : False
TenantId                  : bbbbbbbb-bbbb-bbbb-bbbb-bbbbbbbbbbbb
CurrentStorageAccountName : 

SubscriptionId            : zzzzzzzz-zzzz-zzzz-zzzz-zzzzzzzzzzzz
SubscriptionName          : SubscriptionName3
Environment               : AzureCloud
DefaultAccount            : 3333333333333333333333333333333333333333
IsDefault                 : True
IsCurrent                 : True
TenantId                  : cccccccc-cccc-cccc-cccc-cccccccccccc
CurrentStorageAccountName : 

And then select the one that you want to work with

Select-AzureSubscription -SubscriptionId yyyyyyyy-yyyy-yyyy-yyyy-yyyyyyyyyyyy

Keep in mind that the publish setting file has encoded certificate (you can open it with any text editor) and should be kept in the safe location. If any malicious user will access your publish setting file, they will gain full access to your Azure services.


Leave a Reply

Your email address will not be published.