If you’re automating Windows Azure using Windows PowerShell, one of the first things you’ll probably notice is that you need a management certificate to connect to the Windows Azure subscription that you’re attempting to view or modify. Management certificates are associated to a Windows Azure subscription inside the Management Portal, under the Hosted Services, Storage Accounts & CDN –> Management Certificates section (see screenshot).
Once you have associated a management certificate with a subscription, it needs to be imported into your local computer’s certificate store so that it can be used from PowerShell to manage the Azure subscription. To do this, follow these directions:
- Open MMC
- Add the certificates snap-in (for current user or local computer)
- Navigate to the Personal –> Certificates “folder”
- Right-click the Certificates node and select All Tasks –> Import
- Select the file on the filesystem that contains the certificate
- Select the Personal certificate store if necessary and finish the import wizard
- Double-click the certificate in the Certificates MMC snap-in
- Visit the Details tab
- Scroll down to the Thumbprint field and copy the value into Metapad or equivalent
Now that you’ve taken down the thumbprint of the certificate, you can use PowerShell to retrieve the certificate from the current user’s certificate store. If the certificate resides in the local computer’s certificate store, you’ll have to replace “CurrentUser” with “LocalMachine.” To get the certificate, check out the code below.
$AzureCertThumbprint = ‘4DAE6C3F444F21972B0823467C229605’;
$AzureCert = Get-Item -Path cert:\CurrentUser\My\$AzureCertThumbprint;
The [cci lang=”powershell”]$AzureCert[/cci] variable now holds a reference to the management certificate, and you can now use this to manage your Windows Azure subscription!