<rss version="2.0" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:trackback="http://madskills.com/public/xml/rss/module/trackback/" xmlns:wfw="http://wellformedweb.org/CommentAPI/" xmlns:slash="http://purl.org/rss/1.0/modules/slash/" xmlns:copyright="http://blogs.law.harvard.edu/tech/rss" xmlns:image="http://purl.org/rss/1.0/modules/image/">
    <channel>
        <title>Windows Azure</title>
        <link>http://geekswithblogs.net/paulschapman/category/9376.aspx</link>
        <description>Adventures developing an Azure based application</description>
        <language>en-GB</language>
        <copyright>paulschapman</copyright>
        <managingEditor>paulschapman@xericsystems.com</managingEditor>
        <generator>Subtext Version 0.0.0.0</generator>
        <item>
            <title>Windows Azure, TDS, WCF, Silverlight and a few problems on the way Part IV &amp;ndash; The Silverlight Project</title>
            <link>http://geekswithblogs.net/paulschapman/archive/2009/05/26/windows-azure-tds-wcf-silverlight-and-a-few-problems-on-and-again.aspx</link>
            <description>&lt;h1&gt;Introduction&lt;/h1&gt;
&lt;p&gt;After a short sojourn with the Visual Studio 2010 Beta, I’m back with the next part. Pop quiz – can you run Visual Studio Team Foundation and Visual Studio Professional without Team Suite? Well some wit told a client you could not – so I spent some of the Bank Holiday proving otherwise – Another article there on setting it up, but in general it was incredibly easy for a server app! Anyway I digress back to the subject at hand – hosting a Silverlight Application in an Azure Application.&lt;/p&gt;
&lt;p&gt;This was the part that gave me the most gotchas. &lt;/p&gt;
&lt;h1&gt;Adding a Silverlight Project to the Azure Solution.&lt;/h1&gt;
&lt;p&gt;Right click on the Solution and click on the ‘Add New Project’.&lt;/p&gt;
&lt;p&gt;&lt;a href="http://geekswithblogs.net/images/geekswithblogs_net/paulschapman/WindowsLiveWriter/WindowsAzureTDSWCFSilverlightandafewprob_13772/image_2.png"&gt;&lt;img style="BORDER-BOTTOM: 0px; BORDER-LEFT: 0px; DISPLAY: inline; BORDER-TOP: 0px; BORDER-RIGHT: 0px" title="image" border="0" alt="image" width="244" height="157" src="http://geekswithblogs.net/images/geekswithblogs_net/paulschapman/WindowsLiveWriter/WindowsAzureTDSWCFSilverlightandafewprob_13772/image_thumb.png" /&gt;&lt;/a&gt; &lt;/p&gt;
&lt;p&gt;Select The ‘Silverlight Application’ – Give your Silverlight Application a name and then click on ‘OK’.&lt;/p&gt;
&lt;p&gt;When you hit the ‘OK’ button you will be presented with a new window to create the Web Application that will host the Silverlight App. Well we already have a web app. It is the WebRole – for this reason we select the third option – ‘Link this Silverlight control  into an existing Web Site’, if it has not already been selected.&lt;/p&gt;
&lt;p&gt;&lt;a href="http://geekswithblogs.net/images/geekswithblogs_net/paulschapman/WindowsLiveWriter/WindowsAzureTDSWCFSilverlightandafewprob_13772/image_4.png"&gt;&lt;img style="BORDER-BOTTOM: 0px; BORDER-LEFT: 0px; DISPLAY: inline; BORDER-TOP: 0px; BORDER-RIGHT: 0px" title="image" border="0" alt="image" width="244" height="218" src="http://geekswithblogs.net/images/geekswithblogs_net/paulschapman/WindowsLiveWriter/WindowsAzureTDSWCFSilverlightandafewprob_13772/image_thumb_1.png" /&gt;&lt;/a&gt; &lt;/p&gt;
&lt;p&gt;Of the three options at the bottom ensure the first is selected, we will raid this page for some code. Deselect the Make it the start page and select the Enable Silverlight debugging option.&lt;/p&gt;
&lt;p&gt;Now there is a known issue in the WCF Services SDK which may soon cause you at least a really annoying message; "this operation is not supported for a relative uri". While it is not fatal and you can ignore it – as a matter of good coding I tend to get rid of as many warning messages as possible. To fix it, open your machine.config (both x86 and x64 version), and delete the following section: &lt;br /&gt;
&lt;/p&gt;
&lt;pre class="csharpcode"&gt;   &lt;span class="kwrd"&gt;&amp;lt;&lt;/span&gt;&lt;span class="html"&gt;endpoint&lt;/span&gt; &lt;span class="attr"&gt;address&lt;/span&gt;&lt;span class="kwrd"&gt;=""&lt;/span&gt; &lt;span class="attr"&gt;binding&lt;/span&gt;&lt;span class="kwrd"&gt;="netTcpRelayBinding"&lt;/span&gt; &lt;span class="attr"&gt;contract&lt;/span&gt;&lt;span class="kwrd"&gt;="IMetadataExchange"&lt;/span&gt; &lt;span class="attr"&gt;name&lt;/span&gt;&lt;span class="kwrd"&gt;="sb"&lt;/span&gt; &lt;span class="kwrd"&gt;/&amp;gt;&lt;/span&gt;&lt;/pre&gt;
&lt;style type="text/css"&gt;&lt;![CDATA[
.csharpcode, .csharpcode pre
{
	font-size: small;
	color: black;
	font-family: consolas, "Courier New", courier, monospace;
	background-color: #ffffff;
	/*white-space: pre;*/
}
.csharpcode pre { margin: 0em; }
.csharpcode .rem { color: #008000; }
.csharpcode .kwrd { color: #0000ff; }
.csharpcode .str { color: #006080; }
.csharpcode .op { color: #0000c0; }
.csharpcode .preproc { color: #cc6633; }
.csharpcode .asp { background-color: #ffff00; }
.csharpcode .html { color: #800000; }
.csharpcode .attr { color: #ff0000; }
.csharpcode .alt 
{
	background-color: #f4f4f4;
	width: 100%;
	margin: 0em;
}
.csharpcode .lnum { color: #606060; }]]&gt;&lt;/style&gt;
&lt;p&gt; &lt;/p&gt;
&lt;h1&gt;Linking your Silverlight Application to your Webservice&lt;/h1&gt;
&lt;p&gt;Now last time we created a Web Service and it is now time to link the Webservice to the Silverlight Application. Right click on the Silverlight application you have created last time, and select ‘Add Service Reference’&lt;/p&gt;
&lt;p&gt;&lt;a href="http://geekswithblogs.net/images/geekswithblogs_net/paulschapman/WindowsLiveWriter/WindowsAzureTDSWCFSilverlightandafewprob_13772/image_6.png"&gt;&lt;img style="BORDER-BOTTOM: 0px; BORDER-LEFT: 0px; DISPLAY: inline; BORDER-TOP: 0px; BORDER-RIGHT: 0px" title="image" border="0" alt="image" width="244" height="197" src="http://geekswithblogs.net/images/geekswithblogs_net/paulschapman/WindowsLiveWriter/WindowsAzureTDSWCFSilverlightandafewprob_13772/image_thumb_2.png" /&gt;&lt;/a&gt; &lt;/p&gt;
&lt;p&gt;Click on the Discover button and it will search your solution for the Webservice. Give the Namespace a sensible name and click on OK.&lt;/p&gt;
&lt;p&gt;Go to the ServiceReferences.ClientConfig file in the Silverlight Client that is created when you link a webservice. Look for the client tag;&lt;/p&gt;
&lt;pre class="code"&gt;&lt;span style="COLOR: blue"&gt;&amp;lt;&lt;/span&gt;&lt;span style="COLOR: #a31515"&gt;client&lt;/span&gt;&lt;span style="COLOR: blue"&gt;&amp;gt;
    &amp;lt;&lt;/span&gt;&lt;span style="COLOR: #a31515"&gt;endpoint &lt;/span&gt;&lt;span style="COLOR: red"&gt;address&lt;/span&gt;&lt;span style="COLOR: blue"&gt;=&lt;/span&gt;"&lt;span style="COLOR: blue"&gt;http://localhost:51159/SimplicitaServices.svc&lt;/span&gt;"
        &lt;span style="COLOR: red"&gt;binding&lt;/span&gt;&lt;span style="COLOR: blue"&gt;=&lt;/span&gt;"&lt;span style="COLOR: blue"&gt;basicHttpBinding&lt;/span&gt;" &lt;span style="COLOR: red"&gt;bindingConfiguration&lt;/span&gt;&lt;span style="COLOR: blue"&gt;=&lt;/span&gt;"&lt;span style="COLOR: blue"&gt;BasicHttpBinding_ISimplicitaServices&lt;/span&gt;"
        &lt;span style="COLOR: red"&gt;contract&lt;/span&gt;&lt;span style="COLOR: blue"&gt;=&lt;/span&gt;"&lt;span style="COLOR: blue"&gt;SimplicitaServices.ISimplicitaServices&lt;/span&gt;" &lt;span style="COLOR: red"&gt;name&lt;/span&gt;&lt;span style="COLOR: blue"&gt;=&lt;/span&gt;"&lt;span style="COLOR: blue"&gt;BasicHttpBinding_ISimplicitaServices&lt;/span&gt;" &lt;span style="COLOR: blue"&gt;/&amp;gt;
&amp;lt;/&lt;/span&gt;&lt;span style="COLOR: #a31515"&gt;client&lt;/span&gt;&lt;span style="COLOR: blue"&gt;&amp;gt;&lt;/span&gt;&lt;/pre&gt;
&lt;p&gt;&lt;a href="http://11011.net/software/vspaste"&gt;&lt;/a&gt;Change the port number to the same port number that your Azure project executes on. In my development environment this tends to be 81, for yours it might be different.&lt;/p&gt;
&lt;p&gt;We nearly have set up the Silverlight application. One last task remains. Silverlight will not retrieve data from some sites, including some webservices unless it has been given permission. You do this by placing a clientaccesspolicy.xml file in the root of the web server. However for this site, which is being run in the virtual server of Visual Studio that in effect means the root of the site. So add a file with that name to your site and insert the following code;&lt;/p&gt;
&lt;pre class="code"&gt;&lt;span style="COLOR: blue"&gt;&amp;lt;&lt;/span&gt;&lt;span style="COLOR: #a31515"&gt;access-policy&lt;/span&gt;&lt;span style="COLOR: blue"&gt;&amp;gt;
  &amp;lt;&lt;/span&gt;&lt;span style="COLOR: #a31515"&gt;cross-domain-access&lt;/span&gt;&lt;span style="COLOR: blue"&gt;&amp;gt;
    &amp;lt;&lt;/span&gt;&lt;span style="COLOR: #a31515"&gt;policy&lt;/span&gt;&lt;span style="COLOR: blue"&gt;&amp;gt;
      &amp;lt;&lt;/span&gt;&lt;span style="COLOR: #a31515"&gt;allow-from &lt;/span&gt;&lt;span style="COLOR: red"&gt;http-request-headers&lt;/span&gt;&lt;span style="COLOR: blue"&gt;=&lt;/span&gt;"&lt;span style="COLOR: blue"&gt;*&lt;/span&gt;"&lt;span style="COLOR: blue"&gt;&amp;gt;
        &lt;/span&gt;&amp;gt;
        &lt;span style="COLOR: blue"&gt;&amp;lt;&lt;/span&gt;&lt;span style="COLOR: #a31515"&gt;domain &lt;/span&gt;&lt;span style="COLOR: red"&gt;uri&lt;/span&gt;&lt;span style="COLOR: blue"&gt;=&lt;/span&gt;"&lt;span style="COLOR: blue"&gt;*&lt;/span&gt;"&lt;span style="COLOR: blue"&gt;/&amp;gt;
      &amp;lt;/&lt;/span&gt;&lt;span style="COLOR: #a31515"&gt;allow-from&lt;/span&gt;&lt;span style="COLOR: blue"&gt;&amp;gt;
      &amp;lt;&lt;/span&gt;&lt;span style="COLOR: #a31515"&gt;grant-to&lt;/span&gt;&lt;span style="COLOR: blue"&gt;&amp;gt;
        &amp;lt;&lt;/span&gt;&lt;span style="COLOR: #a31515"&gt;resource &lt;/span&gt;&lt;span style="COLOR: red"&gt;path&lt;/span&gt;&lt;span style="COLOR: blue"&gt;=&lt;/span&gt;"&lt;span style="COLOR: blue"&gt;/&lt;/span&gt;" &lt;span style="COLOR: red"&gt;include-subpaths&lt;/span&gt;&lt;span style="COLOR: blue"&gt;=&lt;/span&gt;"&lt;span style="COLOR: blue"&gt;true&lt;/span&gt;"&lt;span style="COLOR: blue"&gt;/&amp;gt;
      &amp;lt;/&lt;/span&gt;&lt;span style="COLOR: #a31515"&gt;grant-to&lt;/span&gt;&lt;span style="COLOR: blue"&gt;&amp;gt;
    &amp;lt;/&lt;/span&gt;&lt;span style="COLOR: #a31515"&gt;policy&lt;/span&gt;&lt;span style="COLOR: blue"&gt;&amp;gt;
  &amp;lt;/&lt;/span&gt;&lt;span style="COLOR: #a31515"&gt;cross-domain-access&lt;/span&gt;&lt;span style="COLOR: blue"&gt;&amp;gt;
&amp;lt;/&lt;/span&gt;&lt;span style="COLOR: #a31515"&gt;access-policy&lt;/span&gt;&lt;span style="COLOR: blue"&gt;&amp;gt;&lt;/span&gt;&lt;/pre&gt;
&lt;p&gt;&lt;a href="http://11011.net/software/vspaste"&gt;&lt;/a&gt;And there we have it. The Silverlight project is now ready for us to code whatever magic we may wish – which will have to wait till the next part – I’m just about to relax and watch the CSI episode set in a Science Fiction convention!&lt;/p&gt;&lt;p&gt;&lt;a href="http://www.pheedo.com/click.phdo?x=6cda6ad746d942b9a1110d0715a4fa12&amp;u=132432"&gt;&lt;img src="http://www.pheedo.com/img.phdo?x=6cda6ad746d942b9a1110d0715a4fa12&amp;u=132432" border="0"/&gt;&lt;/a&gt;&lt;/p&gt;&lt;iframe src="http://ads.geekswithblogs.net/a.aspx?ZoneID=5&amp;amp;Task=Get&amp;amp;PageID=31016&amp;amp;SiteID=1" width=1 height=1 Marginwidth=0 Marginheight=0 Hspace=0 Vspace=0 Frameborder=0 Scrolling=No&gt;
&lt;script language='javascript1.1' src="http://ads.geekswithblogs.net/a.aspx?ZoneID=5&amp;amp;Task=Get&amp;amp;Browser=NETSCAPE4&amp;amp;NoCache=True&amp;PageID=31016&amp;amp;SiteID=1"&gt;&lt;/script&gt;
&lt;noscript&gt;&lt;a href="http://ads.geekswithblogs.net/a.aspx?ZoneID=5&amp;amp;Task=Click&amp;amp;Mode=HTML&amp;amp;SiteID=1&amp;amp;PageID=31016" target="_blank"&gt;
&lt;img src="http://ads.geekswithblogs.net/a.aspx?ZoneID=5&amp;amp;Task=Get&amp;amp;Mode=HTML&amp;amp;SiteID=1&amp;amp;PageID=31016" width="1" height="1" border="0"  alt=""&gt;&lt;/a&gt;
&lt;/noscript&gt;
&lt;/iframe&gt;
&lt;img src="http://geekswithblogs.net/paulschapman/aggbug/132432.aspx" width="1" height="1" /&gt;</description>
            <dc:creator>paulschapman</dc:creator>
            <guid>http://geekswithblogs.net/paulschapman/archive/2009/05/26/windows-azure-tds-wcf-silverlight-and-a-few-problems-on-and-again.aspx</guid>
            <pubDate>Wed, 27 May 2009 03:08:59 GMT</pubDate>
            <wfw:comment>http://geekswithblogs.net/paulschapman/comments/132432.aspx</wfw:comment>
            <comments>http://geekswithblogs.net/paulschapman/archive/2009/05/26/windows-azure-tds-wcf-silverlight-and-a-few-problems-on-and-again.aspx#feedback</comments>
            <slash:comments>5</slash:comments>
            <wfw:commentRss>http://geekswithblogs.net/paulschapman/comments/commentRss/132432.aspx</wfw:commentRss>
            <trackback:ping>http://geekswithblogs.net/paulschapman/services/trackbacks/132432.aspx</trackback:ping>
        </item>
        <item>
            <title>Windows Azure, TDS, WCF, Silverlight and a few problems on the way Part III &amp;ndash; The Azure Project, and creating our Web service.</title>
            <link>http://geekswithblogs.net/paulschapman/archive/2009/05/14/windows-azure-tds-wcf-silverlight-and-a-few-problems-on-yet-again.aspx</link>
            <description>&lt;p&gt;So far Parts I &amp;amp; II have not given us anything new – the code will work happily in an ASP.Net or a traditional client application. Now we get to a more interesting bit – creating our Azure Project.&lt;/p&gt;
&lt;p&gt;Before we can create an Azure Project you will eventually have to go to the Azure Website – and download the Azure tools from here; &lt;a href="http://www.microsoft.com/azure/windowsazurefordevelopers/default.aspx"&gt;http://www.microsoft.com/azure/windowsazurefordevelopers/default.aspx&lt;/a&gt;.&lt;/p&gt;
&lt;p&gt;Once you have installed these on your development PC you can now create an Azure Project. You will notice that I have not suggested signing up even for a CTP account. The reason is that you can do your development locally – the Azure tools create a kind of mini-Azure on your development PC. This makes little difference now, but when the service is charged for it will make a difference.&lt;/p&gt;
&lt;p&gt;To create an Azure Project, look under your chosen language (C# or VB.Net) and select the ‘Cloud Service’ leaf. Then choose the required template. Normally I have picked the ‘Web And Worker Cloud Service’ – this is because I invariably need both a web and worker role. Indeed this project, we will have both. Below&lt;/p&gt;
&lt;p&gt;&lt;a href="http://geekswithblogs.net/images/geekswithblogs_net/paulschapman/WindowsLiveWriter/WindowsAzureTDSWCFSilverlightandafewpro_147AC/image_2.png"&gt;&lt;img style="BORDER-BOTTOM: 0px; BORDER-LEFT: 0px; DISPLAY: block; FLOAT: none; MARGIN-LEFT: auto; BORDER-TOP: 0px; MARGIN-RIGHT: auto; BORDER-RIGHT: 0px" title="image" border="0" alt="image" width="244" height="165" src="http://geekswithblogs.net/images/geekswithblogs_net/paulschapman/WindowsLiveWriter/WindowsAzureTDSWCFSilverlightandafewpro_147AC/image_thumb.png" /&gt;&lt;/a&gt; &lt;/p&gt;
&lt;p&gt;And that is it. We now have an Azure Project, that can be run locally to test it.&lt;/p&gt;
&lt;h1&gt;The Web service.&lt;/h1&gt;
&lt;p&gt;Now the Azure project will eventually have a Silverlight frontend and that creates a small problem. Silverlight is designed to be a lightweight download and for this reason it uses a subset of the full .Net runtime. This means that many of the functions that one might take for granted. To allow us the use of the full .Net runtime these are placed behind a WCF web service. &lt;/p&gt;
&lt;p&gt;To create a web service you can host it within your Web role. So right-click on the Web role project and select ‘Add’, then ‘New item’&lt;/p&gt;
&lt;p align="center"&gt;&lt;a href="http://geekswithblogs.net/images/geekswithblogs_net/paulschapman/WindowsLiveWriter/WindowsAzureTDSWCFSilverlightandafewpro_147AC/image_4.png"&gt;&lt;img style="BORDER-BOTTOM: 0px; BORDER-LEFT: 0px; DISPLAY: inline; BORDER-TOP: 0px; BORDER-RIGHT: 0px" title="image" border="0" alt="image" width="244" height="148" src="http://geekswithblogs.net/images/geekswithblogs_net/paulschapman/WindowsLiveWriter/WindowsAzureTDSWCFSilverlightandafewpro_147AC/image_thumb_1.png" /&gt;&lt;/a&gt;&lt;/p&gt;
&lt;p&gt; &lt;/p&gt;
&lt;p&gt;This will display the above window – select the WCF Service, and give it name then click on the ‘Add’ button. &lt;/p&gt;
&lt;p&gt;This creates your Web Service, but we are not finished. Silverlight requires that a Web Service use basic binding. So change the binding of the service double click on the Web.config of the Web Role. Finding the &amp;lt;services&amp;gt; tag. Make sure the ‘binding’ attribute is changed to basicHttpBinding. The following code shows what the section  should look like;&lt;/p&gt;
&lt;pre class="code"&gt;    &lt;span style="COLOR: blue"&gt;&amp;lt;&lt;/span&gt;&lt;span style="COLOR: #a31515"&gt;service &lt;/span&gt;&lt;span style="COLOR: red"&gt;behaviorConfiguration&lt;/span&gt;&lt;span style="COLOR: blue"&gt;=&lt;/span&gt;"&lt;span style="COLOR: blue"&gt;NewsMashup_WebRole.NewsMashupServiceBehavior&lt;/span&gt;"
        &lt;span style="COLOR: red"&gt;name&lt;/span&gt;&lt;span style="COLOR: blue"&gt;=&lt;/span&gt;"&lt;span style="COLOR: blue"&gt;NewsMashup_WebRole.NewsMashupService&lt;/span&gt;"&lt;span style="COLOR: blue"&gt;&amp;gt;
        &amp;lt;&lt;/span&gt;&lt;span style="COLOR: #a31515"&gt;endpoint &lt;/span&gt;&lt;span style="COLOR: red"&gt;address&lt;/span&gt;&lt;span style="COLOR: blue"&gt;=&lt;/span&gt;"" &lt;strong&gt;&lt;span style="COLOR: red"&gt;binding&lt;/span&gt;&lt;span style="COLOR: blue"&gt;=&lt;/span&gt;"&lt;span style="COLOR: blue"&gt;basicHttpBinding&lt;/span&gt;"&lt;/strong&gt; &lt;span style="COLOR: red"&gt;contract&lt;/span&gt;&lt;span style="COLOR: blue"&gt;=&lt;/span&gt;"&lt;span style="COLOR: blue"&gt;NewsMashup_WebRole.INewsMashupService&lt;/span&gt;"&lt;span style="COLOR: blue"&gt;&amp;gt;
            &amp;lt;&lt;/span&gt;&lt;span style="COLOR: #a31515"&gt;identity&lt;/span&gt;&lt;span style="COLOR: blue"&gt;&amp;gt;
                &amp;lt;&lt;/span&gt;&lt;span style="COLOR: #a31515"&gt;dns &lt;/span&gt;&lt;span style="COLOR: red"&gt;value&lt;/span&gt;&lt;span style="COLOR: blue"&gt;=&lt;/span&gt;"&lt;span style="COLOR: blue"&gt;localhost&lt;/span&gt;" &lt;span style="COLOR: blue"&gt;/&amp;gt;
            &amp;lt;/&lt;/span&gt;&lt;span style="COLOR: #a31515"&gt;identity&lt;/span&gt;&lt;span style="COLOR: blue"&gt;&amp;gt;
        &amp;lt;/&lt;/span&gt;&lt;span style="COLOR: #a31515"&gt;endpoint&lt;/span&gt;&lt;span style="COLOR: blue"&gt;&amp;gt;
        &amp;lt;&lt;/span&gt;&lt;span style="COLOR: #a31515"&gt;endpoint &lt;/span&gt;&lt;span style="COLOR: red"&gt;address&lt;/span&gt;&lt;span style="COLOR: blue"&gt;=&lt;/span&gt;"&lt;span style="COLOR: blue"&gt;mex&lt;/span&gt;" &lt;span style="COLOR: red"&gt;binding&lt;/span&gt;&lt;span style="COLOR: blue"&gt;=&lt;/span&gt;"&lt;span style="COLOR: blue"&gt;mexHttpBinding&lt;/span&gt;" &lt;span style="COLOR: red"&gt;contract&lt;/span&gt;&lt;span style="COLOR: blue"&gt;=&lt;/span&gt;"&lt;span style="COLOR: blue"&gt;IMetadataExchange&lt;/span&gt;" &lt;span style="COLOR: blue"&gt;/&amp;gt;
    &amp;lt;/&lt;/span&gt;&lt;span style="COLOR: #a31515"&gt;service&lt;/span&gt;&lt;span style="COLOR: blue"&gt;&amp;gt;
&amp;lt;/&lt;/span&gt;&lt;span style="COLOR: #a31515"&gt;services&lt;/span&gt;&lt;span style="COLOR: blue"&gt;&amp;gt;&lt;/span&gt;&lt;/pre&gt;
&lt;a href="http://11011.net/software/vspaste"&gt;&lt;/a&gt;
&lt;p&gt; &lt;/p&gt;
&lt;p&gt;So this sets up our Azure project, and our web service. &lt;/p&gt;&lt;p&gt;&lt;a href="http://www.pheedo.com/click.phdo?x=6cda6ad746d942b9a1110d0715a4fa12&amp;u=132118"&gt;&lt;img src="http://www.pheedo.com/img.phdo?x=6cda6ad746d942b9a1110d0715a4fa12&amp;u=132118" border="0"/&gt;&lt;/a&gt;&lt;/p&gt;&lt;iframe src="http://ads.geekswithblogs.net/a.aspx?ZoneID=5&amp;amp;Task=Get&amp;amp;PageID=31016&amp;amp;SiteID=1" width=1 height=1 Marginwidth=0 Marginheight=0 Hspace=0 Vspace=0 Frameborder=0 Scrolling=No&gt;
&lt;script language='javascript1.1' src="http://ads.geekswithblogs.net/a.aspx?ZoneID=5&amp;amp;Task=Get&amp;amp;Browser=NETSCAPE4&amp;amp;NoCache=True&amp;PageID=31016&amp;amp;SiteID=1"&gt;&lt;/script&gt;
&lt;noscript&gt;&lt;a href="http://ads.geekswithblogs.net/a.aspx?ZoneID=5&amp;amp;Task=Click&amp;amp;Mode=HTML&amp;amp;SiteID=1&amp;amp;PageID=31016" target="_blank"&gt;
&lt;img src="http://ads.geekswithblogs.net/a.aspx?ZoneID=5&amp;amp;Task=Get&amp;amp;Mode=HTML&amp;amp;SiteID=1&amp;amp;PageID=31016" width="1" height="1" border="0"  alt=""&gt;&lt;/a&gt;
&lt;/noscript&gt;
&lt;/iframe&gt;
&lt;img src="http://geekswithblogs.net/paulschapman/aggbug/132118.aspx" width="1" height="1" /&gt;</description>
            <dc:creator>paulschapman</dc:creator>
            <guid>http://geekswithblogs.net/paulschapman/archive/2009/05/14/windows-azure-tds-wcf-silverlight-and-a-few-problems-on-yet-again.aspx</guid>
            <pubDate>Fri, 15 May 2009 04:18:16 GMT</pubDate>
            <wfw:comment>http://geekswithblogs.net/paulschapman/comments/132118.aspx</wfw:comment>
            <comments>http://geekswithblogs.net/paulschapman/archive/2009/05/14/windows-azure-tds-wcf-silverlight-and-a-few-problems-on-yet-again.aspx#feedback</comments>
            <wfw:commentRss>http://geekswithblogs.net/paulschapman/comments/commentRss/132118.aspx</wfw:commentRss>
            <trackback:ping>http://geekswithblogs.net/paulschapman/services/trackbacks/132118.aspx</trackback:ping>
        </item>
        <item>
            <title>Windows Azure, TDS, WCF, Silverlight and a few problems on the way Part II &amp;ndash; Database access layer</title>
            <link>http://geekswithblogs.net/paulschapman/archive/2009/05/13/windows-azure-tds-wcf-silverlight-and-a-few-problems-on-again.aspx</link>
            <description>&lt;div style="PADDING-BOTTOM: 0px; MARGIN: 0px; PADDING-LEFT: 0px; PADDING-RIGHT: 0px; DISPLAY: inline; FLOAT: none; PADDING-TOP: 0px" id="scid:fb3a1972-4489-4e52-abe7-25a00bb07fdf:23ffb774-c08e-4f72-a287-98bdc5a66866" class="wlWriterEditableSmartContent"&gt;
&lt;p&gt;Project Sourcecode: &lt;a target="_blank" href="http://geekswithblogs.net/images/geekswithblogs_net/paulschapman/WindowsLiveWriter/WindowsAzureTDSWCFSilverlightandafewprob_13ABB/NewsMashup.zip"&gt;NewsMashup&lt;/a&gt;&lt;/p&gt;
&lt;/div&gt;
&lt;p&gt;In Part I of this series of articles I discussed the database that lies behind the application. Moving from the backend to the client side, it is now time to discuss the code which accesses the database and returns the data to application.&lt;/p&gt;
&lt;p&gt;I have a standard class I use when accessing databases. The version I am using here is developed to connect to SQL Server but with some minor changes it would not be difficult to adapt to other databases, and I already have one for ODBC.&lt;/p&gt;
&lt;pre class="code"&gt;&lt;span style="COLOR: blue"&gt;public &lt;/span&gt;Database(&lt;span style="COLOR: blue"&gt;string &lt;/span&gt;Connection)
{
    connection = &lt;span style="COLOR: blue"&gt;new &lt;/span&gt;&lt;span style="COLOR: #2b91af"&gt;SqlConnection&lt;/span&gt;(Connection);
    InitialiseCommand();
}

&lt;span style="COLOR: blue"&gt;public &lt;/span&gt;Database(&lt;span style="COLOR: #2b91af"&gt;SqlConnection &lt;/span&gt;Connection)
{
    connection = Connection;
    InitialiseCommand();
}

&lt;span style="COLOR: blue"&gt;public &lt;/span&gt;Database()
{
    connection = &lt;span style="COLOR: blue"&gt;new &lt;/span&gt;&lt;span style="COLOR: #2b91af"&gt;SqlConnection&lt;/span&gt;();
    InitialiseCommand();

}&lt;/pre&gt;
&lt;a href="http://11011.net/software/vspaste"&gt;&lt;/a&gt;
&lt;pre class="prettyprint"&gt; &lt;/pre&gt;
&lt;p&gt;The above code shows the constructor for the data access layer. Essentially the constructor expects either a connection, connection string or nothing to be passed to the constructor. Each calls another function; InitialiseCommand() which sets up the command object and is below.&lt;/p&gt;
&lt;pre class="code"&gt;&lt;span style="COLOR: blue"&gt;private void &lt;/span&gt;InitialiseCommand()
{
    &lt;span style="COLOR: blue"&gt;try
    &lt;/span&gt;{
        &lt;span style="COLOR: blue"&gt;if &lt;/span&gt;(dbCommand == &lt;span style="COLOR: blue"&gt;null&lt;/span&gt;)
        {
            dbCommand             = &lt;span style="COLOR: blue"&gt;new &lt;/span&gt;&lt;span style="COLOR: #2b91af"&gt;SqlCommand&lt;/span&gt;();
            dbCommand.CommandType = &lt;span style="COLOR: #2b91af"&gt;CommandType&lt;/span&gt;.StoredProcedure;  &lt;span style="COLOR: green"&gt;// default to Stored Prc

            &lt;/span&gt;&lt;span style="COLOR: blue"&gt;if &lt;/span&gt;(connection != &lt;span style="COLOR: blue"&gt;null&lt;/span&gt;)
            {
                dbCommand.Connection = connection;
            }
        }
    }
    &lt;span style="COLOR: blue"&gt;catch &lt;/span&gt;(System.&lt;span style="COLOR: #2b91af"&gt;Exception &lt;/span&gt;ex)
    {
        &lt;span style="COLOR: blue"&gt;throw &lt;/span&gt;ex;
    }
}&lt;/pre&gt;
&lt;a href="http://11011.net/software/vspaste"&gt;&lt;/a&gt;
&lt;p&gt; &lt;/p&gt;
&lt;p&gt;This initialises the Command object and sets the type to Stored Procedure, if the Connection object has been initialised the command objects connection is set to the connection object.&lt;/p&gt;
&lt;p&gt;To execute stored procedures we need two. One to return a datatable, and one which does not&lt;/p&gt;
&lt;pre class="code"&gt;    &lt;span style="COLOR: blue"&gt;public void &lt;/span&gt;Execute()
    {
        &lt;span style="COLOR: blue"&gt;try
        &lt;/span&gt;{
            &lt;span style="COLOR: blue"&gt;if &lt;/span&gt;(dbCommand.Connection.State != &lt;span style="COLOR: #2b91af"&gt;ConnectionState&lt;/span&gt;.Open) dbCommand.Connection.Open();
            dbCommand.ExecuteNonQuery();
        }
        &lt;span style="COLOR: blue"&gt;catch &lt;/span&gt;(System.&lt;span style="COLOR: #2b91af"&gt;Exception &lt;/span&gt;ex)
        {
            &lt;span style="COLOR: blue"&gt;throw &lt;/span&gt;ex;
        }
    }

    &lt;span style="COLOR: blue"&gt;public &lt;/span&gt;&lt;span style="COLOR: #2b91af"&gt;DataTable &lt;/span&gt;Execute(&lt;span style="COLOR: blue"&gt;string &lt;/span&gt;TableName)
    {
        &lt;span style="COLOR: #2b91af"&gt;SqlDataAdapter  &lt;/span&gt;da;
        &lt;span style="COLOR: #2b91af"&gt;DataSet         &lt;/span&gt;ds;
        &lt;span style="COLOR: #2b91af"&gt;DataTable       &lt;/span&gt;dt = &lt;span style="COLOR: blue"&gt;new &lt;/span&gt;&lt;span style="COLOR: #2b91af"&gt;DataTable&lt;/span&gt;();

        &lt;span style="COLOR: blue"&gt;try
        &lt;/span&gt;{
            da = &lt;span style="COLOR: blue"&gt;new &lt;/span&gt;&lt;span style="COLOR: #2b91af"&gt;SqlDataAdapter&lt;/span&gt;(dbCommand);
            ds = &lt;span style="COLOR: blue"&gt;new &lt;/span&gt;&lt;span style="COLOR: #2b91af"&gt;DataSet&lt;/span&gt;();
            da.Fill(ds,TableName);

            &lt;span style="COLOR: blue"&gt;if &lt;/span&gt;(ds.Tables.Count &amp;gt; 0)
                dt = ds.Tables[0];
        }
        &lt;span style="COLOR: blue"&gt;catch &lt;/span&gt;(System.&lt;span style="COLOR: #2b91af"&gt;Exception &lt;/span&gt;ex)
        {
            &lt;span style="COLOR: blue"&gt;throw &lt;/span&gt;ex;
        }

        &lt;span style="COLOR: blue"&gt;return &lt;/span&gt;dt;
    }
}&lt;/pre&gt;
&lt;a href="http://11011.net/software/vspaste"&gt;&lt;/a&gt;
&lt;p&gt; &lt;/p&gt;
&lt;p&gt; &lt;/p&gt;
&lt;p&gt;The first of these two methods is fairly simple. Essentially what it does is confirm the connection is open, if not the connection is opened. Then it executes the stored procedure. The whole lot is then wrapped in a try catch, which is thrown back to the calling application. &lt;/p&gt;
&lt;p&gt;The second is more interesting. It uses a Data Adapter and Dataset to fill a table returned back to the calling programme.&lt;/p&gt;
&lt;p&gt;These two methods cover all the various types of database action I might want to undertake. &lt;/p&gt;
&lt;p&gt;The real magic here however is in the objects which inherit from this class. &lt;/p&gt;
&lt;pre class="code"&gt;&lt;span style="COLOR: blue"&gt;public class &lt;/span&gt;&lt;span style="COLOR: #2b91af"&gt;NewsMashupDB &lt;/span&gt;: &lt;span style="COLOR: #2b91af"&gt;Database&lt;/span&gt;,&lt;span style="COLOR: #2b91af"&gt;IDisposable&lt;/span&gt;&lt;/pre&gt;
&lt;p&gt;The class inherits from the class defined in the code above. The constructor for the object is as follows;&lt;/p&gt;
&lt;pre class="code"&gt;&lt;span style="COLOR: blue"&gt;public &lt;/span&gt;NewsMashupDB() 
    : &lt;span style="COLOR: blue"&gt;base&lt;/span&gt;()
{
    
}

&lt;span style="COLOR: blue"&gt;public &lt;/span&gt;NewsMashupDB(&lt;span style="COLOR: blue"&gt;string &lt;/span&gt;ConnectionString) 
    : &lt;span style="COLOR: blue"&gt;base&lt;/span&gt;(ConnectionString)
{

}&lt;/pre&gt;
&lt;p&gt;Thats it. There is two here – one initialises the connection string, the other does not. All the calling application need do is retrieve the connection string. Executing a stored procedure is equally simple. Here we have the stored procedure which executes the CreateStory stored procedure;&lt;/p&gt;
&lt;pre class="code"&gt;&lt;span style="COLOR: blue"&gt;public void &lt;/span&gt;CreateStory(&lt;span style="COLOR: blue"&gt;string &lt;/span&gt;Headline, &lt;span style="COLOR: blue"&gt;string &lt;/span&gt;Description, &lt;span style="COLOR: blue"&gt;string &lt;/span&gt;Url, &lt;span style="COLOR: blue"&gt;string &lt;/span&gt;Supplier, &lt;span style="COLOR: blue"&gt;long &lt;/span&gt;PubDateValue)
{
    &lt;span style="COLOR: #2b91af"&gt;SqlParameter &lt;/span&gt;paramHeadline      = &lt;span style="COLOR: blue"&gt;new &lt;/span&gt;&lt;span style="COLOR: #2b91af"&gt;SqlParameter&lt;/span&gt;(&lt;span style="COLOR: #a31515"&gt;"Headline"&lt;/span&gt;, &lt;span style="COLOR: #2b91af"&gt;SqlDbType&lt;/span&gt;.VarChar);
    &lt;span style="COLOR: #2b91af"&gt;SqlParameter &lt;/span&gt;paramDescription   = &lt;span style="COLOR: blue"&gt;new &lt;/span&gt;&lt;span style="COLOR: #2b91af"&gt;SqlParameter&lt;/span&gt;(&lt;span style="COLOR: #a31515"&gt;"Description"&lt;/span&gt;,&lt;span style="COLOR: #2b91af"&gt;SqlDbType&lt;/span&gt;.VarChar);
    &lt;span style="COLOR: #2b91af"&gt;SqlParameter &lt;/span&gt;paramUrl           = &lt;span style="COLOR: blue"&gt;new &lt;/span&gt;&lt;span style="COLOR: #2b91af"&gt;SqlParameter&lt;/span&gt;(&lt;span style="COLOR: #a31515"&gt;"Url"&lt;/span&gt;,&lt;span style="COLOR: #2b91af"&gt;SqlDbType&lt;/span&gt;.VarChar);
    &lt;span style="COLOR: #2b91af"&gt;SqlParameter &lt;/span&gt;paramSupplier      = &lt;span style="COLOR: blue"&gt;new &lt;/span&gt;&lt;span style="COLOR: #2b91af"&gt;SqlParameter&lt;/span&gt;(&lt;span style="COLOR: #a31515"&gt;"Supplier"&lt;/span&gt;, &lt;span style="COLOR: #2b91af"&gt;SqlDbType&lt;/span&gt;.VarChar);
    &lt;span style="COLOR: #2b91af"&gt;SqlParameter &lt;/span&gt;paramPubDate       = &lt;span style="COLOR: blue"&gt;new &lt;/span&gt;&lt;span style="COLOR: #2b91af"&gt;SqlParameter&lt;/span&gt;(&lt;span style="COLOR: #a31515"&gt;"PubDateValue"&lt;/span&gt;, &lt;span style="COLOR: #2b91af"&gt;SqlDbType&lt;/span&gt;.BigInt);

    CommandText = &lt;span style="COLOR: #a31515"&gt;"NewsMashup.CreateStory"&lt;/span&gt;;

    &lt;span style="COLOR: blue"&gt;try
    &lt;/span&gt;{

        paramHeadline.Value = Headline;
        paramDescription.Value = Description;
        paramUrl.Value = Url;
        paramSupplier.Value = Supplier;
        paramPubDate.Value = PubDateValue;

        dbCommand.Parameters.Clear();

        dbCommand.Parameters.Add(paramHeadline);
        dbCommand.Parameters.Add(paramDescription);
        dbCommand.Parameters.Add(paramUrl);
        dbCommand.Parameters.Add(paramSupplier);
        dbCommand.Parameters.Add(paramPubDate);

        Execute();
    }
    &lt;span style="COLOR: blue"&gt;catch &lt;/span&gt;(System.&lt;span style="COLOR: #2b91af"&gt;Exception &lt;/span&gt;ex)
    {
        &lt;span style="COLOR: blue"&gt;throw &lt;/span&gt;ex;
    }
}&lt;/pre&gt;
&lt;p&gt;Except for the code setting up the parameters required the execution of the stored procedure takes two lines; one to initialise the command text, the other to execute the stored procedure. &lt;/p&gt;
&lt;p&gt;A stored procedure which returns data is equally simple.&lt;/p&gt;
&lt;pre class="code"&gt;&lt;span style="COLOR: blue"&gt;public &lt;/span&gt;&lt;span style="COLOR: #2b91af"&gt;DataTable &lt;/span&gt;RetrieveNewsFeeds()
{
    &lt;span style="COLOR: #2b91af"&gt;DataTable &lt;/span&gt;dt = &lt;span style="COLOR: blue"&gt;new &lt;/span&gt;&lt;span style="COLOR: #2b91af"&gt;DataTable&lt;/span&gt;();

    &lt;span style="COLOR: blue"&gt;try
    &lt;/span&gt;{
        CommandText = &lt;span style="COLOR: #a31515"&gt;"NewsMashup.RetrieveNewsFeeds"&lt;/span&gt;;

        dt = Execute(&lt;span style="COLOR: #a31515"&gt;"NewsFeeds"&lt;/span&gt;);

    }
    &lt;span style="COLOR: blue"&gt;catch &lt;/span&gt;(System.&lt;span style="COLOR: #2b91af"&gt;Exception &lt;/span&gt;ex)
    {
        &lt;span style="COLOR: blue"&gt;throw &lt;/span&gt;ex;
    }

    &lt;span style="COLOR: blue"&gt;return &lt;/span&gt;dt;
}&lt;/pre&gt;
&lt;p&gt;It is clearer here than in the other method, again only two lines of code; one to initialise the CommandText the other to execute the stored procedure. This version of the Execute returns the datatable containing the results of the stored procedure’s execution.&lt;/p&gt;
&lt;p&gt;This shows examples of the code. The rest should be in the attached zip file&lt;/p&gt;&lt;p&gt;&lt;a href="http://www.pheedo.com/click.phdo?x=6cda6ad746d942b9a1110d0715a4fa12&amp;u=132093"&gt;&lt;img src="http://www.pheedo.com/img.phdo?x=6cda6ad746d942b9a1110d0715a4fa12&amp;u=132093" border="0"/&gt;&lt;/a&gt;&lt;/p&gt;&lt;iframe src="http://ads.geekswithblogs.net/a.aspx?ZoneID=5&amp;amp;Task=Get&amp;amp;PageID=31016&amp;amp;SiteID=1" width=1 height=1 Marginwidth=0 Marginheight=0 Hspace=0 Vspace=0 Frameborder=0 Scrolling=No&gt;
&lt;script language='javascript1.1' src="http://ads.geekswithblogs.net/a.aspx?ZoneID=5&amp;amp;Task=Get&amp;amp;Browser=NETSCAPE4&amp;amp;NoCache=True&amp;PageID=31016&amp;amp;SiteID=1"&gt;&lt;/script&gt;
&lt;noscript&gt;&lt;a href="http://ads.geekswithblogs.net/a.aspx?ZoneID=5&amp;amp;Task=Click&amp;amp;Mode=HTML&amp;amp;SiteID=1&amp;amp;PageID=31016" target="_blank"&gt;
&lt;img src="http://ads.geekswithblogs.net/a.aspx?ZoneID=5&amp;amp;Task=Get&amp;amp;Mode=HTML&amp;amp;SiteID=1&amp;amp;PageID=31016" width="1" height="1" border="0"  alt=""&gt;&lt;/a&gt;
&lt;/noscript&gt;
&lt;/iframe&gt;
&lt;img src="http://geekswithblogs.net/paulschapman/aggbug/132093.aspx" width="1" height="1" /&gt;</description>
            <dc:creator>paulschapman</dc:creator>
            <guid>http://geekswithblogs.net/paulschapman/archive/2009/05/13/windows-azure-tds-wcf-silverlight-and-a-few-problems-on-again.aspx</guid>
            <pubDate>Thu, 14 May 2009 03:23:21 GMT</pubDate>
            <wfw:comment>http://geekswithblogs.net/paulschapman/comments/132093.aspx</wfw:comment>
            <comments>http://geekswithblogs.net/paulschapman/archive/2009/05/13/windows-azure-tds-wcf-silverlight-and-a-few-problems-on-again.aspx#feedback</comments>
            <wfw:commentRss>http://geekswithblogs.net/paulschapman/comments/commentRss/132093.aspx</wfw:commentRss>
            <trackback:ping>http://geekswithblogs.net/paulschapman/services/trackbacks/132093.aspx</trackback:ping>
        </item>
        <item>
            <title>Getting WCF to work with Azure</title>
            <link>http://geekswithblogs.net/paulschapman/archive/2009/01/07/getting-wcf-to-work-with-azure.aspx</link>
            <description>&lt;p&gt;Silverlight makes creating compelling Rich Internet Applications fairly easy. That said the cut down version of .Net means some things that you would do within an application have to be relegated to Web Services which can benefit from the full .Net library. One of these is of course Azure, after all that is the whole point - an online store of Business Logic and data.&lt;/p&gt;
&lt;p&gt;The application I'm working on uses Silverlight on the front end, and Azure will provide the bulk of the backend. There are reasons for this; my budget for the site is not that large, adopting Azure means first off that it will be free during development, but almost as important - hosting costs will be related to the success of the site. &lt;/p&gt;
&lt;p&gt;Thing is dealing with pre-beta software has meant an increase in grey hairs and those that are left are getting fewer. One of the parts that needs looking at is in WCF. If you run the Azure Labs the WCF lab does not work. This is because the Development Fabric is not hosting the service correctly, and WCF metadata is not being returned correctly.&lt;/p&gt;
&lt;p&gt;Thanks must go to David Burela and his &lt;a target="_blank" href="http://davidburela.wordpress.com/"&gt;&lt;font color="#800080"&gt;House-o-blog&lt;/font&gt;&lt;/a&gt;. In it he describes a way to get WCF working despite the problems with the Development Fabric. So what I thought I would do is write a version of the Azure Services Training Kits Exercise 3: Hosting a WCF Service&lt;/p&gt;
&lt;p&gt;So the following is Exercise 3, but with the changes made to ensure it works&lt;/p&gt;
&lt;p&gt;1. Open the project you created in Exercise 2 or open the &lt;strong&gt;begin.sln&lt;/strong&gt; solution file located in &lt;strong&gt;C:\AzureServicesKit\Labs\BuildingWindowsAzureServices\Ex03-HostingWCFService\begin\&lt;/strong&gt;.&lt;/p&gt;
&lt;blockquote&gt;
&lt;p&gt;&lt;strong&gt;Note&lt;/strong&gt;:&lt;/p&gt;
&lt;p&gt;If you closed Visual Studio, be sure to open it elevated as &lt;strong&gt;Administrator&lt;/strong&gt;, from &lt;strong&gt;Start | All Programs | Microsoft Visual Studio 2008 right-click Microsoft Visual Studio 2008&lt;/strong&gt; and choose &lt;strong&gt;Run as Administrator&lt;/strong&gt;.&lt;/p&gt;
&lt;/blockquote&gt;
&lt;p&gt;2. Add the WCF service file. To do this, right-click the &lt;strong&gt;RDCompute_WebRole&lt;/strong&gt; node in &lt;strong&gt;Solution Explorer&lt;/strong&gt;, point to &lt;strong&gt;Add&lt;/strong&gt; and select &lt;strong&gt;New Item&lt;/strong&gt;. In the &lt;strong&gt;Add New Item&lt;/strong&gt; dialog, select the &lt;strong&gt;WCF Service&lt;/strong&gt; template, change the Name to &lt;strong&gt;&lt;em&gt;MessageLogger.svc&lt;/em&gt;&lt;/strong&gt;, and then click &lt;strong&gt;Add&lt;/strong&gt;.&lt;/p&gt;
&lt;p&gt;&lt;a href="http://geekswithblogs.net/images/geekswithblogs_net/paulschapman/WindowsLiveWriter/GettingWCFtoworkwithAzure_1446C/image_2.png"&gt;&lt;img style="BORDER-TOP-WIDTH: 0px; BORDER-LEFT-WIDTH: 0px; BORDER-BOTTOM-WIDTH: 0px; BORDER-RIGHT-WIDTH: 0px" height="388" alt="Add New Item" width="644" border="0" src="http://geekswithblogs.net/images/geekswithblogs_net/paulschapman/WindowsLiveWriter/GettingWCFtoworkwithAzure_1446C/image_thumb.png" /&gt;&lt;/a&gt; &lt;/p&gt;
&lt;blockquote&gt;
&lt;p&gt;&lt;strong&gt;Note&lt;/strong&gt;:&lt;/p&gt;
&lt;p&gt;The template adds an &lt;strong&gt;IMessageLogger&lt;/strong&gt; interface, which defines the service contract and a &lt;strong&gt;MessageLogger&lt;/strong&gt; class that implements the contract.&lt;/p&gt;
&lt;/blockquote&gt;
&lt;p&gt;3. Update the contract interface to define a method to send messages to the service. Open the &lt;strong&gt;&lt;em&gt;IMessageLogger.cs&lt;/em&gt;&lt;/strong&gt; file in the text editor. This file contains the generated &lt;strong&gt;IMessageLogger&lt;/strong&gt; interface, which includes a single method named &lt;strong&gt;DoWork&lt;/strong&gt;. Delete this method, and insert a &lt;strong&gt;LogMessage&lt;/strong&gt; method to replace it (shown highlighted in bold text below.) &lt;/p&gt;
&lt;p&gt;&lt;font face="Courier New" size="2"&gt;[ServiceContract] &lt;br /&gt;
public interface IMessageLogger &lt;br /&gt;
{ &lt;br /&gt;
  [OperationContract] &lt;br /&gt;
  &lt;strong&gt;void LogMessage(string message); &lt;br /&gt;
&lt;/strong&gt;}&lt;/font&gt;&lt;/p&gt;
&lt;p&gt;4. Implement the contract interface in the &lt;strong&gt;MessageLogger&lt;/strong&gt; service. Open the &lt;strong&gt;&lt;em&gt;MessageLogger.&lt;/em&gt;&lt;/strong&gt;&lt;strong&gt;&lt;em&gt;svc.&lt;/em&gt;&lt;/strong&gt;&lt;strong&gt;&lt;em&gt;cs&lt;/em&gt;&lt;/strong&gt; file in the text editor. This file contains the service implementation and includes a skeleton &lt;strong&gt;DoWork&lt;/strong&gt; method. Again, delete this method and insert the following code that implements the &lt;strong&gt;LogMessage&lt;/strong&gt; method in its place. &lt;/p&gt;
&lt;p&gt;&lt;font face="Courier New" size="2"&gt;public void LogMessage(string message) &lt;br /&gt;
{ &lt;br /&gt;
     MessageHelper.SaveMessage(message); &lt;br /&gt;
} &lt;/font&gt;&lt;/p&gt;
&lt;p&gt;5. Change the binding of the &lt;strong&gt;IMessageLogger&lt;/strong&gt; endpoint to use a &lt;strong&gt;&lt;em&gt;basicHttpBinding&lt;/em&gt;&lt;/strong&gt;. Open the &lt;strong&gt;&lt;em&gt;Web.config&lt;/em&gt;&lt;/strong&gt; file in the text editor and locate the &lt;strong&gt;&lt;em&gt;RDCompute_&lt;/em&gt;&lt;/strong&gt;&lt;strong&gt;&lt;em&gt;WebRole&lt;/em&gt;&lt;/strong&gt;&lt;strong&gt;&lt;em&gt;.MessageLogger&lt;/em&gt;&lt;/strong&gt; service configuration in the &lt;strong&gt;services&lt;/strong&gt; section inside &lt;strong&gt;system.serviceModel&lt;/strong&gt;. This should be towards the end of the file. Change the &lt;strong&gt;binding&lt;/strong&gt; attribute of the single endpoint contained in this section from &lt;strong&gt;&lt;em&gt;wsHttpBinding&lt;/em&gt;&lt;/strong&gt; to &lt;strong&gt;&lt;em&gt;basicHttpBinding&lt;/em&gt;&lt;/strong&gt;. The endpoint configuration after the change should be as follows: &lt;/p&gt;
&lt;pre&gt;&amp;lt;endpoint address="" binding="basicHttpBinding" contract="RDCompute_WebRole.IMessageLogger"&amp;gt;
  &amp;lt;identity&amp;gt;
    &amp;lt;dns value="localhost" /&amp;gt;
  &amp;lt;/identity&amp;gt;
&amp;lt;/endpoint&amp;gt;&lt;/pre&gt;
&lt;pre&gt;&lt;pre&gt;&lt;font face="Trebuchet MS"&gt;&lt;/font&gt; &lt;/pre&gt;
&lt;pre&gt;&lt;font face="Trebuchet MS"&gt;6. Right click on the ASP.Net project (&lt;strong&gt;AzureWCFDemo_WebRole&lt;/strong&gt;) and set it as the startup project&lt;/font&gt;&lt;/pre&gt;
&lt;pre&gt;&lt;font face="Trebuchet MS"&gt;&lt;/font&gt; &lt;/pre&gt;
&lt;pre&gt;&lt;font face="Trebuchet MS"&gt;7. Right click on the MessageLogger.svc file and select View in Browser&lt;/font&gt;&lt;/pre&gt;
&lt;pre&gt;&lt;font face="Trebuchet MS"&gt;&lt;/font&gt; &lt;/pre&gt;
&lt;pre&gt;&lt;font face="Trebuchet MS"&gt;8. When IE starts copy the address displayed in the Address Bar to the clipboard&lt;/font&gt;&lt;/pre&gt;
&lt;pre&gt;&lt;font face="Trebuchet MS"&gt;&lt;/font&gt; &lt;/pre&gt;
&lt;pre&gt;&lt;font face="Trebuchet MS"&gt;9. Start a new instance of Visual Studio&lt;/font&gt;&lt;/pre&gt;
&lt;pre&gt;&lt;font face="Trebuchet MS"&gt;&lt;/font&gt; &lt;/pre&gt;
&lt;pre&gt;&lt;font face="Trebuchet MS"&gt;10. Create a console client project by select File, New Project&lt;/font&gt;&lt;/pre&gt;
&lt;pre&gt;&lt;font face="Trebuchet MS"&gt;&lt;/font&gt; &lt;/pre&gt;
&lt;pre&gt;&lt;font face="Trebuchet MS"&gt;&lt;/font&gt; &lt;/pre&gt;
&lt;pre&gt;&lt;font face="Trebuchet MS"&gt;&lt;a href="http://geekswithblogs.net/images/geekswithblogs_net/paulschapman/WindowsLiveWriter/GettingWCFtoworkwithAzure_1446C/image_4.png"&gt;&lt;img style="BORDER-TOP-WIDTH: 0px; BORDER-LEFT-WIDTH: 0px; BORDER-BOTTOM-WIDTH: 0px; BORDER-RIGHT-WIDTH: 0px" height="386" alt="image" width="644" border="0" src="http://geekswithblogs.net/images/geekswithblogs_net/paulschapman/WindowsLiveWriter/GettingWCFtoworkwithAzure_1446C/image_thumb_1.png" /&gt;&lt;/a&gt;&lt;/font&gt;&lt;/pre&gt;
&lt;pre&gt;&lt;font face="Trebuchet MS"&gt;&lt;/font&gt; &lt;/pre&gt;
&lt;pre&gt;&lt;font face="Trebuchet MS"&gt;11. Add a reference to the message logging service. In &lt;strong&gt;Solution Explorer&lt;/strong&gt;, right-click the &lt;strong&gt;Message&lt;/strong&gt;&lt;strong&gt;Generator&lt;/strong&gt; project node, and select &lt;strong&gt;Add Service Reference&lt;/strong&gt;. &lt;br /&gt;Paste the address you copied from the IE instance into the &lt;strong&gt;Add Service Reference&lt;/strong&gt; dialog and click Discover. Change the &lt;strong&gt;Namespace&lt;/strong&gt; to &lt;strong&gt;RDService&lt;/strong&gt; and click &lt;strong&gt;OK&lt;/strong&gt;&lt;/font&gt;&lt;/pre&gt;
&lt;pre&gt;&lt;font face="Trebuchet MS"&gt;&lt;/font&gt; &lt;/pre&gt;
&lt;pre&gt;&lt;font face="Trebuchet MS"&gt;12. Add the following code to the main function&lt;/font&gt;&lt;/pre&gt;
&lt;pre&gt;&lt;font face="Trebuchet MS"&gt;&lt;/font&gt; &lt;/pre&gt;
&lt;pre&gt;&lt;strong&gt;using (RDService.MessageLoggerClient client = new RDService.MessageLoggerClient())&lt;/strong&gt;
&lt;strong&gt;  {&lt;/strong&gt;
&lt;strong&gt;    Console.WriteLine("Enter your messages ('quit' to exit)");&lt;/strong&gt;
&lt;strong&gt;    while (true)&lt;/strong&gt;
&lt;strong&gt;    {&lt;/strong&gt;
&lt;strong&gt;      try&lt;/strong&gt;
&lt;strong&gt;      {&lt;/strong&gt;
&lt;strong&gt;        string message = Console.ReadLine();&lt;/strong&gt;
&lt;strong&gt;        if (message.Equals("quit", StringComparison.CurrentCultureIgnoreCase))&lt;/strong&gt;
&lt;strong&gt;          break;&lt;/strong&gt;
&lt;strong&gt;        client.LogMessage(message);&lt;/strong&gt;
&lt;strong&gt;      }&lt;/strong&gt;
&lt;strong&gt;      catch (Exception ex)&lt;/strong&gt;
&lt;strong&gt;      {&lt;/strong&gt;
&lt;strong&gt;           Console.WriteLine(ex.Message);&lt;/strong&gt;
&lt;strong&gt;      }&lt;/strong&gt;
&lt;strong&gt;    }&lt;/strong&gt;
&lt;strong&gt;  }&lt;/strong&gt;
&lt;/pre&gt;
&lt;pre&gt;&lt;font face="Trebuchet MS"&gt;&lt;/font&gt; &lt;/pre&gt;
&lt;pre&gt;&lt;font face="Trebuchet MS"&gt;13. Return to the instance of Visual Studio running the ASP.Net application and stop debugging the ASP.Net Application&lt;/font&gt;&lt;/pre&gt;
&lt;pre&gt;&lt;font face="Trebuchet MS"&gt;&lt;/font&gt; &lt;/pre&gt;
&lt;pre&gt;&lt;font face="Trebuchet MS"&gt;13. Right click the Azure project and set as the Start-up project, then start debugging. The Dev Fabric should start running and hosting the WCF service. &lt;br /&gt;When IE starts note the port number. More than likely this will be 81.&lt;/font&gt;&lt;/pre&gt;
&lt;pre&gt;&lt;font face="Trebuchet MS"&gt;&lt;/font&gt; &lt;/pre&gt;
&lt;pre&gt;&lt;font face="Trebuchet MS"&gt;14. Finally, go back to our client project. Open the app.config file and change the endpoint address so that is the port number found in the previous step.&lt;/font&gt;&lt;/pre&gt;
&lt;pre&gt;&lt;font face="Trebuchet MS"&gt;&lt;/font&gt; &lt;/pre&gt;
&lt;pre&gt;&lt;font face="Trebuchet MS"&gt;15. Now run the client project. It should be able to call the WCF Service hosted within the Development Fabric&lt;/font&gt;&lt;/pre&gt;
&lt;pre&gt;&lt;font face="Trebuchet MS"&gt;&lt;/font&gt; &lt;/pre&gt;
&lt;pre&gt;&lt;font face="Trebuchet MS"&gt;If everything worked you should have completed Exercise 3. Hopefully a fix to the problem will be forthcoming. Excercise 4 should be fun, since in this instance &lt;br /&gt;we will be calling the Web Service from within Azure (rather than a standard Windows Application) and so this technique may need adapting.&lt;/font&gt;&lt;/pre&gt;
&lt;/pre&gt;&lt;p&gt;&lt;a href="http://www.pheedo.com/click.phdo?x=6cda6ad746d942b9a1110d0715a4fa12&amp;u=128468"&gt;&lt;img src="http://www.pheedo.com/img.phdo?x=6cda6ad746d942b9a1110d0715a4fa12&amp;u=128468" border="0"/&gt;&lt;/a&gt;&lt;/p&gt;&lt;iframe src="http://ads.geekswithblogs.net/a.aspx?ZoneID=5&amp;amp;Task=Get&amp;amp;PageID=31016&amp;amp;SiteID=1" width=1 height=1 Marginwidth=0 Marginheight=0 Hspace=0 Vspace=0 Frameborder=0 Scrolling=No&gt;
&lt;script language='javascript1.1' src="http://ads.geekswithblogs.net/a.aspx?ZoneID=5&amp;amp;Task=Get&amp;amp;Browser=NETSCAPE4&amp;amp;NoCache=True&amp;PageID=31016&amp;amp;SiteID=1"&gt;&lt;/script&gt;
&lt;noscript&gt;&lt;a href="http://ads.geekswithblogs.net/a.aspx?ZoneID=5&amp;amp;Task=Click&amp;amp;Mode=HTML&amp;amp;SiteID=1&amp;amp;PageID=31016" target="_blank"&gt;
&lt;img src="http://ads.geekswithblogs.net/a.aspx?ZoneID=5&amp;amp;Task=Get&amp;amp;Mode=HTML&amp;amp;SiteID=1&amp;amp;PageID=31016" width="1" height="1" border="0"  alt=""&gt;&lt;/a&gt;
&lt;/noscript&gt;
&lt;/iframe&gt;
&lt;img src="http://geekswithblogs.net/paulschapman/aggbug/128468.aspx" width="1" height="1" /&gt;</description>
            <dc:creator>paulschapman</dc:creator>
            <guid>http://geekswithblogs.net/paulschapman/archive/2009/01/07/getting-wcf-to-work-with-azure.aspx</guid>
            <pubDate>Thu, 08 Jan 2009 05:04:11 GMT</pubDate>
            <wfw:comment>http://geekswithblogs.net/paulschapman/comments/128468.aspx</wfw:comment>
            <comments>http://geekswithblogs.net/paulschapman/archive/2009/01/07/getting-wcf-to-work-with-azure.aspx#feedback</comments>
            <wfw:commentRss>http://geekswithblogs.net/paulschapman/comments/commentRss/128468.aspx</wfw:commentRss>
            <trackback:ping>http://geekswithblogs.net/paulschapman/services/trackbacks/128468.aspx</trackback:ping>
        </item>
    </channel>
</rss>