Service Management API

Posted: November 10, 2011 in Windows Azure
Tags: , ,

After you have finished the development of your windows azure application and deploy it on the cloud, created the number of instance and finally everything is running. After a while you are looking to scale your application, increase or decrease the number of instances created, you don’t have to delete the application on your portal to change the configuration and deploy it back, you can do all this programmatically using Windows Azure Service Management API.

So what does that management API can do? Well actually it can do a lot of things, I will mention only the things it can’t do:

  1. it cannot create a new service.
  2. It cannot create a new storage account.

Only these 2 things you have to do them through the portal. Otherwise, you can do whatever you want with your apps.

So what do you need to start doing this?

You have 2 choices even you work with Windows PowerShell or use the tools designed for this like Windows Azure cmdLets.

Some of you might think “I am using Windows 7, I don’t have PowerShell” or “How can I find this?”. The answer is too easy open “My Computer” and under this URL you will find the Windows PowerShell “C:\Windows\System32\WindowsPowerShell\v1.0” or if you are running a 64 bit operating system then you will find the file in “C:\Windows\SysWOW64\WindowsPowerShell\v1.0”. Don’t forget to run it as administrator.

Now before proceeding to the next step you must define which certificate will allow you to make a connection between you and your Windows Azure Account. So to create a Certificate:

  1. Run Visual studio Command Prompt as administrator
  2. Change the directory where you want to save the certificate in it
  3. Write this in it:

    “makecertificate –r –pe –n “CN=AzureMgmt” –a sha1 –len 2048 –ss “<the certificate name>.cer””

  4. Press Enter
  5. Now you will find the certificate created in the desired folder.

Upload you certificate on your windows azure portal by clicking add a new certificate you will then upload the certificate and take note the thumbnail print and the subscription ID.

Now to start using the power shell to deploy, to monitor your app… Run the Windows PowerShell as administrator, add the following support for the Azure services.

Add-PSSnapIn AzureManagementToolsSnapIn

Now you can:

New-Deployement –ServiceName <the service name> -SubcriptionId <your subscriptionid> -cert (get-item cert:\<the Cert location>) –slot staging –package<package_location> -configuration<configuration location> -label “v2.0” –storageServiceName <storage service name>

Or even upgrade the available deployment:

Get-HostedService -serviceName <service name> -subscriptionId <subscription id> -certificate (get-item cert:\<Certification Location>) | Get-Deployment staging Set-Deployment -package <package location> -configuration <configuration location> -label "v2.1" 
Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s