<?xml version="1.0" encoding="UTF-8"?>
<?xml-stylesheet type="text/xsl" media="screen" href="/~d/styles/rss2full.xsl"?><?xml-stylesheet type="text/css" media="screen" href="http://feeds.feedburner.com/~d/styles/itemcontent.css"?><rss 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/" xmlns:geo="http://www.w3.org/2003/01/geo/wgs84_pos#" xmlns:feedburner="http://rssnamespace.org/feedburner/ext/1.0" version="2.0">

<channel>
	<title>Wade Wegner</title>
	
	<link>http://www.wadewegner.com</link>
	<description>From the whiteboard to the keyboard</description>
	<lastBuildDate>Mon, 14 May 2012 20:22:00 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.3</generator>
		<atom10:link xmlns:atom10="http://www.w3.org/2005/Atom" rel="self" type="application/rss+xml" href="http://feeds.feedburner.com/WadeWegner" /><feedburner:info uri="wadewegner" /><atom10:link xmlns:atom10="http://www.w3.org/2005/Atom" rel="hub" href="http://pubsubhubbub.appspot.com/" /><geo:lat>39.610431</geo:lat><geo:long>-104.881399</geo:long><feedburner:emailServiceId>WadeWegner</feedburner:emailServiceId><feedburner:feedburnerHostname>http://feedburner.google.com</feedburner:feedburnerHostname><feedburner:feedFlare href="http://add.my.yahoo.com/rss?url=http%3A%2F%2Ffeeds.feedburner.com%2FWadeWegner" src="http://us.i1.yimg.com/us.yimg.com/i/us/my/addtomyyahoo4.gif">Subscribe with My Yahoo!</feedburner:feedFlare><feedburner:feedFlare href="http://www.newsgator.com/ngs/subscriber/subext.aspx?url=http%3A%2F%2Ffeeds.feedburner.com%2FWadeWegner" src="http://www.newsgator.com/images/ngsub1.gif">Subscribe with NewsGator</feedburner:feedFlare><feedburner:feedFlare href="http://feeds.my.aol.com/add.jsp?url=http%3A%2F%2Ffeeds.feedburner.com%2FWadeWegner" src="http://o.aolcdn.com/favorites.my.aol.com/webmaster/ffclient/webroot/locale/en-US/images/myAOLButtonSmall.gif">Subscribe with My AOL</feedburner:feedFlare><feedburner:feedFlare href="http://www.bloglines.com/sub/http://feeds.feedburner.com/WadeWegner" src="http://www.bloglines.com/images/sub_modern11.gif">Subscribe with Bloglines</feedburner:feedFlare><feedburner:feedFlare href="http://www.netvibes.com/subscribe.php?url=http%3A%2F%2Ffeeds.feedburner.com%2FWadeWegner" src="http://www.netvibes.com/img/add2netvibes.gif">Subscribe with Netvibes</feedburner:feedFlare><feedburner:feedFlare href="http://fusion.google.com/add?feedurl=http%3A%2F%2Ffeeds.feedburner.com%2FWadeWegner" src="http://buttons.googlesyndication.com/fusion/add.gif">Subscribe with Google</feedburner:feedFlare><feedburner:feedFlare href="http://www.pageflakes.com/subscribe.aspx?url=http%3A%2F%2Ffeeds.feedburner.com%2FWadeWegner" src="http://www.pageflakes.com/ImageFile.ashx?instanceId=Static_4&amp;fileName=ATP_blu_91x17.gif">Subscribe with Pageflakes</feedburner:feedFlare><feedburner:feedFlare href="http://www.live.com/?add=http%3A%2F%2Ffeeds.feedburner.com%2FWadeWegner" src="http://tkfiles.storage.msn.com/x1piYkpqHC_35nIp1gLE68-wvzLZO8iXl_JMledmJQXP-XTBOLfmQv4zhj4MhcWEJh_GtoBIiAl1Mjh-ndp9k47If7hTaFno0mxW9_i3p_5qQw">Subscribe with Live.com</feedburner:feedFlare><item>
		<title>Simple Capped Exponential Back-Off for Queues</title>
		<link>http://feedproxy.google.com/~r/WadeWegner/~3/PmBklcjwrk0/</link>
		<comments>http://www.wadewegner.com/2012/04/simple-capped-exponential-back-off-for-queues/#comments</comments>
		<pubDate>Fri, 27 Apr 2012 21:15:36 +0000</pubDate>
		<dc:creator>Wade</dc:creator>
				<category><![CDATA[Azure]]></category>
		<category><![CDATA[Best Practices]]></category>
		<category><![CDATA[Queues]]></category>
		<category><![CDATA[Windows Azure]]></category>

		<guid isPermaLink="false">http://www.wadewegner.com/?p=1805</guid>
		<description><![CDATA[Recently Steve Marx and I spent a few hours working on a best practices document for Windows Azure. As expected, this was a fun and educational experience – plenty of goofing around, but also some really good discussion on things to think about when building applications for Windows Azure. One of the items we discussed [...]]]></description>
			<content:encoded><![CDATA[
<p>Recently <a target="_blank" href="http://blog.smarx.com/" target="_blank">Steve Marx</a> and I spent a few hours working on a best practices document for Windows Azure. As expected, this was a fun and educational experience – plenty of goofing around, but also some really good discussion on things to think about when building applications for Windows Azure. One of the items we discussed is a better approach for sleeping inside the Worker Role when pulling from queues. Rather than defaulting to a retry every 10 seconds we decided that the best approach is to exponentially back-off on your queue reads while capping it with an upper bound.</p>
<p>The primary value of this is to decrease the number of storage transactions when reading from your queue, and therefore reduce both bandwidth and transaction costs.</p>
<p>There are plenty of other good posts on this topic that provide a lot more detailed justification and rationale for this approach:</p>
<ul>
<li><a target="_blank" href="http://www.developerfusion.com/article/120619/advanced-scenarios-with-windows-azure-queues/" target="_blank">Advanced scenarios with Windows Azure Queues</a>
<li><a target="_blank" href="http://geekswithblogs.net/hroggero/archive/2011/05/26/cloud-lesson-learned-exponential-backoff.aspx" target="_blank">Cloud Lesson Learned: Exponential Backoff</a>
<li><a target="_blank" href="http://programming4.us/desktop/2910.aspx" target="_blank">Windows Azure : Messaging with the queue &#8211; Patterns for message processing</a> </li>
</ul>
<p>The logic and approach is deceptively simple and I thought I’d share a really simple, yet effective, example. (Incidentally, credit goes to Steve for very quickly putting together the basis of this really simple example.)</p>
<p>Here’s the code:</p>
<pre class="code"><span style="color: blue">   string </span>queueName = <span style="color: #a31515">"queuetest"</span>;

<span style="color: blue">   int </span>minInterval = 1;
<span style="color: blue">   int </span>interval = minInterval;

<span style="color: blue">   int </span>exponent = 2;
<span style="color: blue">   int </span>maxInterval = 60;

<span style="color: #2b91af">   CloudStorageAccount </span>account = <span style="color: #2b91af">CloudStorageAccount</span>.DevelopmentStorageAccount;
<span style="color: #2b91af">   CloudQueueClient </span>queueClient = account.CreateCloudQueueClient();
<span style="color: #2b91af">   CloudQueue </span>queue = queueClient.GetQueueReference(queueName);
   queue.CreateIfNotExist();

<span style="color: blue">   while </span>(<span style="color: blue">true</span>)
   {
      <span style="color: blue">var </span>msg = queue.GetMessage();
      <span style="color: blue">if </span>(msg != <span style="color: blue">null</span>)
      {
         <span style="color: green">// do something
         </span>queue.DeleteMessage(msg);
         interval = minInterval;

         <span style="color: #2b91af">Trace</span>.WriteLine(<span style="color: blue">string</span>.Format(<span style="color: #a31515">"Interval reset to {0} seconds"</span>, interval));
      }
      <span style="color: blue">else
      </span>{
         <span style="color: #2b91af">Trace</span>.WriteLine(<span style="color: blue">string</span>.Format(<span style="color: #a31515">"Sleep for {0} seconds"</span>, interval));
         <span style="color: #2b91af">Thread</span>.Sleep(<span style="color: #2b91af">TimeSpan</span>.FromSeconds(interval));
         interval = <span style="color: #2b91af">Math</span>.Min(maxInterval, interval * exponent);
      }
   }</pre>
<p>As I said, really simple. The magic is in the last line where we check to see which is smaller – the maximum interval or the product of the interval and the exponent. At some point the product of the interval and exponent grows larger than the maximum interval, and consequently the interval value is set to the maximum interval.</p>
<p>Here’s the output in the Windows Azure Compute Emulator:</p>
<pre style="padding-bottom: 10px; border-right-width: 0px; margin: 0px; padding-left: 0px; outline-width: 0px; padding-right: 0px; font-family: 'Courier New'; background: none transparent scroll repeat 0% 0%; border-top-width: 0px; border-bottom-width: 0px; font-size: 11px; vertical-align: baseline; border-left-width: 0px; padding-top: 0px">   Sleep for 1 seconds
   Sleep for 2 seconds
   Sleep for 4 seconds
   Sleep for 8 seconds
   Sleep for 16 seconds
   Sleep for 32 seconds
   Sleep for 60 seconds
   Sleep for 60 seconds
   ...</pre>
<p>Now, the application will continue to sleep until it finds a message in the queue, at which point the interval is reset back to one. To test this I used the Azure Storage Explorer and created a new queue message.</p>
<p><a target="_blank" href="http://images.wadewegner.com/wordpress/2012/04/AzureStorageExplorerQueue.jpg"><img style="background-image: none; border-right-width: 0px; padding-left: 0px; padding-right: 0px; display: inline; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px; padding-top: 0px" title="AzureStorageExplorerQueue" border="0" alt="AzureStorageExplorerQueue" src="http://images.wadewegner.com/wordpress/2012/04/AzureStorageExplorerQueue_thumb.jpg" width="640" height="464"></a></p>
<p>Once the message is created the output is as follows:</p>
<pre style="padding-bottom: 10px; border-right-width: 0px; margin: 0px; padding-left: 0px; outline-width: 0px; padding-right: 0px; font-family: 'Courier New'; background: none transparent scroll repeat 0% 0%; border-top-width: 0px; border-bottom-width: 0px; font-size: 11px; vertical-align: baseline; border-left-width: 0px; padding-top: 0px">   Interval reset to 1 seconds
   Sleep for 1 seconds
   Sleep for 2 seconds
   Sleep for 4 seconds
   Sleep for 8 seconds
   ...</pre>
<p>And so forth.</p>
<p>You can find all the source code for this sample in my <a target="_blank" href="https://github.com/wadewegner/CappedExponentialBackOff" target="_blank">CappedExponentialBackOff repository</a> on GitHub.</p>
<p>Pretty simple but quite useful. I hope this helps!</p>
<pre></pre>

<div class="feedflare">
<a href="http://feeds.feedburner.com/~ff/WadeWegner?a=PmBklcjwrk0:9ajrtw4qiiY:dnMXMwOfBR0"><img src="http://feeds.feedburner.com/~ff/WadeWegner?d=dnMXMwOfBR0" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/WadeWegner?a=PmBklcjwrk0:9ajrtw4qiiY:V_sGLiPBpWU"><img src="http://feeds.feedburner.com/~ff/WadeWegner?i=PmBklcjwrk0:9ajrtw4qiiY:V_sGLiPBpWU" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/WadeWegner?a=PmBklcjwrk0:9ajrtw4qiiY:F7zBnMyn0Lo"><img src="http://feeds.feedburner.com/~ff/WadeWegner?i=PmBklcjwrk0:9ajrtw4qiiY:F7zBnMyn0Lo" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/WadeWegner?a=PmBklcjwrk0:9ajrtw4qiiY:yIl2AUoC8zA"><img src="http://feeds.feedburner.com/~ff/WadeWegner?d=yIl2AUoC8zA" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/WadeWegner?a=PmBklcjwrk0:9ajrtw4qiiY:qj6IDK7rITs"><img src="http://feeds.feedburner.com/~ff/WadeWegner?d=qj6IDK7rITs" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/WadeWegner?a=PmBklcjwrk0:9ajrtw4qiiY:D7DqB2pKExk"><img src="http://feeds.feedburner.com/~ff/WadeWegner?i=PmBklcjwrk0:9ajrtw4qiiY:D7DqB2pKExk" border="0"></img></a>
</div><img src="http://feeds.feedburner.com/~r/WadeWegner/~4/PmBklcjwrk0" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://www.wadewegner.com/2012/04/simple-capped-exponential-back-off-for-queues/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		<feedburner:origLink>http://www.wadewegner.com/2012/04/simple-capped-exponential-back-off-for-queues/</feedburner:origLink></item>
		<item>
		<title>Return Empty Set Instead of ResourceNotFound from Table Storage</title>
		<link>http://feedproxy.google.com/~r/WadeWegner/~3/x5wwMZTmDtU/</link>
		<comments>http://www.wadewegner.com/2012/04/return-empty-set-instead-of-resourcenotfound-from-table-storage/#comments</comments>
		<pubDate>Sat, 14 Apr 2012 21:50:32 +0000</pubDate>
		<dc:creator>Wade</dc:creator>
				<category><![CDATA[Tables]]></category>
		<category><![CDATA[Windows Azure]]></category>
		<category><![CDATA[Windows Azure Storage]]></category>

		<guid isPermaLink="false">http://www.wadewegner.com/?p=1796</guid>
		<description><![CDATA[This past week I’ve been working on a little project – amazing how less email equates to more time for other endeavors – and I was surprised when I received a DataServiceQueryException when querying table storage in the local storage emulator. I was querying based on partition and row keys and, if no data matched [...]]]></description>
			<content:encoded><![CDATA[
<p>This past week I’ve been working on a little project – amazing how less email equates to more time for other endeavors – and I was surprised when I received a <font size="2" face="Courier New">DataServiceQueryException</font> when querying table storage in the local storage emulator. I was querying based on partition and row keys and, if no data matched the statement, I received an <font size="2" face="Courier New">HTTP 404: Resource Not Found</font> exception.</p>
<p>I was initially puzzled. Shouldn’t I receive an empty set or null instead?</p>
<p>Of course, I had forgotten that this is by design. The <font size="2" face="Courier New">DataServiceContext</font> will throw a <font size="2" face="Courier New">DataServiceQueryException</font> if there’s no data to return. To receive an empty set it’s necessary to set the <font size="2" face="Courier New">IgnoreResourceNotFoundException</font> property to <font size="2" face="Courier New">true</font>.</p>
<p>Here’s a simplified version of the code:</p>
<pre class="code"><span style="color: blue">    string </span>connectionString = <span style="color: #a31515">&quot;UseDevelopmentStorage=true&quot;</span>;

<span style="color: blue">    var </span>context = <span style="color: #2b91af">CloudStorageAccount</span>.Parse(connectionString)
        .CreateCloudTableClient().GetDataServiceContext();

    <font style="background-color: #ffff00">context.IgnoreResourceNotFoundException = <span style="color: blue">true</span>;</font>

<span style="color: blue">    var </span>results = context.CreateQuery&lt;<span style="color: #2b91af">TableEntity</span>&gt;(<span style="color: #a31515">&quot;tableName&quot;</span>)
        .Where(e =&gt; e.PartitionKey == partitionKey &amp;&amp; e.RowKey == rowKey).AsTableServiceQuery();

<span style="color: blue">    var </span>key = results.FirstOrDefault();</pre>
<p>Problem solved. No <font size="2" face="Courier New">DataServiceQueryException</font>!</p>
<p>Something to keep in mind when working with the Windows Azure table storage service. I almost didn’t blog about but decided that it was worth a few minutes effort. Probably something to add to your Windows Azure development checklist (you have one, right?).</p>

<div class="feedflare">
<a href="http://feeds.feedburner.com/~ff/WadeWegner?a=x5wwMZTmDtU:63HHhb3P8PA:dnMXMwOfBR0"><img src="http://feeds.feedburner.com/~ff/WadeWegner?d=dnMXMwOfBR0" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/WadeWegner?a=x5wwMZTmDtU:63HHhb3P8PA:V_sGLiPBpWU"><img src="http://feeds.feedburner.com/~ff/WadeWegner?i=x5wwMZTmDtU:63HHhb3P8PA:V_sGLiPBpWU" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/WadeWegner?a=x5wwMZTmDtU:63HHhb3P8PA:F7zBnMyn0Lo"><img src="http://feeds.feedburner.com/~ff/WadeWegner?i=x5wwMZTmDtU:63HHhb3P8PA:F7zBnMyn0Lo" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/WadeWegner?a=x5wwMZTmDtU:63HHhb3P8PA:yIl2AUoC8zA"><img src="http://feeds.feedburner.com/~ff/WadeWegner?d=yIl2AUoC8zA" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/WadeWegner?a=x5wwMZTmDtU:63HHhb3P8PA:qj6IDK7rITs"><img src="http://feeds.feedburner.com/~ff/WadeWegner?d=qj6IDK7rITs" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/WadeWegner?a=x5wwMZTmDtU:63HHhb3P8PA:D7DqB2pKExk"><img src="http://feeds.feedburner.com/~ff/WadeWegner?i=x5wwMZTmDtU:63HHhb3P8PA:D7DqB2pKExk" border="0"></img></a>
</div><img src="http://feeds.feedburner.com/~r/WadeWegner/~4/x5wwMZTmDtU" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://www.wadewegner.com/2012/04/return-empty-set-instead-of-resourcenotfound-from-table-storage/feed/</wfw:commentRss>
		<slash:comments>4</slash:comments>
		<feedburner:origLink>http://www.wadewegner.com/2012/04/return-empty-set-instead-of-resourcenotfound-from-table-storage/</feedburner:origLink></item>
		<item>
		<title>Joining Aditi Technologies as Chief Technology Officer</title>
		<link>http://feedproxy.google.com/~r/WadeWegner/~3/yjbtMHoMYDU/</link>
		<comments>http://www.wadewegner.com/2012/04/joining-aditi-technologies-as-chief-technology-officer/#comments</comments>
		<pubDate>Fri, 13 Apr 2012 14:08:48 +0000</pubDate>
		<dc:creator>Wade</dc:creator>
				<category><![CDATA[Aditi]]></category>

		<guid isPermaLink="false">http://www.wadewegner.com/?p=1785</guid>
		<description><![CDATA[It’s been a little more than three weeks since I announced my departure from Microsoft. Leaving Microsoft was harder than I expected and I never anticipated the outpouring of support and appreciation from everyone. From the bottom of my heart, thank you! Today I’m really excited to share that I’ve joined Aditi Technologies as Chief [...]]]></description>
			<content:encoded><![CDATA[
<p>It’s been a little more than three weeks since I announced my <a href="http://www.wadewegner.com/2012/03/leaving-microsoft/" target="_blank">departure from Microsoft</a>. Leaving Microsoft was harder than I expected and I never anticipated the outpouring of support and appreciation from everyone. From the bottom of my heart, thank you!</p>
<p><img style="background-image: none; border-right-width: 0px; margin: 4px 10px 5px 0px; padding-left: 0px; padding-right: 0px; display: inline; float: left; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px; padding-top: 0px" title="Aditi Technologies" border="0" alt="Aditi Technologies" align="left" src="http://images.wadewegner.com/wordpress/2012/04/Aditi_Corp_Icons_240.png" width="240" height="27" />Today I’m really excited to share that I’ve joined <a target="_blank" href="http://www.aditi.com/" target="_blank">Aditi Technologies</a> as Chief Technology Officer. Aditi is a top Microsoft partner with a lot of talented people and has recently made a lot of key investments – particularly around Windows Azure. Last November Aditi <a target="_blank" href="http://www.prnewswire.com/news-releases/aditi-technologies-announces-acquisition-of-cumulux-microsoft-cloud-partner-of-the-year-134227893.html" target="_blank">acquired Cumulux</a>, hired Windows Azure MVP <a target="_blank" href="http://adititechnologiesblog.blogspot.com/2010/07/nuno-godinho.html" target="_blank">Nuno Godinho</a>, and most recently brought on the former Windows Azure Tactical Strategist <a target="_blank" href="http://blog.smarx.com/posts/joining-aditi-as-chief-windows-azure-architect" target="_blank">Steve Marx</a>.</p>
<p>Aditi has a cloud-first strategy that I find compelling. Brian Hanna – Director, Cloud Practice – summarized it nicely here:</p>
<p style="padding-left: 15px"><em>&quot;We believe that cloud and consumerization will drive future technology strategies and standards. We encourage our customers to consider a ‘cloud first policy’ for every technology project. While the approach might be radical, we believe that by investing in the cloud ahead of the curve, customers stand to gain significant competitive advantage in the long term.&quot;</em></p>
<p>My leaving Microsoft to join Aditi is a testament to the depth to which I agree with this statement. Yet, while cloud is an area with which I remain passionate, as CTO I will also focus on technologies across our software practices – including digital marketing, enterprise social, IT/virtualization, and BI/analytics. This means I’ll work with SharePoint, SQL Server, AD, Hadoop, and so many other great technologies! At the end of the day, my charter is to build our global engineering capabilities across the company – cloud may be a foundation but there are a lot of other areas with which to dig in!</p>
<p>This is going to be an exciting journey.</p>
<p>To learn a bit more you can read the my <a target="_blank" href="http://www.aditi.com/Home/NewsPage/Aditi_Technologies_appoints_Wade_Wegner_as_Chief_Technology_Officer" target="_blank">official appointment announcement</a> and visit <a target="_blank" href="http://www.aditi.com/About/Management" target="_blank">Aditi management page</a>.</p>

<div class="feedflare">
<a href="http://feeds.feedburner.com/~ff/WadeWegner?a=yjbtMHoMYDU:cNw54j4iv4w:dnMXMwOfBR0"><img src="http://feeds.feedburner.com/~ff/WadeWegner?d=dnMXMwOfBR0" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/WadeWegner?a=yjbtMHoMYDU:cNw54j4iv4w:V_sGLiPBpWU"><img src="http://feeds.feedburner.com/~ff/WadeWegner?i=yjbtMHoMYDU:cNw54j4iv4w:V_sGLiPBpWU" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/WadeWegner?a=yjbtMHoMYDU:cNw54j4iv4w:F7zBnMyn0Lo"><img src="http://feeds.feedburner.com/~ff/WadeWegner?i=yjbtMHoMYDU:cNw54j4iv4w:F7zBnMyn0Lo" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/WadeWegner?a=yjbtMHoMYDU:cNw54j4iv4w:yIl2AUoC8zA"><img src="http://feeds.feedburner.com/~ff/WadeWegner?d=yIl2AUoC8zA" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/WadeWegner?a=yjbtMHoMYDU:cNw54j4iv4w:qj6IDK7rITs"><img src="http://feeds.feedburner.com/~ff/WadeWegner?d=qj6IDK7rITs" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/WadeWegner?a=yjbtMHoMYDU:cNw54j4iv4w:D7DqB2pKExk"><img src="http://feeds.feedburner.com/~ff/WadeWegner?i=yjbtMHoMYDU:cNw54j4iv4w:D7DqB2pKExk" border="0"></img></a>
</div><img src="http://feeds.feedburner.com/~r/WadeWegner/~4/yjbtMHoMYDU" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://www.wadewegner.com/2012/04/joining-aditi-technologies-as-chief-technology-officer/feed/</wfw:commentRss>
		<slash:comments>7</slash:comments>
		<feedburner:origLink>http://www.wadewegner.com/2012/04/joining-aditi-technologies-as-chief-technology-officer/</feedburner:origLink></item>
		<item>
		<title>Leaving Microsoft</title>
		<link>http://feedproxy.google.com/~r/WadeWegner/~3/ys8bJQkeOQg/</link>
		<comments>http://www.wadewegner.com/2012/03/leaving-microsoft/#comments</comments>
		<pubDate>Wed, 21 Mar 2012 15:05:27 +0000</pubDate>
		<dc:creator>Wade</dc:creator>
				<category><![CDATA[Microsoft]]></category>
		<category><![CDATA[Windows Azure]]></category>

		<guid isPermaLink="false">http://www.wadewegner.com/?p=1778</guid>
		<description><![CDATA[I’ve spent a fair amount of time thinking about the right title for this post. Steve Marx was clever with Career vNext, Sriram Krishnan waxed poetic with On Leaving Microsoft, and Brad Abrams just came out and talked about My Last Day at Microsoft. Yet no matter how it’s phrased it comes down to one [...]]]></description>
			<content:encoded><![CDATA[
<p>I’ve spent a fair amount of time thinking about the right title for this post. Steve Marx was clever with <a target="_blank" href="http://blog.smarx.com/posts/career-vnext">Career vNext</a>, Sriram Krishnan waxed poetic with <a target="_blank" href="http://sriramk.com/blog/2011/05/leaving-microsoft.html" class="broken_link">On Leaving Microsoft</a>, and Brad Abrams just came out and talked about <a target="_blank" href="http://blogs.msdn.com/b/brada/archive/2010/04/20/my-last-day-at-microsoft.aspx">My Last Day at Microsoft</a>. Yet no matter how it’s phrased it comes down to one thing: leaving Microsoft.</p>
<p>I can honestly say that I never thought this day would come. Working for Microsoft has been a dream come true – brilliant colleagues, interesting opportunities, and inspiring technologies. In particular, I’ve had a blast working on Windows Azure. I never envisaged that a <a href="http://www.wadewegner.com/2008/11/building-multi-enterprise-business-applications-on-the-azure-services-platform/">little project I worked on in 2008</a> would lead me to Redmond and all the interesting things I’ve done over the last several years.</p>
<p>Fortunately for me (and I hope for you), I am not going far from Windows Azure. I’ll share more details soon but for now I’ll just say that I’m going &#8220;to put money where my mouth is&#8221; and help companies build real solutions on Windows Azure. This is going to be an amazing year for Windows Azure and I plan to push it to the limit!</p>
<p>Don’t hesitate to reach out to me – I’d love to stay in touch.</p>
<ul>
<li>Email: <a target="_blank" href="mailto:wade.wegner@live.com">wade.wegner@live.com</a> </li>
<li>Twitter: <a target="_blank" href="http://twitter.com/#!/wadewegner">@WadeWegner</a> </li>
<li>LinkedIn: <a target="_blank" href="http://www.linkedin.com/in/wadewegner">www.linkedin.com/in/wadewegner</a> </li>
</ul>
<p>Thanks for the ride!</p>

<div class="feedflare">
<a href="http://feeds.feedburner.com/~ff/WadeWegner?a=ys8bJQkeOQg:mknfIA6X_9U:dnMXMwOfBR0"><img src="http://feeds.feedburner.com/~ff/WadeWegner?d=dnMXMwOfBR0" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/WadeWegner?a=ys8bJQkeOQg:mknfIA6X_9U:V_sGLiPBpWU"><img src="http://feeds.feedburner.com/~ff/WadeWegner?i=ys8bJQkeOQg:mknfIA6X_9U:V_sGLiPBpWU" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/WadeWegner?a=ys8bJQkeOQg:mknfIA6X_9U:F7zBnMyn0Lo"><img src="http://feeds.feedburner.com/~ff/WadeWegner?i=ys8bJQkeOQg:mknfIA6X_9U:F7zBnMyn0Lo" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/WadeWegner?a=ys8bJQkeOQg:mknfIA6X_9U:yIl2AUoC8zA"><img src="http://feeds.feedburner.com/~ff/WadeWegner?d=yIl2AUoC8zA" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/WadeWegner?a=ys8bJQkeOQg:mknfIA6X_9U:qj6IDK7rITs"><img src="http://feeds.feedburner.com/~ff/WadeWegner?d=qj6IDK7rITs" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/WadeWegner?a=ys8bJQkeOQg:mknfIA6X_9U:D7DqB2pKExk"><img src="http://feeds.feedburner.com/~ff/WadeWegner?i=ys8bJQkeOQg:mknfIA6X_9U:D7DqB2pKExk" border="0"></img></a>
</div><img src="http://feeds.feedburner.com/~r/WadeWegner/~4/ys8bJQkeOQg" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://www.wadewegner.com/2012/03/leaving-microsoft/feed/</wfw:commentRss>
		<slash:comments>28</slash:comments>
		<feedburner:origLink>http://www.wadewegner.com/2012/03/leaving-microsoft/</feedburner:origLink></item>
		<item>
		<title>Cannot create database ‘DevelopmentStorageDb20110816′ for the Windows Azure Storage Emulator</title>
		<link>http://feedproxy.google.com/~r/WadeWegner/~3/t9_ReS0w64g/</link>
		<comments>http://www.wadewegner.com/2012/01/cannot-create-database-developmentstoragedb20110816-in-storage-emulator-azure-sdk/#comments</comments>
		<pubDate>Wed, 25 Jan 2012 18:37:14 +0000</pubDate>
		<dc:creator>Wade</dc:creator>
				<category><![CDATA[Scripts]]></category>
		<category><![CDATA[Storage Emulator]]></category>
		<category><![CDATA[Windows Azure]]></category>
		<category><![CDATA[Windows Azure Storage]]></category>

		<guid isPermaLink="false">http://www.wadewegner.com/?p=1770</guid>
		<description><![CDATA[Have you seen this error before? If you’ve spent any time with the Windows Azure storage emulator it’s highly probable. Here’s the full text: Added reservation for http://127.0.0.1:10000/ in user account COMPUTER\User. Added reservation for http://127.0.0.1:10001/ in user account COMPUTER\User. Added reservation for http://127.0.0.1:10002/ in user account COMPUTER\User. Creating database DevelopmentStorageDb20110816... Cannot create database 'DevelopmentStorageDb20110816' [...]]]></description>
			<content:encoded><![CDATA[
<p>Have you seen this error before? If you’ve spent any time with the Windows Azure storage emulator it’s highly probable. Here’s the full text:</p>
<pre class="code">    Added reservation for http://127.0.0.1:10000/ in user account COMPUTER\User.
    Added reservation for http://127.0.0.1:10001/ in user account COMPUTER\User.
    Added reservation for http://127.0.0.1:10002/ in user account COMPUTER\User.

    Creating database DevelopmentStorageDb20110816...
    Cannot create database 'DevelopmentStorageDb20110816' : CREATE DATABASE permission
    denied in database 'master'.

    One or more initialization actions have failed. Resolve these errors before attempting
    to run the storage emulator again. These errors can occur if SQL Server was installed
    by someone other than the current user. Please refer to
    http://go.microsoft.com/fwlink/?LinkID=205140 for more details.</pre>
<p>And an image of the error:</p>
<p><img style="background-image: none; border-right-width: 0px; padding-left: 0px; padding-right: 0px; display: inline; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px; padding-top: 0px" title="Development Storage initialization error" border="0" alt="Development Storage initialization error" src="http://images.wadewegner.com/wordpress/2012/01/SQLError.png" width="484" height="370" /></p>
<p>This error can occur when running the storage emulator (or running DSINIT.exe) for the first time. The compute emulator needs to initialize itself, which includes creating a local SQL Server database that is used to store data for local Windows Azure storage. The above error indicates that there’s a permissions when trying to create the database.</p>
<p>There are a number of ways to resolve this issue and, like others, I have my favorite approach. I have a script that I run which will add the executing user to the SQL Server sysadmin role.</p>
<p>I&#8217;ve published the entire script here: <a target="_blank" href="https://gist.github.com/1677788">https://gist.github.com/1677788</a>. Simply download and unzip the file. Open up an elevated command prompt and execute the file (i.e. run <strong>addselftosqlsysadmin.cmd</strong>). Once the script is executed the user can successfully initialize the storage emulator.</p>
<p><script src="https://gist.github.com/1677788.js?file=addselftosqlsysadmin.cmd"></script></p>
<p>I hope this helps!</p>

<div class="feedflare">
<a href="http://feeds.feedburner.com/~ff/WadeWegner?a=t9_ReS0w64g:od6-RRt8WUE:dnMXMwOfBR0"><img src="http://feeds.feedburner.com/~ff/WadeWegner?d=dnMXMwOfBR0" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/WadeWegner?a=t9_ReS0w64g:od6-RRt8WUE:V_sGLiPBpWU"><img src="http://feeds.feedburner.com/~ff/WadeWegner?i=t9_ReS0w64g:od6-RRt8WUE:V_sGLiPBpWU" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/WadeWegner?a=t9_ReS0w64g:od6-RRt8WUE:F7zBnMyn0Lo"><img src="http://feeds.feedburner.com/~ff/WadeWegner?i=t9_ReS0w64g:od6-RRt8WUE:F7zBnMyn0Lo" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/WadeWegner?a=t9_ReS0w64g:od6-RRt8WUE:yIl2AUoC8zA"><img src="http://feeds.feedburner.com/~ff/WadeWegner?d=yIl2AUoC8zA" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/WadeWegner?a=t9_ReS0w64g:od6-RRt8WUE:qj6IDK7rITs"><img src="http://feeds.feedburner.com/~ff/WadeWegner?d=qj6IDK7rITs" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/WadeWegner?a=t9_ReS0w64g:od6-RRt8WUE:D7DqB2pKExk"><img src="http://feeds.feedburner.com/~ff/WadeWegner?i=t9_ReS0w64g:od6-RRt8WUE:D7DqB2pKExk" border="0"></img></a>
</div><img src="http://feeds.feedburner.com/~r/WadeWegner/~4/t9_ReS0w64g" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://www.wadewegner.com/2012/01/cannot-create-database-developmentstoragedb20110816-in-storage-emulator-azure-sdk/feed/</wfw:commentRss>
		<slash:comments>4</slash:comments>
		<feedburner:origLink>http://www.wadewegner.com/2012/01/cannot-create-database-developmentstoragedb20110816-in-storage-emulator-azure-sdk/</feedburner:origLink></item>
		<item>
		<title>Are You Building Mobile + Cloud Applications? Tell Me!</title>
		<link>http://feedproxy.google.com/~r/WadeWegner/~3/zg1WYF0fxgg/</link>
		<comments>http://www.wadewegner.com/2012/01/are-you-building-mobile-cloud-applications-tell-me/#comments</comments>
		<pubDate>Mon, 09 Jan 2012 19:02:43 +0000</pubDate>
		<dc:creator>Wade</dc:creator>
				<category><![CDATA[Android]]></category>
		<category><![CDATA[iOS]]></category>
		<category><![CDATA[Windows Azure]]></category>
		<category><![CDATA[Windows Phone]]></category>

		<guid isPermaLink="false">http://www.wadewegner.com/?p=1764</guid>
		<description><![CDATA[If you follow my blog or on Twitter then you know that I’m passionate about using services running in Windows Azure to power mobile applications. To effectively run mobile services for mobile apps you need a platform that is responsive to a global audience and able to scale to the needs of your user base [...]]]></description>
			<content:encoded><![CDATA[
<p><img style="background-image: none; border-right-width: 0px; margin: 0px 5px 0px 0px; padding-left: 0px; padding-right: 0px; display: inline; float: left; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px; padding-top: 0px" title="WindowsAzure" border="0" alt="WindowsAzure" align="left" src="http://images.wadewegner.com/wordpress/2012/01/image8.png" width="88" height="154" />If you follow my blog or <a target="_blank" href="http://twitter.com/wadewegner" target="_blank">on Twitter</a> then you know that I’m passionate about using services running in Windows Azure to power mobile applications. To effectively run mobile services for mobile apps you need a platform that is responsive to a global audience and able to scale to the needs of your user base – Windows Azure provides these capabilities.</p>
<p>As part of the refresh of the <a target="_blank" href="http://www.windowsazure.com/" target="_blank">WindowsAzure.com</a> we have also provided additional information about <a target="_blank" href="http://www.windowsazure.com/en-us/home/scenarios/mobile/" target="_blank">mobile scenarios</a> – it’s worth taking a look.</p>
<p>We’ve built a lot of resources that you should take a look at, including: the <a target="_blank" href="http://go.microsoft.com/fwlink/?LinkID=234566&amp;clcid=0x409" target="_blank">Windows Azure Toolkit for iOS</a>, the <a target="_blank" href="http://go.microsoft.com/fwlink/?LinkID=234567&amp;clcid=0x409" target="_blank">Windows Azure Toolkit for Android</a>, the <a target="_blank" href="http://go.microsoft.com/fwlink/?LinkID=214684&amp;clcid=0x409" target="_blank">Windows Azure Toolkit for Windows Phone</a>, and a host of NuGet packages for Windows Phone and Windows Azure. All of these resources include native libraries (e.g. Objective-C for iOS and .NET for Windows Phone), sample applications, documentation, and tools. We also have a lot of videos and guides available to make the process of getting started as easy as possible.</p>
<p><strong><font size="3"><u>How can you help?</u></font></strong></p>
<p>One of my primary goals in 2012 is to continue to find and build compelling mobile applications that benefit from Windows Azure. We already have few great stories (see <a target="_blank" href="http://www.microsoft.com/casestudies/Windows-Azure/T-Mobile-USA/Mobile-Operator-Speeds-Time-to-Market-for-Innovative-Social-Networking-Solution/4000008598" target="_blank">T-Mobile USA</a>, <a target="_blank" href="http://www.microsoft.com/casestudies/Windows-Azure/Red-Badger/Creative-Software-Consultancy-Uses-Cloud-Operating-System-for-Twitter-Push-Alerts/4000011213" target="_blank">Red Badger</a>, <a target="_blank" href="http://www.microsoft.com/casestudies/Microsoft-Visual-Studio-Team-Foundation-Server-2010/easyJet/Airline-Aims-to-Save-Millions-Shorten-Airport-Waits-with-Cloud-Based-Mobile-Services/4000010767" target="_blank">easyJet</a>, and more) but that’s only scratching the surface – we can do a lot more!</p>
<p>So, I have a few questions of you:</p>
<ul>
<li>Are you building mobile applications that use services in Windows Azure? </li>
<li>Are you looking for additional PR and opportunities to highlight your applications? </li>
<li>Have you tried any of the toolkits or NuGet packages? </li>
<li>Do you have feedback for me regarding the use of the toolkits or NuGet packages? </li>
<li>What should we do that we aren’t today? </li>
<li>Do you have an application released to a marketplace – either Windows Phone, Apple, or Android – that uses Windows Azure? </li>
</ul>
<p>If you have any feedback to these questions then please contact me at <a target="_blank" href="mailto:wade.wegner@microsoft.com">wade.wegner@microsoft.com</a>. I want to hear from you!</p>
<p>Let’s see what we can accomplish together!</p>

<div class="feedflare">
<a href="http://feeds.feedburner.com/~ff/WadeWegner?a=zg1WYF0fxgg:bK5v7iziFxk:dnMXMwOfBR0"><img src="http://feeds.feedburner.com/~ff/WadeWegner?d=dnMXMwOfBR0" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/WadeWegner?a=zg1WYF0fxgg:bK5v7iziFxk:V_sGLiPBpWU"><img src="http://feeds.feedburner.com/~ff/WadeWegner?i=zg1WYF0fxgg:bK5v7iziFxk:V_sGLiPBpWU" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/WadeWegner?a=zg1WYF0fxgg:bK5v7iziFxk:F7zBnMyn0Lo"><img src="http://feeds.feedburner.com/~ff/WadeWegner?i=zg1WYF0fxgg:bK5v7iziFxk:F7zBnMyn0Lo" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/WadeWegner?a=zg1WYF0fxgg:bK5v7iziFxk:yIl2AUoC8zA"><img src="http://feeds.feedburner.com/~ff/WadeWegner?d=yIl2AUoC8zA" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/WadeWegner?a=zg1WYF0fxgg:bK5v7iziFxk:qj6IDK7rITs"><img src="http://feeds.feedburner.com/~ff/WadeWegner?d=qj6IDK7rITs" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/WadeWegner?a=zg1WYF0fxgg:bK5v7iziFxk:D7DqB2pKExk"><img src="http://feeds.feedburner.com/~ff/WadeWegner?i=zg1WYF0fxgg:bK5v7iziFxk:D7DqB2pKExk" border="0"></img></a>
</div><img src="http://feeds.feedburner.com/~r/WadeWegner/~4/zg1WYF0fxgg" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://www.wadewegner.com/2012/01/are-you-building-mobile-cloud-applications-tell-me/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		<feedburner:origLink>http://www.wadewegner.com/2012/01/are-you-building-mobile-cloud-applications-tell-me/</feedburner:origLink></item>
		<item>
		<title>How to Handle a Faulted Channel with the Windows Azure Service Bus</title>
		<link>http://feedproxy.google.com/~r/WadeWegner/~3/2R9hZNsVOyA/</link>
		<comments>http://www.wadewegner.com/2011/12/how-to-handle-a-faulted-channel-with-the-windows-azure-service-bus/#comments</comments>
		<pubDate>Tue, 13 Dec 2011 04:52:51 +0000</pubDate>
		<dc:creator>Wade</dc:creator>
				<category><![CDATA[Service Bus]]></category>
		<category><![CDATA[WCF]]></category>
		<category><![CDATA[Windows Azure]]></category>

		<guid isPermaLink="false">http://www.wadewegner.com/2011/12/how-to-handle-a-faulted-channel-with-the-windows-azure-service-bus/</guid>
		<description><![CDATA[Recently I wrote a WCF service that fronted an on-premises SQL Server database for an MVC application running in a Window Azure Web Role. There are a number of ways I could have approached this scenario; I decided to use the netTcpRelayBinding via the Windows Azure Service Bus for the following reasons: I needed optimal [...]]]></description>
			<content:encoded><![CDATA[
<p>Recently I wrote a WCF service that fronted an on-premises SQL Server database for an MVC application running in a <a target="_blank" href="http://www.windowsazure.com/en-us/home/tour/compute/" target="_blank">Window Azure Web Role</a>. There are a number of ways I could have approached this scenario; I decided to use the <a target="_blank" href="http://msdn.microsoft.com/en-us/library/windowsazure/microsoft.servicebus.nettcprelaybinding.aspx" target="_blank">netTcpRelayBinding</a> via the <a target="_blank" href="http://www.windowsazure.com/en-us/home/tour/service-bus/" target="_blank">Windows Azure Service Bus</a> for the following reasons:</p>
<ul>
<li>I needed optimal performance (i.e. TCP over HTTP). </li>
<li>I wanted to reuse existing connections (rather than opening many connections). </li>
<li>I didn’t want to open up ports in my firewall (inbound or outbound). </li>
</ul>
<p>Based on these requirements, the Service Bus is almost a no brainer. The Service Bus provides both messaging and connectivity capabilities, the latter of which provide a nice way to build loosely coupled applications in hybrid scenarios (i.e. cloud + on-premises).</p>
<p>I dove right in and wrote the following code:</p>
<pre class="code"><span style="color: blue">public static </span><span style="color: #2b91af">IEnumerable</span>&lt;<span style="color: #2b91af">Customer</span>&gt; GetCustomers()
{
    <span style="color: #2b91af">Uri </span>serviceUri = <span style="color: #2b91af">ServiceBusEnvironment</span>.CreateServiceUri(<span style="color: #a31515">&quot;sb&quot;</span>,
        <span style="color: #a31515">&quot;MYSERVICENAMESPACE&quot;</span>, <span style="color: #a31515">&quot;Customer&quot;</span>);
    <span style="color: blue">var </span>customersChannelFactory = <span style="color: blue">new </span><span style="color: #2b91af">ChannelFactory</span>&lt;<span style="color: #2b91af">ICustomerChannel</span>&gt;(
        <span style="color: #a31515">&quot;RelayEndpoint&quot;</span>, <span style="color: blue">new </span><span style="color: #2b91af">EndpointAddress</span>(serviceUri));
    <span style="color: blue">var </span>customersChannel = customersChannelFactory.CreateChannel();
    customersChannel.Open();

    <span style="color: blue">return </span>customersChannel.GetCustomers();
}</pre>
<p>(I put much of the binding, client, and endpoint behaviors in the Web.Config.)</p>
<p>This code works but has problems. The channel to the Service Bus will open every time the service is called, resulting in suboptimal performance. To make this more efficient I decided to make the <font face="Courier New">ChannelFactory</font> and <font face="Courier New">Channel</font> variables statics so that I could reuse the channel if it had already been opened.</p>
<pre class="code"><span style="color: blue">static </span><span style="color: #2b91af">ChannelFactory</span>&lt;<span style="color: #2b91af">ICustomerChannel</span>&gt; customersChannelFactory;
<span style="color: blue">static </span><span style="color: #2b91af">ICustomerChannel </span>customersChannel;

<span style="color: blue">public static </span><span style="color: #2b91af">IEnumerable</span>&lt;<span style="color: #2b91af">Customer</span>&gt; GetCustomers()
{
    <span style="color: blue">if </span>(customersChannelFactory == <span style="color: blue">null </span>|| customersChannel == <span style="color: blue">null</span>)
    {
        <span style="color: #2b91af">Uri </span>serviceUri = <span style="color: #2b91af">ServiceBusEnvironment</span>.CreateServiceUri(<span style="color: #a31515">&quot;sb&quot;</span>,
            <span style="color: #a31515">&quot;MYSERVICENAMESPACE&quot;</span>, <span style="color: #a31515">&quot;Customer&quot;</span>);
        customersChannelFactory = <span style="color: blue">new </span><span style="color: #2b91af">ChannelFactory</span>&lt;<span style="color: #2b91af">ICustomerChannel</span>&gt;(
            <span style="color: #a31515">&quot;RelayEndpoint&quot;</span>, <span style="color: blue">new </span><span style="color: #2b91af">EndpointAddress</span>(serviceUri));
        customersChannel = customersChannelFactory.CreateChannel();
        customersChannel.Open();
    }

    <span style="color: blue">return </span>customersChannel.GetCustomers();
}</pre>
<p>This updated does a good job of improving the performance of the service call but has it’s own problems. When you create a <font face="Courier New">Channel</font> through the <font face="Courier New">ChannelFactory</font> your channel can enter a faulted state – with the Service Bus there are a number of ways that this can occur (in my testing it was because I often stopped/started the service host). When this happens the WCF communication static must be reset by recreating the client channel. </p>
<p>Finding an efficient – and somewhat elegant – way of handling the faulted state proved to be a fun challenge. Fortunately, I received a lot of help from folks on the Service Bus team.</p>
<p>In the end I went with the following code:</p>
<pre class="code"><span style="color: blue">static </span><span style="color: #2b91af">ChannelFactory</span>&lt;<span style="color: #2b91af">ICustomerChannel</span>&gt; customersChannelFactory;
<span style="color: blue">static </span><span style="color: #2b91af">ICustomerChannel </span>customersChannel;

<span style="color: blue">public static </span><span style="color: #2b91af">IEnumerable</span>&lt;<span style="color: #2b91af">Customer</span>&gt; GetCustomers()
{
    <span style="color: #2b91af">List</span>&lt;<span style="color: #2b91af">Customer</span>&gt; customers = <span style="color: blue">null</span>;

    <span style="color: blue">if </span>(customersChannelFactory == <span style="color: blue">null</span>)
    {
        <span style="color: #2b91af">Uri </span>serviceUri = <span style="color: #2b91af">ServiceBusEnvironment</span>.CreateServiceUri(<span style="color: #a31515">&quot;sb&quot;</span>,
            <span style="color: #a31515">&quot;MYSERVICENAMESPACE&quot;</span>, <span style="color: #a31515">&quot;Customer&quot;</span>);
        customersChannelFactory = <span style="color: blue">new </span><span style="color: #2b91af">ChannelFactory</span>&lt;<span style="color: #2b91af">ICustomerChannel</span>&gt;(
            <span style="color: #a31515">&quot;RelayEndpoint&quot;</span>, <span style="color: blue">new </span><span style="color: #2b91af">EndpointAddress</span>(serviceUri));
    }

    <span style="color: blue">int </span>tries = 0;
    <span style="color: blue">while </span>(tries++ &lt; 3)
    {
        <span style="color: blue">try
        </span>{
            <span style="color: blue">if </span>(customersChannel == <span style="color: blue">null</span>)
            {
                customersChannel = customersChannelFactory.CreateChannel();
                customersChannel.Open();
            }

            <span style="color: blue">return </span>customersChannel.GetCustomers();
        }
        <span style="color: blue">catch </span>(<span style="color: #2b91af">CommunicationException</span>)
        {
            customersChannel.Abort();
            customersChannel = <span style="color: blue">null</span>;
        }
    }

    <span style="color: blue">return </span>customers;
}</pre>
<p>More verbose but much, much better.</p>
<p>The key is correctly handling the <font face="Courier New">CommunicationException</font>, aborting the channel, and setting the channel to null. Since we have retry logic via the while loop it will try again, determine that the channel is null, and re-open the channel.</p>
<p>There are certainly other ways to do this correctly. For example, you could decide to create a <a target="_blank" href="http://msdn.microsoft.com/en-us/library/bb350915.aspx" target="_blank">Faulted event handler</a>.</p>
<p>I hope this helps!</p>

<div class="feedflare">
<a href="http://feeds.feedburner.com/~ff/WadeWegner?a=2R9hZNsVOyA:x5QPJ4lQhwM:dnMXMwOfBR0"><img src="http://feeds.feedburner.com/~ff/WadeWegner?d=dnMXMwOfBR0" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/WadeWegner?a=2R9hZNsVOyA:x5QPJ4lQhwM:V_sGLiPBpWU"><img src="http://feeds.feedburner.com/~ff/WadeWegner?i=2R9hZNsVOyA:x5QPJ4lQhwM:V_sGLiPBpWU" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/WadeWegner?a=2R9hZNsVOyA:x5QPJ4lQhwM:F7zBnMyn0Lo"><img src="http://feeds.feedburner.com/~ff/WadeWegner?i=2R9hZNsVOyA:x5QPJ4lQhwM:F7zBnMyn0Lo" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/WadeWegner?a=2R9hZNsVOyA:x5QPJ4lQhwM:yIl2AUoC8zA"><img src="http://feeds.feedburner.com/~ff/WadeWegner?d=yIl2AUoC8zA" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/WadeWegner?a=2R9hZNsVOyA:x5QPJ4lQhwM:qj6IDK7rITs"><img src="http://feeds.feedburner.com/~ff/WadeWegner?d=qj6IDK7rITs" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/WadeWegner?a=2R9hZNsVOyA:x5QPJ4lQhwM:D7DqB2pKExk"><img src="http://feeds.feedburner.com/~ff/WadeWegner?i=2R9hZNsVOyA:x5QPJ4lQhwM:D7DqB2pKExk" border="0"></img></a>
</div><img src="http://feeds.feedburner.com/~r/WadeWegner/~4/2R9hZNsVOyA" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://www.wadewegner.com/2011/12/how-to-handle-a-faulted-channel-with-the-windows-azure-service-bus/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		<feedburner:origLink>http://www.wadewegner.com/2011/12/how-to-handle-a-faulted-channel-with-the-windows-azure-service-bus/</feedburner:origLink></item>
		<item>
		<title>Unable to find assembly references that are compatible with the target framework ‘Silverlight,Version=v4.0, Profile=WindowsPhone71′</title>
		<link>http://feedproxy.google.com/~r/WadeWegner/~3/m0TI6Dc0ueo/</link>
		<comments>http://www.wadewegner.com/2011/11/unable-to-find-assembly-references-that-are-compatible-with-the-target-framework-silverlightversionv4-0-profilewindowsphone71/#comments</comments>
		<pubDate>Wed, 30 Nov 2011 18:18:18 +0000</pubDate>
		<dc:creator>Wade</dc:creator>
				<category><![CDATA[NuGet]]></category>

		<guid isPermaLink="false">http://www.wadewegner.com/?p=1730</guid>
		<description><![CDATA[Yes, that title is a mouthful. But this title is as cryptic as the error that can get generated when trying to install a NuGet package: Install-Package : Unable to find assembly references that are compatible with the target framework 'Silverlight,Version=v4.0,Profile=WindowsPhone71'. At line:1 char:16 + Install-Package &#60;&#60;&#60;&#60; Phone.Storage + CategoryInfo : NotSpecified: (:) [Install-Package], InvalidOperationException [...]]]></description>
			<content:encoded><![CDATA[
<p>Yes, that title is a mouthful. But this title is as cryptic as the error that can get generated when trying to install a NuGet package:</p>
<pre>    Install-Package : Unable to find assembly references that are compatible with the target
    framework 'Silverlight,Version=v4.0,Profile=WindowsPhone71'.

    At line:1 char:16
    + Install-Package &lt;&lt;&lt;&lt;  Phone.Storage
        + CategoryInfo          : NotSpecified: (:) [Install-Package], InvalidOperationException
        + FullyQualifiedErrorId : NuGetCmdletUnhandledException,
          NuGet.PowerShell.Commands.InstallPackageCommand</pre>
<p>Here’s what you’ll see in Visual Studio:</p>
<p><img style="background-image: none; border-right-width: 0px; padding-left: 0px; padding-right: 0px; display: inline; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px; padding-top: 0px" title="NuGetErrorMessage" border="0" alt="NuGetErrorMessage" src="http://images.wadewegner.com/wordpress/2011/11/NuGetErrorMessage.jpg" width="640" height="215" /></p>
<p>This is the error I get when trying to install one of our <a href="http://www.wadewegner.com/2011/11/nuget-packages-for-windows-azure-and-windows-phone-developers/" target="_blank">NuGet packages</a> on a freshly built machine. Long story short, the reason is that I don’t have the latest NuGet Package Manager.</p>
<p>Take a look at Extension Manager and observe the version number associated with the NuGet Package Manager:</p>
<p><img style="background-image: none; border-right-width: 0px; padding-left: 0px; padding-right: 0px; display: inline; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px; padding-top: 0px" title="OldNuGet" border="0" alt="OldNuGet" src="http://images.wadewegner.com/wordpress/2011/11/OldNuGet.jpg" width="721" height="171" /></p>
<p>See that the version is 1.2? We need to update it to version 1.5. Head to <a target="_blank" href="http://nuget.org">http://nuget.org</a> and from there click to install NuGet. Once you’ve completed the installation you should confirm that you now have version 1.5:</p>
<p><img style="background-image: none; border-right-width: 0px; padding-left: 0px; padding-right: 0px; display: inline; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px; padding-top: 0px" title="NewNuGet" border="0" alt="NewNuGet" src="http://images.wadewegner.com/wordpress/2011/11/NewNuGet.jpg" width="721" height="172" /></p>
<p>So now, when you try to install a NuGet package such as Phone.Storage you won’t have any problems.</p>
<p><img style="background-image: none; border-right-width: 0px; padding-left: 0px; padding-right: 0px; display: inline; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px; padding-top: 0px" title="NuGetWorking" border="0" alt="NuGetWorking" src="http://images.wadewegner.com/wordpress/2011/11/NuGetWorking.jpg" width="640" height="219" /></p>
<p>I hope this helps!</p>

<div class="feedflare">
<a href="http://feeds.feedburner.com/~ff/WadeWegner?a=m0TI6Dc0ueo:lVh-my5EH1M:dnMXMwOfBR0"><img src="http://feeds.feedburner.com/~ff/WadeWegner?d=dnMXMwOfBR0" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/WadeWegner?a=m0TI6Dc0ueo:lVh-my5EH1M:V_sGLiPBpWU"><img src="http://feeds.feedburner.com/~ff/WadeWegner?i=m0TI6Dc0ueo:lVh-my5EH1M:V_sGLiPBpWU" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/WadeWegner?a=m0TI6Dc0ueo:lVh-my5EH1M:F7zBnMyn0Lo"><img src="http://feeds.feedburner.com/~ff/WadeWegner?i=m0TI6Dc0ueo:lVh-my5EH1M:F7zBnMyn0Lo" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/WadeWegner?a=m0TI6Dc0ueo:lVh-my5EH1M:yIl2AUoC8zA"><img src="http://feeds.feedburner.com/~ff/WadeWegner?d=yIl2AUoC8zA" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/WadeWegner?a=m0TI6Dc0ueo:lVh-my5EH1M:qj6IDK7rITs"><img src="http://feeds.feedburner.com/~ff/WadeWegner?d=qj6IDK7rITs" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/WadeWegner?a=m0TI6Dc0ueo:lVh-my5EH1M:D7DqB2pKExk"><img src="http://feeds.feedburner.com/~ff/WadeWegner?i=m0TI6Dc0ueo:lVh-my5EH1M:D7DqB2pKExk" border="0"></img></a>
</div><img src="http://feeds.feedburner.com/~r/WadeWegner/~4/m0TI6Dc0ueo" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://www.wadewegner.com/2011/11/unable-to-find-assembly-references-that-are-compatible-with-the-target-framework-silverlightversionv4-0-profilewindowsphone71/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		<feedburner:origLink>http://www.wadewegner.com/2011/11/unable-to-find-assembly-references-that-are-compatible-with-the-target-framework-silverlightversionv4-0-profilewindowsphone71/</feedburner:origLink></item>
		<item>
		<title>Adding Push Notification Support to Your Windows Phone Application</title>
		<link>http://feedproxy.google.com/~r/WadeWegner/~3/5RSiXgltk58/</link>
		<comments>http://www.wadewegner.com/2011/11/adding-push-notification-support-to-your-windows-phone-application/#comments</comments>
		<pubDate>Fri, 18 Nov 2011 22:32:00 +0000</pubDate>
		<dc:creator>Wade</dc:creator>
				<category><![CDATA[Deep Linking]]></category>
		<category><![CDATA[NuGet]]></category>
		<category><![CDATA[Push Notification]]></category>
		<category><![CDATA[Windows Azure]]></category>
		<category><![CDATA[Windows Phone]]></category>

		<guid isPermaLink="false">http://www.wadewegner.com/2011/11/adding-push-notification-support-to-your-windows-phone-application/</guid>
		<description><![CDATA[A couple days ago I wrote a post on outsourcing user authentication in a Windows Phone application, demonstrating how easy it is to leverage the Windows Azure Access Control service in your Windows Phone application. The solution is built using a set of NuGet packages that our team has built for Windows Phone + Windows [...]]]></description>
			<content:encoded><![CDATA[
<p>A couple days ago I wrote a post on <a href="http://www.wadewegner.com/2011/11/outsourcing-user-authentication-in-a-windows-phone-application/" target="_blank">outsourcing user authentication in a Windows Phone application</a>, demonstrating how easy it is to leverage the Windows Azure Access Control service in your Windows Phone application. The solution is built using a <a href="http://www.wadewegner.com/2011/11/nuget-packages-for-windows-azure-and-windows-phone-developers/" target="_blank">set of NuGet packages</a> that our team has built for Windows Phone + Windows Azure – they provide a similar development experience by allowing you to better manage dependencies and compose great application experiences on the Windows Phone.</p>
<p>Today I want to show a similar way to build support for sending push notifications to Windows Phone applications.</p>
<p>Push notifications provide you a way to deliver information to your applications that are installed on someone’s Windows Phone. It can help provide a key way to differentiate your application from other applications – especially when you tap into tile notifications and take advantage of background tiles, deep linking, and the like. There are a lot of great blog posts on this topic:</p>
<ul>
<li><a target="_blank" href="http://msdn.microsoft.com/en-us/library/ff402558%28v=VS.92%29.aspx" target="_blank">Push Notifications Overview for Windows Phone</a> </li>
<li><a target="_blank" href="http://windowsteamblog.com/windows_phone/b/wpdev/archive/2010/05/03/understanding-microsoft-push-notifications-for-windows-phones.aspx" target="_blank">Understanding Microsoft Push Notifications for Windows Phones</a> (somewhat old) </li>
<li><a target="_blank" href="http://windowsteamblog.com/windows_phone/b/wpdev/archive/2010/05/04/understanding-how-microsoft-push-notification-works-part-2.aspx" target="_blank">Understanding How Microsoft Push Notification Works</a> (somewhat old) </li>
<li><a target="_blank" href="http://www.jeffblankenburg.com/2011/11/11/31-days-of-mango-day-11-live-tiles/" target="_blank">Live Tiles</a> (part of the <a target="_blank" href="http://www.jeffblankenburg.com/2011/10/31/31-days-of-mango/" target="_blank">31 Days of Mango</a> series) </li>
</ul>
<p>One problem I’ve observed with push notifications is most people aren’t sure what to do with the channel URI’s received from the Microsoft Push Notification Service (MPNS). Developers also don’t know where or how to send messages to the device—should it be a service, and if so, where does it run? This is where Windows Azure can provide a lot of help.</p>
<p>Through the Windows Azure Toolkit for Windows Phone, we’ve been providing push notification services for quite a long time. It’s a great solution, and one that has helped a lot of folks. However, it was also relatively difficult to take our samples and then update them such that they worked in your applications. This is where the NuGet packages come into play. We’ve completely refactored the underlying libraries and now deliver all the capabilities as individual NuGets – you can easily create a new Windows Phone application—or update an existing one—using these NuGets.</p>
<p>A few comments on how these NuGets collaborate with the Windows Phone and the MPNS:</p>
<ol>
<li><strong>The Windows Phone Application registers in the MPNS</strong>: The Windows Phone application opens a notification channel to the MPNS and indicates that it wishes to receive push notification messages. The MPNS creates a subscription endpoint associated with that particular channel and forwards it to the Windows Phone device (and the specific application) using the channel it’s just opened. The MPNS sends the endpoint to the application so that the application can send it to the service from which it plans to receive notifications. </li>
<li><strong>The Windows Phone Client registers with the Web Role</strong>: The Windows Phone application invokes a service in the Web Role to register itself with the subscription endpoint received from the MPNS. This endpoint is the URI to which the cloud application will perform the HTTP POSTs to send push notification messages to the device. </li>
<li><strong>The Cloud Service sends a notification request to the MPNS</strong>: The cloud services sends a notification request by doing a HTTP POST in a specific XML format defined by the MPNS protocol to the subscription endpoint associated with the device it wants to notify. </li>
<li><strong>The MPNS sends the notification to the Windows Phone device</strong>: The MPNS transforms the notification request it received to a proper Push Notification to send to the Windows Phone device associated with the endpoint where it received the notification request. The notification request can ask for a toast, a tile, or a raw notification. Once the device receives the push notification via the Push Client it will route the notification to the Shell, which will take an action according to the status of the application. If the application is not running, the shell will either update the application tile, or show a toast. If the application is running, it will send the notification to the already running application. </li>
</ol>
<p>This architectural picture should help explain the interactions:</p>
<p><img style="background-image: none; border-bottom: 0px; border-left: 0px; padding-left: 0px; padding-right: 0px; display: inline; border-top: 0px; border-right: 0px; padding-top: 0px" title="Architecture" border="0" alt="Architecture" src="http://images.wadewegner.com/wordpress/2011/11/Architecture.png" width="777" height="399" /></p>
<p>As with the Windows Phone and ACS example, I want to walk you through the whole process. There’s certainly more that you can do, but I think you’ll agree that the following is quite compelling.</p>
<ol>
<li>Create a new Windows Phone OS 7.1 application.      <br /><img style="background-image: none; border-right-width: 0px; margin: 10px 0px; padding-left: 0px; padding-right: 0px; display: inline; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px; padding-top: 0px" title="NewWindowsPhoneApplication7.1" border="0" alt="NewWindowsPhoneApplication7.1" src="http://images.wadewegner.com/wordpress/2011/11/NewWindowsPhoneApplication7.1.jpg" width="413" height="195" /> </li>
<li>From the <strong>Package Manager Console</strong> type the following to install the ACS base login page NuGet package for Windows Phone: <font face="Courier New">Install-Package Phone.Notifications.BasePage</font><font face="Calibri">.        <br /></font><img style="background-image: none; border-right-width: 0px; margin: 10px 0px; padding-left: 0px; padding-right: 0px; display: inline; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px; padding-top: 0px" title="Phone.Notifications.BasePage" border="0" alt="Phone.Notifications.BasePage" src="http://images.wadewegner.com/wordpress/2011/11/Phone.Notifications.BasePage.jpg" width="635" height="237" /> </li>
<li>Update the<strong> WMAppManifest.xml</strong> file so that the default page is the <strong>Push.xaml</strong>. This way the user will come to the login page before the <strong>MainPage.xaml.        <br /><img style="background-image: none; border-right-width: 0px; margin: 10px 0px; padding-left: 0px; padding-right: 0px; display: inline; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px; padding-top: 0px" title="WMAppManifest" border="0" alt="WMAppManifest" src="http://images.wadewegner.com/wordpress/2011/11/WMAppManifest.jpg" width="691" height="255" /></strong> </li>
<li>Let’s create a page that we can use to demonstration deep linking with MPNS. Create a new <strong>Windows Phone Portrait Page</strong> called <strong>DeepLinkPage.xaml</strong> in the <strong>Pages</strong> folder. </li>
<li>In the <strong>ContentPanel</strong> grid, add a <strong>TextBlock </strong>control. We’ll push a message to this control when sending a notification.
<pre class="code">    <span style="color: blue">&lt;</span><span style="color: #a31515">TextBlock </span><span style="color: red">x</span><span style="color: blue">:</span><span style="color: red">Name</span><span style="color: blue">=&quot;QueryString&quot; </span><span style="color: red">Text</span><span style="color: blue">=&quot;Query string&quot; </span><span style="color: red">Margin</span><span style="color: blue">=&quot;9,10,0,0&quot;
        </span><span style="color: red">Style</span><span style="color: blue">=&quot;{</span><span style="color: #a31515">StaticResource </span><span style="color: red">PhoneTextTitle2Style</span><span style="color: blue">}&quot;/&gt;
</span></pre>
</li>
<li>We need to write the handler that will write the code to the <strong>TextBlock</strong>.
<pre class="code"><span style="color: blue">    protected override void </span>OnNavigatedTo(<span style="color: #2b91af">NavigationEventArgs </span>e)
    {
        <span style="color: blue">if </span>(<span style="color: blue">this</span>.NavigationContext.QueryString.ContainsKey(<span style="color: #a31515">&quot;message&quot;</span>))
        {
            <span style="color: blue">this</span>.QueryString.Text = <span style="color: blue">this</span>.NavigationContext.QueryString[<span style="color: #a31515">&quot;message&quot;</span>];
        }
        <span style="color: blue">else
        </span>{
            <span style="color: blue">this</span>.QueryString.Text = <span style="color: #a31515">&quot;no message was received.&quot;</span>;
        }
    }</pre>
</li>
<li>That’s all there is to do in the Windows Phone client. Now we have to write the services that will store the Channel URI generated by MPNS and allow us to send notifications to the device. Add a new <strong>Windows Azure Project </strong>to the solution. Select the <strong>Internet Application</strong> template using the <strong>HTML 5 semantic markup</strong>.
<p><img style="background-image: none; border-right-width: 0px; margin: 10px 0px; padding-left: 0px; padding-right: 0px; display: inline; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px; padding-top: 0px" title="WindowsAzureProject" border="0" alt="WindowsAzureProject" src="http://images.wadewegner.com/wordpress/2011/11/WindowsAzureProject.jpg" width="639" height="400" /></p>
</li>
<li>From the <strong>Package Manager Console</strong>, change the default project to <strong>Web</strong> (or whatever you called your MVC 3 web application), and then type the following to install the MPNS push notifications services and libraries into the web applications: <font face="Courier New">Install-Package WindowsAzure.Notifications</font>. The services installed will let clients register (and unregister) for receiving push notification messages.
<p><img style="background-image: none; border-bottom: 0px; border-left: 0px; padding-left: 0px; padding-right: 0px; display: inline; border-top: 0px; border-right: 0px; padding-top: 0px" title="WindowsAzure.Notifications" border="0" alt="WindowsAzure.Notifications" src="http://images.wadewegner.com/wordpress/2012/01/WindowsAzure.Notifications.png" width="709" height="240" /></p>
</li>
<li>At this point we don’t have any means for sending a notification. To make this easier, we’ve built a sample management UI for Windows Phone that allows you to manually send push notifications to registered devices. This registers a sample MVC Area called “Notifications” containing the UI and the MPNS Recipe for sending all the supported types of push notifications.
<p><img style="background-image: none; border-right-width: 0px; margin: 10px 0px; padding-left: 0px; padding-right: 0px; display: inline; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px; padding-top: 0px" title="WindowsPhone.Notifications.ManagementUI.Sample" border="0" alt="WindowsPhone.Notifications.ManagementUI.Sample" src="http://images.wadewegner.com/wordpress/2011/11/WindowsPhone.Notifications.ManagementUI.Sample.jpg" width="523" height="237" /> </p>
</li>
<li>At this point you’re ready to roll! Hit <strong>Control-F5 </strong>to build and run. When your website starts browse to http://127.0.0.1:81/notifications and notice that you don’t have any clients currently registered.
<p><img style="background-image: none; border-right-width: 0px; margin: 10px 0px; padding-left: 0px; padding-right: 0px; display: inline; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px; padding-top: 0px" title="image" border="0" alt="image" src="http://images.wadewegner.com/wordpress/2011/11/image.png" width="700" height="441" /></p>
</li>
<li>In the Windows Phone emulator, click to <strong>Enable push notifications</strong>. Wait until you receive confirmation that the channel has successfully registered.
<p><img style="background-image: none; border-right-width: 0px; margin: 10px 0px; padding-left: 0px; padding-right: 0px; display: inline; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px; padding-top: 0px" title="RegisterChannel" border="0" alt="RegisterChannel" src="http://images.wadewegner.com/wordpress/2011/11/RegisterChannel.jpg" width="264" height="480" /></p>
</li>
<li>Reload the notifications page and you’ll see that you now have a registered channel.
<p><img style="background-image: none; border-right-width: 0px; margin: 10px 0px; padding-left: 0px; padding-right: 0px; display: inline; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px; padding-top: 0px" title="RegisteredChannel" border="0" alt="RegisteredChannel" src="http://images.wadewegner.com/wordpress/2011/11/RegisteredChannel.jpg" width="640" height="320" /> </p>
</li>
<li>Click the <strong>Send Notification</strong>. Select the <strong>Raw</strong> notification type, type a message, and click <strong>send</strong>.
<p><img style="background-image: none; border-right-width: 0px; margin: 10px 0px; padding-left: 0px; padding-right: 0px; display: inline; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px; padding-top: 0px" title="SendRawMessage" border="0" alt="SendRawMessage" src="http://images.wadewegner.com/wordpress/2011/11/SendRawMessage.jpg" width="640" height="341" /></p>
</li>
<li>In your application on the Windows Phone emulator you should receive the message. This is great – we’ve just received a push notification message in our application.
<p><img style="background-image: none; border-right-width: 0px; margin: 10px 0px; padding-left: 0px; padding-right: 0px; display: inline; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px; padding-top: 0px" title="RawMessageReceived" border="0" alt="RawMessageReceived" src="http://images.wadewegner.com/wordpress/2011/11/RawMessageReceived.jpg" width="264" height="480" /> </p>
</li>
<li>On the device emulator, click the Windows button, pan to the right, and pin the <strong>PushNotifications</strong> application to start. </li>
<li>Now, from the website, click <strong>Send Notification</strong>. This time select a <strong>Tile </strong>notification type. Change the <strong>Title</strong>, set the <strong>Count</strong>, and choose a <strong>Background Image</strong>. Click <strong>Send</strong>.
<p><img style="background-image: none; border-right-width: 0px; margin: 10px 0px; padding-left: 0px; padding-right: 0px; display: inline; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px; padding-top: 0px" title="SendTileMessage" border="0" alt="SendTileMessage" src="http://images.wadewegner.com/wordpress/2011/11/SendTileMessage.jpg" width="640" height="341" /></p>
</li>
<li>Notice how the <strong>title</strong>, <strong>tile</strong> <strong>background</strong>, and <strong>count</strong> have now updated on the device!
<p><img style="background-image: none; border-right-width: 0px; margin: 10px 0px; padding-left: 0px; padding-right: 0px; display: inline; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px; padding-top: 0px" title="ReceivedTileMessage" border="0" alt="ReceivedTileMessage" src="http://images.wadewegner.com/wordpress/2011/11/ReceivedTileMessage.jpg" width="264" height="480" /></p>
</li>
<li>Lastly, from the website, click <strong>Send Notification</strong>. This time select a <strong>Toast </strong>notification type. Set a <strong>Title</strong>, <strong>Sub Title</strong>, and set the <strong>Target Page </strong>to: <font face="Courier New">/Pages/DeepLinkPage.xaml?message=Hello</font><font face="Calibri">. Click <strong>Send</strong>.
<p><img style="background-image: none; border-right-width: 0px; margin: 10px 0px; padding-left: 0px; padding-right: 0px; display: inline; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px; padding-top: 0px" title="SendToastMessage" border="0" alt="SendToastMessage" src="http://images.wadewegner.com/wordpress/2011/11/SendToastMessage.jpg" width="640" height="341" /></p>
<p>    </font></li>
<li>You’ll receive a toast message (i.e “<strong>Title</strong> <strong>Sub Title</strong>”) on the device. Click it. This will open up the DeepLink.xaml page and pass along the message “Hello” that was sent in the toast.
<p><img style="background-image: none; border-right-width: 0px; margin: 10px 0px; padding-left: 0px; padding-right: 0px; display: inline; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px; padding-top: 0px" title="ReceiveToastMessage" border="0" alt="ReceiveToastMessage" src="http://images.wadewegner.com/wordpress/2011/11/ReceiveToastMessage.jpg" width="528" height="480" /></p>
</li>
</ol>
<p>And that’s it! You can now quickly enrich your Windows Phone applications by leveraging push notifications.</p>
<p>While the Sample UI works great for development, you’ll most likely want to go a few steps further and write your own services or processes to generate notifications. Worker roles with queues work great in this space – I’ll definitely write about this in the future.</p>
<p>Long story short, the following three NuGet packages make it really easy to take advantage of Push Notifications on the Windows Phone using Windows Azure:</p>
<ul>
<li>Install-Package <a target="_blank" href="http://www.nuget.org/List/Packages/Phone.Notifications.BasePage" target="_blank">Phone.Notifications.BasePage</a> </li>
<li>Install-Package <a target="_blank" href="http://www.nuget.org/List/Packages/WindowsAzure.Notifications" target="_blank">WindowsAzure.Notifications</a> </li>
<li>Install-Package <a target="_blank" href="http://www.nuget.org/List/Packages/WindowsPhone.Notifications.ManagementUI.Sample" target="_blank">WindowsPhone.Notifications.ManagementUI.Sample</a> </li>
</ul>
<p>Give it a try and tell me if you agree.</p>
<p>I hope this helps!</p>

<div class="feedflare">
<a href="http://feeds.feedburner.com/~ff/WadeWegner?a=5RSiXgltk58:Jqntzd4GRBQ:dnMXMwOfBR0"><img src="http://feeds.feedburner.com/~ff/WadeWegner?d=dnMXMwOfBR0" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/WadeWegner?a=5RSiXgltk58:Jqntzd4GRBQ:V_sGLiPBpWU"><img src="http://feeds.feedburner.com/~ff/WadeWegner?i=5RSiXgltk58:Jqntzd4GRBQ:V_sGLiPBpWU" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/WadeWegner?a=5RSiXgltk58:Jqntzd4GRBQ:F7zBnMyn0Lo"><img src="http://feeds.feedburner.com/~ff/WadeWegner?i=5RSiXgltk58:Jqntzd4GRBQ:F7zBnMyn0Lo" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/WadeWegner?a=5RSiXgltk58:Jqntzd4GRBQ:yIl2AUoC8zA"><img src="http://feeds.feedburner.com/~ff/WadeWegner?d=yIl2AUoC8zA" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/WadeWegner?a=5RSiXgltk58:Jqntzd4GRBQ:qj6IDK7rITs"><img src="http://feeds.feedburner.com/~ff/WadeWegner?d=qj6IDK7rITs" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/WadeWegner?a=5RSiXgltk58:Jqntzd4GRBQ:D7DqB2pKExk"><img src="http://feeds.feedburner.com/~ff/WadeWegner?i=5RSiXgltk58:Jqntzd4GRBQ:D7DqB2pKExk" border="0"></img></a>
</div><img src="http://feeds.feedburner.com/~r/WadeWegner/~4/5RSiXgltk58" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://www.wadewegner.com/2011/11/adding-push-notification-support-to-your-windows-phone-application/feed/</wfw:commentRss>
		<slash:comments>5</slash:comments>
		<feedburner:origLink>http://www.wadewegner.com/2011/11/adding-push-notification-support-to-your-windows-phone-application/</feedburner:origLink></item>
		<item>
		<title>Outsourcing User Authentication in a Windows Phone Application</title>
		<link>http://feedproxy.google.com/~r/WadeWegner/~3/EEQRoiK-Mng/</link>
		<comments>http://www.wadewegner.com/2011/11/outsourcing-user-authentication-in-a-windows-phone-application/#comments</comments>
		<pubDate>Thu, 17 Nov 2011 05:18:58 +0000</pubDate>
		<dc:creator>Wade</dc:creator>
				<category><![CDATA[Access Control Service]]></category>
		<category><![CDATA[NuGet]]></category>
		<category><![CDATA[Windows Azure]]></category>
		<category><![CDATA[Windows Phone]]></category>

		<guid isPermaLink="false">http://www.wadewegner.com/2011/11/outsourcing-user-authentication-in-a-windows-phone-application/</guid>
		<description><![CDATA[Yesterday I shared all the NuGet packages we’re building to make it easy to build Windows Phone and Windows Azure applications. Today I wanted to share how easy it is to build a Windows Phone application that leverages the Windows Azure Access Control service. The Phone.Identity.AccessControl.BasePage NuGet package includes a control for Window Phone that [...]]]></description>
			<content:encoded><![CDATA[
<p>Yesterday I shared all the <a target="_blank" href="http://www.wadewegner.com/2011/11/nuget-packages-for-windows-azure-and-windows-phone-developers/" target="_blank">NuGet packages we’re building</a> to make it easy to build Windows Phone and Windows Azure applications. Today I wanted to share how easy it is to build a Windows Phone application that leverages the <a href="http://www.microsoft.com/windowsazure/features/accesscontrol/" target="_blank">Windows Azure Access Control service</a>.</p>
<p>The <strong>Phone.Identity.AccessControl.BasePage</strong> NuGet package includes a control for Window Phone that allows your phone applications to outsource user authentication to the Windows Azure Access Control service (ACS). This service enables your users to login by reusing their existing accounts from identity providers such as Windows Live ID, Google, Yahoo, Facebook, and even Active Directory. If you want to know more about ACS you can take a look at the dedicated hands-on labs in the <a target="_blank" href="http://msdn.microsoft.com/gg271268">Windows Azure Platform Training Course</a>.</p>
<p>Using this NuGet package and the included control for ACS in your Windows Phone applications takes care of all the runtime interactions with ACS. Additionally, this package provides a base login page that uses the control and is easy to setup in your phone application. All that is left for you to do is to configure your ACS namespace via the management portal (i.e. specifying your preferences such as the identity providers you want to enable in your application) and integrate the login page into your existing Windows Phone application.</p>
<p>For more information on setting up ACS take a look at the resources at <a target="_blank" href="http://acs.codeplex.com/">http://acs.codeplex.com/</a></p>
<p>To help simplify the process below, I’m making the assumption you already have ACS setup and configured. I’ll be using the following values in the below sample (no guarantee that they’ll be available when you read this post but I’ll do my best):</p>
<ul>
<li><strong>namespace</strong>: watwindowsphone </li>
<li><strong>realm</strong>: uri:watwindowsphone </li>
</ul>
<p>Without further ado, here are the steps to build a Windows Phone application that outsources authentication to ACS:</p>
<ol>
<li>Create a new <strong>Windows Phone OS 7.1</strong> application.       <br /><img style="background-image: none; border-right-width: 0px; margin: 10px 0px; padding-left: 0px; padding-right: 0px; display: inline; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px; padding-top: 0px" title="WindowsPhoneOS71" border="0" alt="WindowsPhoneOS71" src="http://images.wadewegner.com/wordpress/2011/11/WindowsPhoneOS71.jpg" width="527" height="249" /> </li>
<li>From the <strong>Package Manager Console</strong> type the following to install the ACS base login page NuGet package for Windows Phone: <span style="font-family: courier new">Install-Package Phone.Identity.AccessControl.BasePage        <br /><img style="background-image: none; border-right-width: 0px; margin: 10px 0px; padding-left: 0px; padding-right: 0px; display: inline; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px; padding-top: 0px" title="InstallPackage" border="0" alt="InstallPackage" src="http://images.wadewegner.com/wordpress/2011/11/InstallPackage.jpg" width="758" height="236" /></span> </li>
<li>Update the <strong>AccessControlResources.xaml </strong>resources file to use your ACS namespace and the realm you have configured.
<pre class="code">    <span style="color: blue">&lt;</span><span style="color: #a31515">system</span><span style="color: blue">:</span><span style="color: #a31515">String </span><span style="color: red">x</span><span style="color: blue">:</span><span style="color: red">Key</span><span style="color: blue">=&quot;acsNamespace&quot;&gt;</span><span style="color: #a31515">watwindowsphone</span><span style="color: blue">&lt;/</span><span style="color: #a31515">system</span><span style="color: blue">:</span><span style="color: #a31515">String</span><span style="color: blue">&gt;
    &lt;</span><span style="color: #a31515">system</span><span style="color: blue">:</span><span style="color: #a31515">String </span><span style="color: red">x</span><span style="color: blue">:</span><span style="color: red">Key</span><span style="color: blue">=&quot;realm&quot;&gt;</span><span style="color: #a31515">uri:watwindowsphone</span><span style="color: blue">&lt;/</span><span style="color: #a31515">system</span><span style="color: blue">:</span><span style="color: #a31515">String</span><span style="color: blue">&gt;
</span></pre>
</li>
<li>Update the<strong> WMAppManifest.xml</strong> file so that the default page is the <strong>LoginPage.xaml</strong>. This way the user will come to the login page before the <strong>MainPage.xaml</strong>.<img style="background-image: none; border-right-width: 0px; margin: 10px 0px; padding-left: 0px; padding-right: 0px; display: inline; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px; padding-top: 0px" title="WMAManifiest" border="0" alt="WMAManifiest" src="http://images.wadewegner.com/wordpress/2011/11/WMAManifiest.jpg" width="694" height="281" /> </li>
<li>Update the <strong>LoginPage.xaml.cs</strong> so that the user is navigated to the <strong>MainPage.xaml </strong>upon successfully logging into the application. Make sure to update <strong>Line 23 </strong>and <strong>Line 33</strong>.
<pre class="code"><span style="color: blue"> this</span>.NavigationService.Navigate(<span style="color: blue">new </span><span style="color: #2b91af">Uri</span>(<span style="color: #a31515">&quot;/MainPage.xaml&quot;</span>, <span style="color: #2b91af">UriKind</span>.Relative));</pre>
</li>
<li>Let’s display some information from the Simple Web Token. Add a <strong>TextBlock</strong> control to the <strong>MainPage.xaml </strong>page.&#160;
<pre class="code">    <span style="color: green">&lt;!--ContentPanel - place additional content here--&gt;
    </span><span style="color: blue">&lt;</span><span style="color: #a31515">Grid </span><span style="color: red">x</span><span style="color: blue">:</span><span style="color: red">Name</span><span style="color: blue">=&quot;ContentPanel&quot; </span><span style="color: red">Grid.Row</span><span style="color: blue">=&quot;1&quot; </span><span style="color: red">Margin</span><span style="color: blue">=&quot;12,0,12,0&quot;&gt;
        &lt;</span><span style="color: #a31515">TextBlock </span><span style="color: red">Name</span><span style="color: blue">=&quot;DisplayLoginInfo&quot; /&gt;
    &lt;/</span><span style="color: #a31515">Grid</span><span style="color: blue">&gt;
</span></pre>
</li>
<li>Add a Loaded event for the <strong>MainPage.xaml</strong>. In this event you’ll want to load the <strong>simpleWebTokenStore</strong> out of the application resources. You can then use it to grab resources like the name identifier or various other claim types (like Name). Finish by updating the <strong>DisplayLoginInfo</strong>textblock.
<pre class="code"><span style="color: blue">    using </span>Microsoft.WindowsAzure.Samples.Phone.Identity.AccessControl;

    ...

<span style="color: blue">    var </span>simpleWebTokenStore = <span style="color: #2b91af">Application</span>.Current.Resources[<span style="color: #a31515">&quot;swtStore&quot;</span>]
        <span style="color: blue">as </span><span style="color: #2b91af">SimpleWebTokenStore</span>;

<span style="color: blue">    var </span>userNameIdentifier = simpleWebTokenStore.SimpleWebToken.NameIdentifier;
<span style="color: blue">    var </span>name = simpleWebTokenStore.SimpleWebToken.Claims[<span style="color: #2b91af">ClaimTypes</span>.Name];

<span style="color: blue">    this</span>.DisplayLoginInfo.Text =
        <span style="color: #a31515">&quot;Identifier: &quot; </span>+ userNameIdentifier + <span style="color: #2b91af">Environment</span>.NewLine +
        <span style="color: #a31515">&quot;Name: &quot; </span>+ name;</pre>
</li>
<li>Run the application. I’d recommend using Facebook, Google, or Yahoo! for the identity providers, as Live ID does not provide the name claim type in the SWT token.<img style="background-image: none; border-right-width: 0px; padding-left: 0px; padding-right: 0px; display: inline; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px; padding-top: 0px" title="LoginExperience" border="0" alt="LoginExperience" src="http://images.wadewegner.com/wordpress/2011/11/LoginExperience.jpg" width="757" height="426" /> </li>
</ol>
<p>And that’s it! You can now take advantage of the Identifier claim (and others) in your phone application for many things – tracking users, displaying additional user information, and so forth. Additionally, you can use these claims to authenticate against additional services running in Windows Azure – I’ll cover this token in a future post.</p>
<p>The <strong>Phone.Identity.AccessControl.BasePage </strong>NuGet package makes it really easy for you to take advantage of the Windows Azure Access Control service within your applications. ACS provides a great way for you to leverage your users existing identity providers when using your application.</p>
<p>I hope this helps!</p>

<div class="feedflare">
<a href="http://feeds.feedburner.com/~ff/WadeWegner?a=EEQRoiK-Mng:zeWPPlGRLVo:dnMXMwOfBR0"><img src="http://feeds.feedburner.com/~ff/WadeWegner?d=dnMXMwOfBR0" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/WadeWegner?a=EEQRoiK-Mng:zeWPPlGRLVo:V_sGLiPBpWU"><img src="http://feeds.feedburner.com/~ff/WadeWegner?i=EEQRoiK-Mng:zeWPPlGRLVo:V_sGLiPBpWU" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/WadeWegner?a=EEQRoiK-Mng:zeWPPlGRLVo:F7zBnMyn0Lo"><img src="http://feeds.feedburner.com/~ff/WadeWegner?i=EEQRoiK-Mng:zeWPPlGRLVo:F7zBnMyn0Lo" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/WadeWegner?a=EEQRoiK-Mng:zeWPPlGRLVo:yIl2AUoC8zA"><img src="http://feeds.feedburner.com/~ff/WadeWegner?d=yIl2AUoC8zA" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/WadeWegner?a=EEQRoiK-Mng:zeWPPlGRLVo:qj6IDK7rITs"><img src="http://feeds.feedburner.com/~ff/WadeWegner?d=qj6IDK7rITs" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/WadeWegner?a=EEQRoiK-Mng:zeWPPlGRLVo:D7DqB2pKExk"><img src="http://feeds.feedburner.com/~ff/WadeWegner?i=EEQRoiK-Mng:zeWPPlGRLVo:D7DqB2pKExk" border="0"></img></a>
</div><img src="http://feeds.feedburner.com/~r/WadeWegner/~4/EEQRoiK-Mng" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://www.wadewegner.com/2011/11/outsourcing-user-authentication-in-a-windows-phone-application/feed/</wfw:commentRss>
		<slash:comments>11</slash:comments>
		<feedburner:origLink>http://www.wadewegner.com/2011/11/outsourcing-user-authentication-in-a-windows-phone-application/</feedburner:origLink></item>
	</channel>
</rss>

