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.

Windows Azure PowerShell

Windows Azure PowerShell is a powerful scripting environment thatcan be used to control and manage the windows azure environment. Windows Azure PowerShell gives set of commandlets which can be used to create amd manage windows azure services, web sites and VMs.

I was looking for way to automate deployments and found that the windows azure powershell can be one of the tools which can be used for most of the things we do on windows azure platform like –

  • Connect to Windows Azure subscription
  • Create New Windows Azure Service
  • Create New Deployment
  • Remove existing deployments and services
  • Provisioning and de-provisioning of VMs and many more.

As I am going deep and learning the PowerShell I am kind of fascinated to it. I will start a series on what I understand of PowerShell and will come up with scripts to automate the whole deployment process.

I am also planning to come up with some kind of .Net Application which will be kind of wrapper around PowerShell but with an easy interface.