Windows Azure – Deployment using Powershell

In my last post I described about how to create new service on windows azure using power shell.
In this post I am going to explain how can we do a production deployment using powershell.
The pre-requisites are again same-

  • Configure remote execution
  • Import windows azure powershell cmdlets.

This time we will be setting subscription differently. We will use publish file to set the subscription. You can get the publish file by –

  • Donwloading it manually by browsing directly to the site:https://windows.azure.com/download/publishprofile.aspx
  • You can use following powershell cmdlet- Get-AzurePublishSettingsFile. 
    This command will automatically download the publish file by taking you to windows azure web site.

Once you have publish file downloaded you can setup the subscription by following cmdlet-
Import-AzurePublishSettingsFile ‘PATH OF PUBLISH FILE\MySubs.publishsettings’

You can verify the subscription by following cmdlet-
Get-AzureSubscription

I am assuming you have created the service and you just want to have a production deployment. To do the deployment run following cmdlet-

#Variables Declaration
$service = “testpowershelldeploymentfromstorage” #this is the name of the cloud service you created
$slot = “production” #staging or production
$package = “PATH OF PACKAGE FILE\TestPowerShell.cspkg”
$configuration = “PATH OF CONFIG FILE\ServiceConfiguration.Cloud.cscfg”
$deploymentLabel = “PowerShell Deployment”

# Deployment cmdlet
New-AzureDeployment -Slot $slot -Package $package -Configuration $configuration -label $deploymentLabel -ServiceName $service

There you go. You will see the outputs and after it is done you can go to azure portal and see the deployment.