Working with Windows Azure Management REST API

I’ve been searching the web for solutions on automating Virtual Machine creation on Azure. I wanted to do it from C# code. The following options came into picture (A great help on all the approaches is when you have the Windows Azure Service Management API Reference):

  1. Calling Powershell cmdlets with the RunspaceConfiguration like here. I didn’t like this approach as I wanted to talk to C# classes and so on…
  2. Another option was to work with manually built WebRequest instances like in the article on Programatically Adding Management Certificates to WebRequests using Azure Rest API. This approach was at least good for me to understand how I can deal with my certificates in the same way as the article on Programatically Installing Management Certificates. I’ve also created a working WebRequest in a Post A simple way of creating and sending request on the Azure Management REST API
  3. There was a good way for starting on a WCF client in the Windows Azure ServiceManagement Sample. But that interface didn’t contain every method I needed.
  4. Gotti (see his blog among my followed list) gave me an idea to use the Microsoft.WindowsAzure.ServiceManagementClient from the C:\Program Files\Microsoft SDKs\Windows Azure\.NET SDK\2012-10\bin\Microsoft.WindowsAzure.ServiceManagementClient.dll, however its interface is also pretty small, it wasn’t enough for my needs:
    public class CloudManagmentClient
        public CloudManagmentClient(CloudManagmentAccount account);
        public CloudManagmentAccount Account { get; }
        public TimeSpan PollInterval { get; set; }
        public TimeSpan PollTimeout { get; set; }
        public TimeSpan ReciveTimeout { get; set; }
        public TimeSpan SendTimeout { get; set; }
        public event EventHandler CommandProgress;
        public void AddCertificate(string hostedServiceName, X509Certificate2 cert);
        public void ClearClientCache();
        public Disk CreateDisk(Disk disk);
        public OSImage CreateOSImage(OSImage image);
        public void DeleteCertificate(string hostedServiceName, string thumbprint);
        public void DeleteDisk(string diskName);
        public void DeleteOSImage(string imageName);
        public CloudAffinityGroup GetAffinityGroup(string affinityGroupName);
        public X509Certificate2 GetCertificate(string hostedServiceName, string thumbprint);
        public Disk GetDisk(string diskName);
        public DiskList GetDisks();
        public CloudHostedService GetHostedService(string serviceName, bool embedDetail);
        public CloudLocation GetLocation(string locationName);
        public CloudMachineImage GetMachineImage(string name);
        public OSImage GetOSImage(string imageName);
        public OSImageList GetOSImages();
        public CloudStorageService GetStorageService(string serviceName);
        public IEnumerable ListAffinityGroups();
        public IEnumerable ListCertificates(string hostedServiceName);
        public IEnumerable ListHostedSerivces();
        public IEnumerable ListLocations();
        public IEnumerable ListMachineImages();
        public IEnumerable ListOperatingSystems();
        public IEnumerable ListStorageServices();
        public CloudMachineImage NewMachineImage(string name);

    A concrete way of using it looks like:

    var account = new CloudManagmentAccount();
    account.ApiCertificate = GetCertificate();
    account.SubscriptionId = SubscriptionId;
    account.ServiceManagmentEndpoint = new Uri("");
    var client = new CloudManagmentClient(account);
    var affinityGroups = client.ListAffinityGroups();

    where the GetCertificate() can be derived from the point 2.

  5. Finally I came to the point, that I need a better way which was provided by a Windows Azure Service Management Library Nuget Package which allows us to use the Management API in a typesafe manner. There is a tricky problem on Bad Request for which I’m going to provide a solution in the next posts…
  6. Another alternative can be – however I didn’t try it out yet – the Azure Fluent Management Library


The last two options sound pretty good to work with however the Windows Azure Service Management Library Nuget package can have a problem when the Rest API gets changed. In the future I’m going to take a closer look at the Fluent Library.


About Tamas Nemeth

Husband and proud father of two daughters in Nürnberg. I'm working as a Senior Software Developer and an enthusiastic Clean-Coder. I spend most of my free time with my family (playing, hiking, etc...). I also play table-tennis and badminton sometimes...
This entry was posted in Technical Interest and tagged , , , , , , , , . Bookmark the permalink.

12 Responses to Working with Windows Azure Management REST API

  1. I could not refrain from commenting. Very well written!

  2. cardsharing says:

    Hello mates, how is the whole thing, and what you would like to say regarding this paragraph, in my view
    its genuinely amazing in favor of me.

  3. Why viewers still make use of to read news papers when in this technological globe everything is presented on net?

  4. Thank you for the auspicious writeup. It in truth was
    once a amusement account it. Glance advanced to far introduced agreeable from you!

    However, how can we be in contact?

  5. Hmm is anyone else encountering problems with the pictures on this
    blog loading? I’m trying to find out if its a problem on my end or if it’s the blog.
    Any feedback would be greatly appreciated.

  6. Thanks for sharing your info. I really appreciate your efforts and I am waiting for your next post thanks once

  7. My spouse and I stumbled over here different web address and thought I should check things out.
    I like what I see so now i am following you.

    Look forward to looking at your web page for a second

  8. I like the helpful info you provide in your articles. I’ll bookmark your weblog and check again here frequently. I am quite sure I’ll learn many new stuff
    right here! Good luck for the next!

  9. immo killer says:

    Hello! This is my first visit to your blog!
    We are a group of volunteers and starting a new project in a community in the same niche.
    Your blog provided us beneficial information to work on.
    You have done a outstanding job!

  10. whoah this weblog is excellent i love reading your articles.

    Keep up the great work! You know, a lot of individuals are looking round for this information,
    you can help them greatly.

  11. crafts dolls says:

    I was suggested this website by means of my cousin. I am no longer
    certain whether or not this publish is written by way of him as nobody else recognize such specific about my problem.
    You are wonderful! Thank you!

  12. Hi there! I could have sworn I’ve visited this web site before but after browsing through a few
    of the articles I realized it’s new to me. Anyhow,
    I’m certainly delighted I stumbled upon it and I’ll be book-marking it and checking
    back regularly!

Leave a Reply

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

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

Google+ photo

You are commenting using your Google+ 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 )


Connecting to %s