domgreen

The Geek Will Inherit the Earth

  • Service management API – REST on REST

    • 12 Jan 2010
    • 0 Responses
    •  views
    • Azure REST WCF WCF REST Windows Azure service management API
    • Edit
    • Delete
    • Tags
    • Autopost

    In a previous post I mentioned using the Service Management API sample library to call out to the Azure fabric from within a C# application.

    The natural progression from here was to get the code working from within a web or worker role instance hosted within the cloud. Using a web role, I used the OnStart method to set up a IServiceManagent class that could then be shared with the remainder of the classes within the role.

    When tracing the hosted services from either the OnStart method or from within default.aspx.cs I could successfully print out all of the services within my account. However, when I set up a WCF REST service to return these hosted services in an array I started to get an error with the connection to the Management API. Giving a argument error stating that a property with the name “httpRequest” is not present. This was even happening when I was using exactly the same code as I was elsewhere.

    Media_httpdomgreencom_yxjeg

    After a push in the right direction from Simon Davies we found out  that the issue was in the WCF REST service already having an OperationContext from the original REST call before calling out to the Service Management API. This handy blog post, help solve all my issues, all that was needed was to create a second OperationalContext before calling the management service.

    Ta dar … everything now works, we can use the above code snippet to retrieve back all our hosted services by calling our own web role.

    • Tweet
  • Azure Service Management API – via C#

    • 6 Jan 2010
    • 0 Responses
    •  views
    • Windows Azure code csmanage service management API
    • Edit
    • Delete
    • Tags
    • Autopost

    I previously published an article showing how the Service Management API and the csmanage tool could be used to aid in the deployment of your Windows Azure application as part of your daily build.

    Once I had began playing with the API’s, I wanted to be able to use them within an application so that I would be able to create something like a simple dashboard for managing your services without calling to csmanage all of the time.

    I started to do this by building up the REST requests within the application and performing a HTTP GET from my application. However, I then found this very handy library from Microsoft that has done the leg work around all of the calls needed for the service API (almost like a Blue Peter, here’s one I made earlier).

    You can see in the code below that to utilize the library, we first need to create a ServiceManagementHelper class. This class will then be used to call out to each of the available services. To create this helper class we need to pass in a reference to an endpoint in app.config (show further down) and a reference to the certificate uploaded to manage our service.

    As you can see in the code once the helper is set up we can call any of the services such as ListHostedServices which will return an list containing each service we have hosted in our account.

    As mentioned above we need to have an endpoint set up for the helper class to call out to, the configuration for this is shown below.

    With the configuration set up and the sample service management API library, we can easily get any application to call out and manage our cloud services.

    Download the sample library here.

    • Tweet
  • About

    By day a virtual warrior, hunched over a keyboard cranking out line after line of code at Huddle, living the East London tech dream at Silicon Roundabout. We are an Enterprise collaboration tool that will revolutionise how your company collaborates, shares and operates, we are taking the fight to Microsoft SharePoint, we are David and we're taking on Goliath.

    However, by night this pasty geek escapes his keyboard and monitor with the attempt to get fit. I train at one of the greatest gyms in London, Thames CrossFit. CrossFit is not like other gyms its a lifestyle, and as the guys at Thames say you must be prepared to work hard.

    I also run with the great Run Dem Crew a Shoreditch based running family who run the mean streets of London by night. RDC is a mecca for runners, and creatives alike.

    With all this training its bound to get hard, its bound to be tough but its certainly worth it when you achieve something great and make friends along the way.

    So remember, "Pain is temporary but victory is forever".

    75680 Views
  • Archive

    • 2011 (13)
      • June (2)
      • May (5)
      • April (6)
    • 2010 (3)
      • April (1)
      • January (2)

    Get Updates

    Subscribe via RSS
    TwitterBuzz