How to deploy Microsoft Azure using PowerShell

Pre-requisite :

  • Windows XP or more later version of Windows OS.
  • Powershell 2.0 installed
  • PowerShell for Azure installed
  • Azure Project compiled and packaged

Steps :

  1. Open PowerShell for Azure
  2. Initialize PowerShell with Azure Libraries :
    import-module "C:\Program Files (x86)\Microsoft SDKs\Windows Azure\PowerShell\Azure\Azure.psd1"
  3. Retrieve Azure Publish Settings Files :
  4. Fill in account credentials used for publishing in web browser
  5. Copy .publishsettings file into your deployment directory, in this example C:\dev\Azure_Deployment\settings_cert
  6. Rename publish settings files to myFirstAzurePSDeployment.publishsettings
  7. Use publishsettingsfile to associate the Azure Account with your current machine or computer
    Import-AzurePublishSettingsFile C:\dev\Azure_Deployment\settings_cert\myFirstAzurePSDeployment.publishsettings
  8. Once the import is completed, the following output will be shown in the PowerShell command prompt :
    Success :
     Setting: LV Cloud Core Development Account as the default and current subscription.
  9. To view other subscriptions use Get-AzureSubscription
  10. To confirm the Azure account association is successful run the following, command

    to get the similar output :

     SubscriptionName : My Azure Deployment PS
     SubscriptionId : 067b7777-1234-abcd-4567-1234c38e5dcb
     Certificate : [Subject]
     CN=Windows Azure Tools[Issuer]
     CN=Windows Azure Tools[Serial Number]
    [Not Before]
     1/10/2013 7:35:23 AM
    [Not After]
    1/10/2014 7:35:23 AM
    ServiceEndpoint :
    SqlAzureServiceEndpoint :
    CurrentStorageAccount : MyFirstAzureDeploymentPSBLOB
    IsDefault : True
    SubscriptionName : MyAzureDeploymentPS
    SubscriptionId : 9fa79dac-3569-4154-b1d9-7863259b8bef
    Certificate : [Subject]
    CN=Windows Azure Tools
    CN=Windows Azure Tools
    [Serial Number]
    [Not Before]
    3/22/2013 11:05:06 AM
    [Not After]
    3/22/2014 11:05:06 AM
    ServiceEndpoint :
    SqlAzureServiceEndpoint :
    CurrentStorageAccount :
    IsDefault : False
  11. Select the correct Azure subscription which will be used as the targeted to be deployed.
    Select-AzureSubscription “My First Azure Deployment PS”
  12. Initialize Azure subscription with the correct BLOB storage, the BLOB storage will be used by Azure during deployment as a temporary upload location before Azure will install your software project into Azure Instances (Web Role or Worker Role).
    Set-AzureSubscription "My First Azure Deployment PS" - CurrentStorageAccount MyFirstAzureDeploymentPSBLOB
  13.  Confirm your Azure ServiceName which will be used to have your Azure Application deployed, use the following command to list the Hosted Services.Get-AzureService
    Example of output :

    Label : MyAzureDeploymentPS
     Description : description of the subsystem
     AffinityGroup : 9bf5714d-3c8e-44e0-985f-c4626c495284
     Location :
     Status : Created
     DateModified : 2012-12-04T03:14:12Z
     DateCreated : 2012-11-06T22:37:59Z
     Url :
     ServiceName : MyAzureDeploymentPS
     OperationDescription : Get-AzureService
     OperationId : ea0dd11d-e3f2-46ec-8fd1-a2e472d07b85
     OperationStatus : Succeeded
  14. Once everything is in order from step 1 to step 12, use the following command to deploy your Azure Project. It is important to ensure there are no existing Service running in the Azure ServiceName staging slot.
    New-AzureDeployment -ServiceName MyAzureDeploymentPS -Package C:\dev\VS-TFS\MyExamples\MyAzureDeploymentPS\bin\Release\app.publish\MyAzureDeploymentPS.cspkg -Configuration C:\dev\VS-TFS\MyExamples\MyAzureDeploymentPS\bin\Release\app.publish\MyAzureDeploymentPS.cscfg -Slot staging -Label "My Azure Deployment PS" -Name MyAzureDeploymentPS
  15. Check the temporary URL in the staging environment, make sure your application is able to behaves as expected.
  16. Lastly, to perform Virtual IP Swap; swapping the application from staging slot to production slot of Azure, make sure that the production slot of the ServiceName is empty. Then run :
    Move-AzureDeployment -ServiceName "MyAzureDeploymentPS"
  17. If there is no error until Step 16, you are done deploying Azure Package into Azure account using PowerShell.

Leave a Reply

Your email address will not be published. Required fields are marked *

To prove you're a person (not a spam script), type the answer to the math equation shown in the picture. Click on the picture to hear an audio file of the equation.
Click to hear an audio file of the anti-spam equation

This site uses Akismet to reduce spam. Learn how your comment data is processed.