How does Windows Azure PowerShell import publishsettings using Import-AzurePublishSettingsFile command?

As you already know you can use Windows Azure Powershell to manage your Windows Azure Service. To get it started,  you need to setup your development machine to be ready to use Windows Azure PowerShell commands and this is done by downloading the publishsetting file from Windows Azure Management Portal about your account first.

 

To download the Windows Azure PowerShell you can use the following command in PowerShell

PS C:\> Get-AzurePublishSettingsFile

 

The above command launches the following URL which allows you to download the .publishsettings on your local machine.

https://windows.azure.com/download/publishprofile.aspx?wa=wsignin1.0

 

Based on number of subscription(s) associated with your Live ID you will see that many certificate added in your management certificate sections as shows below:

 

 

Once you save the .publishsettings file locally you can use it with PowerShell as below:

PS C:\> Import-AzurePublishSettingsFile WindowsAzureInternal-11-20-2012-credentials.publishsettings

Setting: Windows Azure Internal Consumption - ******* as the default and current subscription. To view other subscriptions use Get-AzureSubscription

 

When above command runs it creates configuration specific setting the local machine located as below:

 

C:\Users\<Windows_Login_User_Name>\AppData\Roaming\Windows Azure Powershell

  •  config.json
  • DefaultSubscriptionData.xml
  • publishSettings.xml

  

If you open publishsettings.xml you will see the Certificate Thumb print as below:

 

  <?xml version="1.0"?>
 <PublishData xmlns:xsi="https://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="https://www.w3.org/2001/XMLSchema">
 <PublishProfile PublishMethod="AzureServiceManagementAPI" Url="https://management.core.windows.net/" ManagementCertificate="********************************************">
 <Subscription Id="GUID_1" Name="Windows Azure Internal Consumption *" />
 <Subscription Id="GUID_2" Name="Windows Azure Internal Consumption ****" />
 </PublishProfile>
 </PublishData>
 

In some case you may get an error as below while importing PublishSettings using Import-AzurePublishSettingsFile:

  Import-AzurePublishSettingsFile : Value can not be null.
 Parameter name: s
 At line:1 char:1
 

If that is the case, try the following solution:

  1. Go ahead and delete all the files in above location (C:\Users\<Windows_Login_User_Name>\AppData\Roaming\Windows Azure Powershell)
  2. Try again using the same command. This will re-generate the configuration files again the publish settings will be imported.