Before we can connect to Azure with PowerShell, we need to download the Azure PowerShell Module. Download and install the Windows Azure PowerShell Tools. Scroll down to Command-line Tools, under Windows PowerShell; click Install. Several components will be installed, you can take the defaults, accept the license agreement and let it go. Once done, click Finish. The Web Platform Installer will remain open allowing you to install additional components. You do not need any of them. Just click Exit
There are two ways you can authenticate to Windows Azure. You can store a username and password or you can use a certificate. If you want to authenticate with a password see How to: Connect to your subscription My preference is to use a certificate.
The Windows Azure PowerShell module includes cmdlets that help you download and import the certificate.
- The Get-AzurePublishSettingsFile cmdlet opens a web page on the Windows Azure Management Portal, from which you can download the subscription information. The information is contained in a .publishsettings file.
- The Import-AzurePublishSettingsFile imports the .publishsettings file for use by the module. This file includes a management certificate that has security credentials.
Important We recommend that you delete the publishing profile that you downloaded using Get-AzurePublishSettingsFile after you import those settings. Because the management certificate includes security credentials, it should not be accessed by unauthorized users. If you need information about your subscriptions, you can get it from the Windows Azure Management Portal or the Microsoft Online Services Customer Portal.
- From a web browser: Sign in to the Windows Azure Management Portal (http://manage.windowsazure.com) using the credentials for your Windows Azure account.
- Open the Windows Azure PowerShell console: On a computer running at least Windows 8 or Windows Server 2012, you can use the built-in Search. From the Start screen, begin typing power. This produces a scoped list of apps that includes Windows PowerShell and once installed, Windows Azure PowerShell. Click Windows Azure PowerShell to open the console window. (To pin the app to the Start screen, right-click the icon then select pin to start.)
- In your PowerShell window Type the following command:
- When prompted, download and save the publishing profile and note the path and name of the .publishsettings file. This information is required when you run the Import-AzurePublishSettingsFile cmdlet to import the settings. The default location and file name format is:C:Users<UserProfile>Downloads[MySubscription-…]-downloadDate-credentials.publishsettings
- Type a command similar to the following, substituting your Windows account name and the path and file name for the placholders:
Import-AzurePublishSettingsFile C:Users<UserProfile>Downloads[MySubscription-…]-downloadDate-credentials.publishsettingsExample: Import-AzurePublishSettingsFile C:UsersCampAdminDownloadsBizSpark-Pay-As-You-Go-1-28-2014-credentials.publishsettings
- Delete the .pushlishsettings file it is no longer needed and should not be left around to get compromised.
- If you have multiple accounts you can simply login to Windows Azure with the other account credentials (step 1 above) then repeat steps 4-7 for the other accounts.
Note: If you are added to other subscriptions as a co-administrator after you import your publish settings, you’ll need to repeat this process to download a new .publishsettings file, and then import those settings. For information about adding co-administrators to help manage services for a subscription, see Add and Remove Co-Administrators for Your Windows Azure Subscriptions.
View account and subscription details
You can have multiple accounts and subscriptions available for use by Windows Azure PowerShell.
To see the available accounts, type:
To see subscription information, type:
For help from the community, try these popular forums:
These are some of the resources available that you can use to learn to use Windows Azure and Windows PowerShell.
- To provide feedback about the cmdlets, report issues, or access the source code, see Windows Azure PowerShell code repository.
- Windows Azure Scripting Center
- To learn about the Windows PowerShell command line and scripting environment, see the TechNet Script Center.
- For information about installing, learning, using, and customizing Windows PowerShell, see Scripting with Windows PowerShell.
- For information about what scripts are and how to run them in Windows PowerShell, see Running Scripts. This article includes basic information about creating scripts and configuring your computer to run scripts.
- For information about cmdlets for Windows Azure AD, see Manage Windows Azure AD using Windows PowerShell.