Click here to Skip to main content
65,938 articles
CodeProject is changing. Read more.
Articles / Hosted-services / Azure

Set-AzureSubscription from a Publish File

0.00/5 (No votes)
31 Jan 2017Ms-PL 4.4K  
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 to make the script runnable everywhere with simple copy/paste without any other deployment.

If you are using the free version, or if 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 the following link:

License

This article, along with any associated source code and files, is licensed under The Microsoft Public License (Ms-PL)