<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>domgreen.com &#187; service management API</title>
	<atom:link href="http://domgreen.com/tag/service-management-api/feed/" rel="self" type="application/rss+xml" />
	<link>http://domgreen.com</link>
	<description>The geek will inherit the Earth</description>
	<lastBuildDate>Mon, 07 Jun 2010 08:42:44 +0000</lastBuildDate>
	<generator>http://wordpress.org/?v=2.8.5</generator>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
			<item>
		<title>Service management API &#8211; REST on REST</title>
		<link>http://domgreen.com/2010/01/11/service-management-api-rest-on-rest/</link>
		<comments>http://domgreen.com/2010/01/11/service-management-api-rest-on-rest/#comments</comments>
		<pubDate>Mon, 11 Jan 2010 23:39:29 +0000</pubDate>
		<dc:creator>domgreen</dc:creator>
				<category><![CDATA[Windows Azure]]></category>
		<category><![CDATA[Azure]]></category>
		<category><![CDATA[REST]]></category>
		<category><![CDATA[service management API]]></category>
		<category><![CDATA[WCF]]></category>
		<category><![CDATA[WCF REST]]></category>

		<guid isPermaLink="false">http://domgreen.com/2010/01/11/service-management-api-rest-on-rest/</guid>
		<description><![CDATA[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 [...]]]></description>
			<content:encoded><![CDATA[<p>In a <a href="http://domgreen.com/2010/01/06/azure-service-management-api-via-c/" target="_blank">previous post</a> I mentioned using the Service Management API <a href="http://code.msdn.microsoft.com/Release/ProjectReleases.aspx?ProjectName=windowsazuresamples&amp;ReleaseId=3233" target="_blank">sample library</a> to call out to the Azure fabric from within a C# application.</p>
<p>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.</p>
<p>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 <strong>exactly</strong> the same code as I was elsewhere.</p>
<p><a href="http://domgreen.com/wp-content/uploads/2010/01/image1.png"><img style="border-right-width: 0px; display: block; float: none; border-top-width: 0px; border-bottom-width: 0px; margin-left: auto; border-left-width: 0px; margin-right: auto" title="Dom Green - httpRequest" border="0" alt="Dominic Green - httpRequest" src="http://domgreen.com/wp-content/uploads/2010/01/image_thumb1.png" width="642" height="209" /></a> </p>
<p>After a push in the right direction from <a href="http://blogs.msdn.com/simondavies/default.aspx" target="_blank">Simon Davies</a> we found out&#160; 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 <a href="http://blogs.msdn.com/pedram/archive/2008/07/19/webchannelfactory-inside-a-wcf-service.aspx" target="_blank">handy blog post</a>, help solve all my issues, all that was needed was to create a second OperationalContext before calling the management service.</p>
<pre class="brush: c-sharp" name="code">using(new OperationContextScope((IContextChannel)WebRole.serviceManagement))
{
  var hostedServices = WebRole.serviceManagement.ListHostedServices(subscriberID);

  foreach (HostedService service in hostedServices)
  {
    Trace.TraceInformation(&quot;Hosted Service: {0}&quot;, service.ServiceName);
  }
}
            </pre>
<p>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.</p>
]]></content:encoded>
			<wfw:commentRss>http://domgreen.com/2010/01/11/service-management-api-rest-on-rest/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Azure Service Management API &#8211; via C#</title>
		<link>http://domgreen.com/2010/01/06/azure-service-management-api-via-c/</link>
		<comments>http://domgreen.com/2010/01/06/azure-service-management-api-via-c/#comments</comments>
		<pubDate>Wed, 06 Jan 2010 08:58:38 +0000</pubDate>
		<dc:creator>domgreen</dc:creator>
				<category><![CDATA[Windows Azure]]></category>
		<category><![CDATA[code]]></category>
		<category><![CDATA[csmanage]]></category>
		<category><![CDATA[service management API]]></category>

		<guid isPermaLink="false">http://domgreen.com/2010/01/06/azure-service-management-api-via-c/</guid>
		<description><![CDATA[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 [...]]]></description>
			<content:encoded><![CDATA[<p>I previously published an article showing how the <a href="http://msdn.microsoft.com/en-us/library/ee460799.aspx" target="_blank">Service Management API</a> and the <a href="http://code.msdn.microsoft.com/Release/ProjectReleases.aspx?ProjectName=windowsazuresamples&amp;ReleaseId=3233" target="_blank">csmanage</a> tool could be used to aid in the deployment of your Windows Azure application as <a href="http://domgreen.com/2009/09/29/deploying-to-the-cloud-as-part-of-your-daily-build/" target="_blank">part of your daily build</a>.</p>
<p>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.</p>
<p><a href="http://domgreen.com/wp-content/uploads/2010/01/serviceManagement.png"><img style="border-right-width: 0px; margin: 0px 0px 10px 10px; display: inline; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px" title="Dom Green - serviceManagement" border="0" alt="Dominic Green - serviceManagement" align="right" src="http://domgreen.com/wp-content/uploads/2010/01/serviceManagement_thumb.png" width="197" height="191" /></a>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 <a href="http://code.msdn.microsoft.com/Project/Download/FileDownload.aspx?ProjectName=windowsazuresamples&amp;DownloadId=8254" target="_blank">this very handy library</a> 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).</p>
<p>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.</p>
<pre class="brush: c-sharp" name="code">namespace serviceManagementConsoleApplication
{
    class Program
    {
        private const string subscriberID = &quot;...&quot;;

        static void Main(string[] args)
        {
            var serviceManagment = ServiceManagementHelper.CreateServiceManagementChannel				   (&quot;WindowsAzureEndPoint&quot;, new X509Certificate2(&quot;insertcert&quot;));

 	    var x = serviceManagment.ListHostedServices(subscriberID);

            foreach (HostedService s in x)
            {
                Console.WriteLine(s.ServiceName);
            }

            Console.Read();
        }
    }
}</pre>
<p>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.</p>
<p>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.</p>
<pre class="brush: xml" name="code"><configuration>
  <system .servicemodel>
    <bindings>
      <webhttpbinding>
        <binding name="WindowsAzureServiceManagement_WebHttpBinding" closetimeout="00:01:00" opentimeout="00:01:00" receivetimeout="00:10:00" sendtimeout="00:01:00">
          <readerquotas maxstringcontentlength="1048576" maxbytesperread="131072" />
          <security mode="Transport">
<transport clientcredentialtype="Certificate" />
          </security>
        </binding>
      </webhttpbinding>
    </bindings>
    <client>
      <endpoint name="WindowsAzureEndPoint" contract="Microsoft.Samples.WindowsAzure.ServiceManagement.IServiceManagement" binding="webHttpBinding" address="https://management.core.windows.net" bindingconfiguration="WindowsAzureServiceManagement_WebHttpBinding" />
    </client>
  </system>
</configuration></pre>
<p>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.</p>
<p>Download the sample library <a href="http://code.msdn.microsoft.com/Release/ProjectReleases.aspx?ProjectName=windowsazuresamples&amp;ReleaseId=3233" target="_blank">here</a>.</p>
]]></content:encoded>
			<wfw:commentRss>http://domgreen.com/2010/01/06/azure-service-management-api-via-c/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
	</channel>
</rss>
