Category Archives: Powershell

Set-AzureSubscription from a publish file

IaaS Management Studio generates powershell script for everything you do.

Most operations on VMs start like that

$cert64 = [System.Convert]::FromBase64String("#Base64 of the certificate....")
$cert = New-Object 'System.Security.Cryptography.X509Certificates.X509Certificate2' $cert64, ""
Set-AzureSubscription -SubscriptionName "AO-IS Bizpark" -SubscriptionId "a26aaa6a-e02a-2746-9140-4bdca437f224" -Certificate $cert -ServiceEndpoint https://management.core.windows.net/

This allows the make the script runnable everywhere with simple copy/paste without any other deployment.

If you are using the free version, or you are adjusting the code for your own scripts, then you will prefer to create a subscription from a publish setting file downloaded from Azure Portal, so here is an alternative version to do the exact same thing from a publish file.

Set-AzureSubscription –SubscriptionName “Subscription from publishsettings” –SubscriptionDataFile “account.publishsettings”

As a reminder, you can get your publish settings file by going to following link : https://manage.windowsazure.com/publishsettings/index