find a location for property in a new city

Wednesday, 11 January 2012

Using the Azure API to see a deployment status using .NET

See the status of your Windows Azure deployments using the Windows Azure Service Management REST API. Since this is REST based you can use any framework or programming language that can make web requests. Python, Java etc here is .NET.

Here is a short bit of C# code that will allow you to call the part of the Windows Azure Service Management REST API that deals with getting the status of your hosted service in Azure.

You can see how the REST API is expected to be used here at Get Hosted Service Properties. This code accesses that API:

static void Main(string[] args)
    var subsctiptionId = "f62e5e87-5c76-4a94-9136-794fae3eff16";
    var hostedService = "colintest";
    //I have another post that details how GetCertificateByThumbprint method works:
    var certificate = GetCertificateByThumbprint("23A43AE81F15CB000000000000000000000000000");

    var statusApiUrl = string.Format(
       subsctiptionId, hostedService);
    var hostedServiceStatus = new Uri(statusApiUrl);
    Console.WriteLine("Hosted service status");
    MakeApiRequest(hostedServiceStatus, certificate);

private static void MakeApiRequest(Uri requestUri, X509Certificate2 certificate)
    var request = (HttpWebRequest)HttpWebRequest.Create(requestUri);
    request.Headers.Add("x-ms-version", "2011-10-01");
    request.Method = "GET";
    request.ContentType = "application/xml";

        using (var response = (HttpWebResponse)request.GetResponse())
            Console.WriteLine("Response status code: " + response.StatusCode);

            using (var responseStream = response.GetResponseStream())
            using (var reader = new StreamReader(responseStream))
                Console.WriteLine("Response output:");
    catch (Exception e)
        throw e;

Since you have used ?embed-detail=true in the querystring this add extra detail. From here you can get all sorts of useful information such as: Status e.g. Running or DeploymentSlot e.g. Production.

Note: The GetCertificateByThumbprint(string thumbprint) method I used is of course simplifying attaching a certificate to the request for the sake of conciseness. You can have a look at what this method is doing here at attaching a certificate to a WebRequest.

Follow britishdev on Twitter


  1. What’s up, it's miles very splendid and beneficial net website. Keep shaping the notable feature, exceptional to discover your realistic internet web page. Thanks for tremendous and Informative post. This article is without a doubt consists of lot more information about this issue relies. College paper writing service giving many ideas and methods for thesis writing papers

  2. I really had a great time with your post! I am looking forward to read more blog post regarding this!

  3. Motifz Designer Lawn. 1, 2 & 3 Piece Unstitched Premium Embroidered Lawn 2019, Premium Lawn, Lawn 2019, Best lawn collection, Motifz, Best Lawn in Pakistan, Shipping worldwide. Stitching option available.

  4. Awesome blog. I enjoyed reading your articles.
    tutu app
    tutuapp download

  5. Wholesale printed custom perfume boxes with the highest quality and affordable prices. Free worldwide Delivery and free Custom Perfume Boxes design.

  6. Buy online wholesale printed custom perfume boxes and packaging at easy prices and shipping worldwide, with 24/7 customer support. Get a free custom quote now!!

  7. Blackbird packaging provide you with any size, shape design, custom cbd boxes sooner than any other packaging competitor in the market

  8. mylar label bags in stock now. Ready made Cali pack designs. Fast Shipping at Your Supplies. Custom designs available

  9. Blackbird packaging provide you with any size, shape design, custom cbd bath bomb boxes sooner than any other packaging competitor in the market