Thursday, May 11, 2017

How to connect Azure subs subscription from PowerShell?

Option 1
To establish connectivity to Azure subscription from PowerShell you need to first run the command  Get-AzurePublishSettingsFile (start PowerShell in  administrator mode). This will result in downloading PublishSettings to your local machine. You can used this file to establish connection to azure by using another azure command Import-AzurePublishSettingsFile
Step
1.       Open PowerShell in administrator  mode
2.       At the Windows PowerShell command prompt, type the below command, and then press Enter
a.  Get-AzurePublishSettingsFile
3.       A web browser opens at https://windows.azure.com/download/publishprofile.aspx for signing in to Windows Azure.
4.       Sign in to the Windows Azure Management Portal, and then follow the instructions to download your Windows Azure publishing settings. Save the file as a .publishsettings type file to your computer.
5.       In the Windows Azure PowerShell window, at the command prompt, type the following command, and then press Enter.
a.  Import-AzurePublishSettingsFile .publishsettings
Replace with the file name of the publishsettings file that you  downloaded in the previous step.
Detail step can be found here https://msdn.microsoft.com/en-us/library/dn385850(v=nav.70).aspx


Another method is to go with Interactive log in by using Connect-AzureRmAccount

Option 2

Step
  1. Type Connect-AzureRmAccount. You will get dialog box asking for your Azure credentials.
  2. Type the email address and password associated with your account. Azure authenticates and saves the credential information, and then closes the window.

Detail step can be found here https://docs.microsoft.com/en-us/powershell/azure/authenticate-azureps?view=azurermps-5.7.0