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

<channel>
	<title>Bill Lodin &#187; Windows Azure</title>
	<atom:link href="http://blogs.itmentors.com/bill/category/microsoft/windows-azure/feed/" rel="self" type="application/rss+xml" />
	<link>http://blogs.itmentors.com/bill</link>
	<description></description>
	<lastBuildDate>Tue, 11 Jan 2011 22:46:09 +0000</lastBuildDate>
	<generator>http://wordpress.org/?v=2.8.2</generator>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
			<item>
		<title>SetConfigurationSettingPublisher demystified</title>
		<link>http://blogs.itmentors.com/bill/2011/01/10/setconfigurationsettingpublisher-demystified/</link>
		<comments>http://blogs.itmentors.com/bill/2011/01/10/setconfigurationsettingpublisher-demystified/#comments</comments>
		<pubDate>Mon, 10 Jan 2011 22:52:52 +0000</pubDate>
		<dc:creator>bill</dc:creator>
				<category><![CDATA[Microsoft]]></category>
		<category><![CDATA[Windows Azure]]></category>
		<category><![CDATA[azure]]></category>
		<category><![CDATA[configuration]]></category>
		<category><![CDATA[setconfigurationsettingpublisher]]></category>

		<guid isPermaLink="false">http://blogs.itmentors.com/bill/?p=107</guid>
		<description><![CDATA[I am often asked by students about the purpose of Azure’s CloudStorageAccount.SetConfigurationSettingPublisher method, particularly when they experience the infamous “SetConfigurationSettingPublisher needs to be called before FromConfigurationSetting can be used” error.
I suppose part of it is the potentially unfamiliar syntax, so let’s start there. You will usually find SetConfigurationPublisher called in code that looks similar to [...]]]></description>
			<content:encoded><![CDATA[<p>I am often asked by students about the purpose of Azure’s <em>CloudStorageAccount.SetConfigurationSettingPublisher</em> method, particularly when they experience the infamous “<em>SetConfigurationSettingPublisher needs to be called before FromConfigurationSetting can be used</em>” error.</p>
<p>I suppose part of it is the potentially unfamiliar syntax, so let’s start there. You will usually find <em>SetConfigurationPublisher</em> called in code that looks similar to the following:</p>
<pre>CloudStorageAccount.SetConfigurationSettingPublisher((configName,
                                                      configSettingPublisher) =&gt;
{
    string configValue = RoleEnvironment.GetConfigurationSettingValue(configName);
    configSettingPublisher(configValue);
});</pre>
<p>In a nutshell, you’re invoking a method that expects a method that takes a method as a parameter. Confused? No worries – it becomes clearer once you unravel the lambda expression.</p>
<p>First, note that the <em>SetConfigurationSettingPublisher</em> method expects a single parameter, of type <em>Action&lt;string,Func&lt;string,bool&gt;&gt;</em>. Instead of using the lambda expression, we could simply define a matching method as follows:</p>
<pre>private void MySettingPublisher(string configName,
                                Func&lt;string, bool&gt; configSettingPublisher) {
}</pre>
<p>Then the call to <em>SetConfigurationSettingPublisher</em> becomes the following:</p>
<pre>CloudStorageAccount.SetConfigurationSettingPublisher(MySettingPublisher);</pre>
<p>Now, when a call is made to retrieve settings from configuration, Azure will invoke our <em>MySettingPublisher</em> method. So far so good, but it won’t work yet because our method doesn’t actually do anything. If you look at the parameters that are passed to our method, you will notice that we receive a <em>string</em> (called <strong>configName</strong>) and a <em>Func&lt;string,bool&gt;</em> called <strong>configSettingPublisher</strong>. In other words, Azure will give us the name of the configuration setting that is being retrieved as well as a method that expects a string and returns a Boolean. We just need to call that method once we’ve figured out what the value for the setting should be. So, a few lines of implementation are all it takes to complete our code:</p>
<pre>private void MySettingPublisher (string configName,
                                 Func&lt;string, bool&gt; configSettingPublisher)
{
   string configValue = RoleEnvironment.GetConfigurationSettingValue(configName);
   configSettingPublisher(configValue);
}</pre>
<p>When you use a method such as <em>CloudStorageAccount.FromConfigurationSetting</em>, Azure looks for a setting publisher. Thanks to an earlier call to <em>SetConfigurationSettingPublisher</em>, it finds your <em>MySettingPublisher</em> method which it dutifully invokes. Your code gets the actual value from configuration (using <em>RoleEnvironment.GetConfigurationSettingValue</em>) and invokes the method Azure provided with the <em>Func&lt;string, bool&gt;</em> parameter.</p>
<p>But why all this back-and-forth between Azure and your code? Shouldn’t <em>CloudStorageAccount.FromConfigurationSetting</em> know that you want to grab the setting out of <em>ServiceConfiguration.cscfg</em> and just take care of it for you?</p>
<p>It turns out that being able to set your own “setting publisher” has code reusability benefits. The most likely scenario is building a Web application that <em>may or may not</em> run in Azure. No Azure, no <em>Service Configuration.cscfg</em> file so you might place the setting in the <strong>&lt;appSettings&gt;</strong> section of <em>Web.config</em>:</p>
<pre>&lt;configuration&gt;
  <strong>&lt;appSettings&gt;
    &lt;add key="MyConnectionString" value="UseDevelopmentStorage=true" /&gt;
  &lt;/appSettings&gt;
</strong>&lt;/configuration&gt;</pre>
<p>Now, let’s modify our <em>MySettingPublisher</em> method as follows:</p>
<pre>private void MySettingPublisher(string configName,
                                Func&lt;string, bool&gt; configSettingPublisher)
{
  var configValue = RoleEnvironment.IsAvailable ?
       RoleEnvironment.GetConfigurationSettingValue(configName) :
       System.Web.Configuration.WebConfigurationManager.AppSettings[configName];
  configSettingPublisher(configValue);</pre>
<pre>}</pre>
<p>With this in place we can run our Web application outside Azure and it still works, it just uses <em>Web.config</em> instead of <em>ServiceConfiguration.cscfg</em>.</p>
<p>By the way, as Steve Marx <a title="How to Resolve “SetConfigurationSettingPublisher needs to be called before FromConfigurationSetting can be used” After Moving to Windows Azure SDK 1.3" href="http://blog.smarx.com/posts/how-to-resolve-setconfigurationsettingpublisher-needs-to-be-called-before-fromconfigurationsetting-can-be-used-after-moving-to-windows-azure-sdk-1-3">points out</a>, if you are building an Azure-specific solution and would rather not worry about all this “setting publisher” business, you could simply use the following to initialize your storage account:</p>
<pre>string configValue = RoleEnvironment.GetConfigurationSettingValue("MyConnectionString");
CloudStorageAccount account = CloudStorageAccount.Parse(configValue);</pre>
<p> </p>
<p>Sample code <a title="Azure configuration sample code" href="http://www.itmentors.com/code/2011/01/AzureConfigDemo.zip">here</a>!</p>
]]></content:encoded>
			<wfw:commentRss>http://blogs.itmentors.com/bill/2011/01/10/setconfigurationsettingpublisher-demystified/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Revisiting the Windows Azure &#8220;How Do I&#8221; videos</title>
		<link>http://blogs.itmentors.com/bill/2010/01/21/revisiting-the-windows-azure-how-do-i-videos/</link>
		<comments>http://blogs.itmentors.com/bill/2010/01/21/revisiting-the-windows-azure-how-do-i-videos/#comments</comments>
		<pubDate>Thu, 21 Jan 2010 19:18:13 +0000</pubDate>
		<dc:creator>bill</dc:creator>
				<category><![CDATA[Microsoft]]></category>
		<category><![CDATA[Windows Azure]]></category>
		<category><![CDATA[blobs]]></category>
		<category><![CDATA[windows azure storage]]></category>

		<guid isPermaLink="false">http://blogs.itmentors.com/bill/?p=86</guid>
		<description><![CDATA[About a year ago I started posting &#8220;How Do I&#8221; videos on topics related to the Windows Azure Platform (of course, back then it was known as the &#8220;Azure Services Platform&#8221; and there were quite a few differences.) Needless to say, every one of these videos is now out-of-date because of the changes and improvements [...]]]></description>
			<content:encoded><![CDATA[<p>About a year ago I started posting &#8220;How Do I&#8221; videos on topics related to the Windows Azure Platform (of course, back then it was known as the &#8220;Azure Services Platform&#8221; and there were quite a few differences.) Needless to say, every one of these videos is now out-of-date because of the changes and improvements that Microsoft has made during a year of CTP testing.</p>
<p>I&#8217;ll be updating a number of these videos, starting with the following which have recently been posted to the msdev site:</p>
<ul>
<li><span><a id="m_c__eventDescription__title" title="Getting Started Developing on Windows Azure" href="http://www.msdev.com/Directory/Description.aspx?eventId=1179">Windows Azure How To Guide: Getting Started Developing on Windows Azure</a></span></li>
<li><span><span><a id="m_c__eventDescription__title" title="Storing Blobs in Windows Azure Storage" href="http://www.msdev.com/Directory/Description.aspx?eventId=1180">Windows Azure How To Guide: Storing Blobs in Windows Azure Storage</a></span></span></li>
</ul>
<p>The video on BlobStorage includes a demonstration app &#8211; you can download the source code <a title="Blob storage demo source code" href="http://www.itmentors.com/code/2010/01/HDI_BlobStorage.zip">here</a>.</p>
<p>Cheers!</p>
]]></content:encoded>
			<wfw:commentRss>http://blogs.itmentors.com/bill/2010/01/21/revisiting-the-windows-azure-how-do-i-videos/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Windows Mobile 6.5 Development</title>
		<link>http://blogs.itmentors.com/bill/2010/01/11/windows-mobile-6-5-development/</link>
		<comments>http://blogs.itmentors.com/bill/2010/01/11/windows-mobile-6-5-development/#comments</comments>
		<pubDate>Mon, 11 Jan 2010 20:55:57 +0000</pubDate>
		<dc:creator>bill</dc:creator>
				<category><![CDATA[Microsoft]]></category>
		<category><![CDATA[Uncategorized]]></category>
		<category><![CDATA[Visual Studio]]></category>
		<category><![CDATA[Windows Azure]]></category>
		<category><![CDATA[windows mobile 6.5]]></category>

		<guid isPermaLink="false">http://blogs.itmentors.com/bill/?p=80</guid>
		<description><![CDATA[Just posted a 30-minute session on Windows Mobile 6.5 &#8211; if you&#8217;re new to Windows Mobile development and you want to get up to speed quickly, this is a good place to start! Here&#8217;s the link to the session:
http://www.msdev.com/Directory/Description.aspx?eventId=1665
This is actually the first in an eight-part series on WM6.5 that IT Mentors is doing for [...]]]></description>
			<content:encoded><![CDATA[<p>Just posted a 30-minute session on Windows Mobile 6.5 &#8211; if you&#8217;re new to Windows Mobile development and you want to get up to speed quickly, this is a good place to start! Here&#8217;s the link to the session:</p>
<p><a href="http://www.msdev.com/Directory/Description.aspx?eventId=1665">http://www.msdev.com/Directory/Description.aspx?eventId=1665</a></p>
<p>This is actually the first in an <a title="Building Applications for Windows Mobile 6.5" href="http://www.msdev.com/Directory/SeriesDescription.aspx?CourseId=146">eight-part series</a> on WM6.5 that IT Mentors is doing for msdev. Oh, and you can download the demo that I used <a title="Windows Mobile 6.5 &quot;Getting Started&quot; demo" href="http://www.itmentors.com/code/2010/01/WinMo65_HelloWorld.zip">here </a>(note that in order for this demo to work you&#8217;ll need to grab the <a title="Windows Mobile Managed Gestures Sample" href="http://code.msdn.microsoft.com/gestureswm">managed code wrapper for Windows Mobile Gestures</a>!)</p>
]]></content:encoded>
			<wfw:commentRss>http://blogs.itmentors.com/bill/2010/01/11/windows-mobile-6-5-development/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>New AppFabric Web Seminars</title>
		<link>http://blogs.itmentors.com/bill/2009/12/14/new-appfabric-web-seminars/</link>
		<comments>http://blogs.itmentors.com/bill/2009/12/14/new-appfabric-web-seminars/#comments</comments>
		<pubDate>Mon, 14 Dec 2009 16:45:39 +0000</pubDate>
		<dc:creator>bill</dc:creator>
				<category><![CDATA[Microsoft]]></category>
		<category><![CDATA[Windows Azure]]></category>
		<category><![CDATA[access control service]]></category>
		<category><![CDATA[appfabric]]></category>
		<category><![CDATA[service bus]]></category>

		<guid isPermaLink="false">http://blogs.itmentors.com/bill/?p=73</guid>
		<description><![CDATA[This morning we posted four new videos as part of the &#8220;Everything You Need to Know About Azure as a Developer&#8221; series. These focus on the Windows Azure platform AppFabric:

AppFabric Overview
AppFabric Fundamentals
AppFabric Service Bus
AppFabric Access Control Service

 
Source code for the &#8220;AppFabric Fundamentals&#8221; session can be downloaded here. The source code I used in the Service [...]]]></description>
			<content:encoded><![CDATA[<p>This morning we posted four new videos as part of the &#8220;<a title="Everything You Need to Know About Azure as a Developer" href="http://www.msdev.com/Directory/SeriesDescription.aspx?CourseId=129">Everything You Need to Know About Azure as a Developer</a>&#8221; series. These focus on the Windows Azure platform <strong>AppFabric</strong>:</p>
<ul>
<li><a title="Windows Azure Platform: AppFabric Overview" href="http://www.msdev.com/Directory/Description.aspx?eventId=1518">AppFabric Overview</a></li>
<li><a title="Windows Azure Platform: AppFabric Fundamentals" href="http://www.msdev.com/Directory/Description.aspx?eventId=1519">AppFabric Fundamentals</a></li>
<li><a title="Windows Azure Platform: Introducing the Service Bus" href="http://www.msdev.com/Directory/Description.aspx?eventId=1520">AppFabric Service Bus</a></li>
<li><a title="Windows Azure Platform: The Access Control Service" href="http://www.msdev.com/Directory/Description.aspx?eventId=1521">AppFabric Access Control Service</a></li>
</ul>
<p> </p>
<p>Source code for the &#8220;AppFabric Fundamentals&#8221; session can be downloaded <a title="AppFabric Fundamentals Code" href="http://www.itmentors.com/code/2009/12/CalculatorDemo.zip">here</a>. The source code I used in the Service Bus and ACS sessions is from the AppFabric SDK, which you can get <a title="AppFabric SDK" href="http://go.microsoft.com/fwlink/?LinkID=129448">here</a>.</p>
<p>Cheers!</p>
]]></content:encoded>
			<wfw:commentRss>http://blogs.itmentors.com/bill/2009/12/14/new-appfabric-web-seminars/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Azure Virtual Lab Changes</title>
		<link>http://blogs.itmentors.com/bill/2009/12/09/azure-virtual-lab-changes/</link>
		<comments>http://blogs.itmentors.com/bill/2009/12/09/azure-virtual-lab-changes/#comments</comments>
		<pubDate>Thu, 10 Dec 2009 04:33:12 +0000</pubDate>
		<dc:creator>bill</dc:creator>
				<category><![CDATA[Microsoft]]></category>
		<category><![CDATA[Uncategorized]]></category>
		<category><![CDATA[Windows Azure]]></category>
		<category><![CDATA[storage client]]></category>
		<category><![CDATA[virtual lab]]></category>

		<guid isPermaLink="false">http://blogs.itmentors.com/bill/?p=69</guid>
		<description><![CDATA[In case you hadn&#8217;t noticed, the Storage Client sample in the SDK is no longer a sample &#8211; as of the November CTP it has become part of the core Azure runtime classes. This is good news for those of us who like having  built-in, easy-to-use, managed wrapper around all the REST-based storage API calls. [...]]]></description>
			<content:encoded><![CDATA[<p>In case you hadn&#8217;t noticed, the Storage Client sample in the SDK is no longer a sample &#8211; as of the November CTP it has become part of the core Azure runtime classes. This is good news for those of us who like having  built-in, easy-to-use, managed wrapper around all the REST-based storage API calls. Unfortunately, the namespace and API changes mean that lots of sample code out there is now broken&#8230; But hey, that&#8217;s why it&#8217;s a CTP, right?</p>
<p>At any rate, the changes mean that the <a title="Azure Virtual Lab" href="http://www.msdev.com/Directory/Description.aspx?eventId=1626">Azure Virtual Lab</a> at <a title="msdev" href="http://www.msdev.com">msdev.com </a>no longer works as is. I&#8217;ll be working on updated content that reflects the latest changes, but in the meantime you should be able to proceed with the help of the following file (luckily, I encapsulated all storage client code into a single class, so this should be a relatively easy fix.)</p>
<p><a title="AzureStorageManager.cs" href="http://www.itmentors.com/code/2009/12/AzureStorageManager.cs.txt">AzureStorageClient.cs</a></p>
<p>UPDATED: The Windows Azure Virtual Lab has now been updated to reflect the November API changes &#8211; you can check it out <a title="Windows Azure Virtual Lab" href="http://www.msdev.com/Directory/Description.aspx?eventId=1626">here</a>.</p>
]]></content:encoded>
			<wfw:commentRss>http://blogs.itmentors.com/bill/2009/12/09/azure-virtual-lab-changes/feed/</wfw:commentRss>
		<slash:comments>3</slash:comments>
		</item>
		<item>
		<title>Web Role as StartUp Project in Visual Studio</title>
		<link>http://blogs.itmentors.com/bill/2009/11/06/web-role-as-startup-project-in-visual-studio/</link>
		<comments>http://blogs.itmentors.com/bill/2009/11/06/web-role-as-startup-project-in-visual-studio/#comments</comments>
		<pubDate>Sat, 07 Nov 2009 00:43:27 +0000</pubDate>
		<dc:creator>bill</dc:creator>
				<category><![CDATA[Microsoft]]></category>
		<category><![CDATA[Visual Studio]]></category>
		<category><![CDATA[Windows Azure]]></category>

		<guid isPermaLink="false">http://blogs.itmentors.com/bill/?p=63</guid>
		<description><![CDATA[The other day I posted an entry about configuration files in Windows Azure, and I mentioned a strategy for being able to build a Web application that runs inside or outside of the cloud. I just wanted to follow up by mentioning the easiest way to test this; it&#8217;s one of those things that is [...]]]></description>
			<content:encoded><![CDATA[<p>The other day I posted an entry about configuration files in Windows Azure, and I mentioned a strategy for being able to build a Web application that runs inside or outside of the cloud. I just wanted to follow up by mentioning the easiest way to test this; it&#8217;s one of those things that is so obvious you might not even think about it.</p>
<p>In a Windows Azure application, the “startup project” is set to the Cloud Service by default. So when you hit F5, the development fabric spins up, the service is packaged and deployed, a browser window opens to host your start page and the Visual Studio debugger attaches to the dev fabric process. But if you right-click your Web role, select “Set as StartUp Project” and then hit F5, Visual Studio will start a debugging session attached to the ASP.NET Web Development Server – in other words, outside of the development fabric. It’s a great way to test the dual-configuration approach I mentioned in my last post!</p>
]]></content:encoded>
			<wfw:commentRss>http://blogs.itmentors.com/bill/2009/11/06/web-role-as-startup-project-in-visual-studio/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Configuration Files and Windows Azure</title>
		<link>http://blogs.itmentors.com/bill/2009/11/04/configuration-files-and-windows-azure/</link>
		<comments>http://blogs.itmentors.com/bill/2009/11/04/configuration-files-and-windows-azure/#comments</comments>
		<pubDate>Wed, 04 Nov 2009 19:15:05 +0000</pubDate>
		<dc:creator>bill</dc:creator>
				<category><![CDATA[Microsoft]]></category>
		<category><![CDATA[Windows Azure]]></category>
		<category><![CDATA[configuration]]></category>
		<category><![CDATA[ServiceConfiguration.cscfg]]></category>
		<category><![CDATA[web.config]]></category>

		<guid isPermaLink="false">http://blogs.itmentors.com/bill/?p=58</guid>
		<description><![CDATA[Last week I posted a short article on how easy it is to move an ASP.NET Web Application to the cloud&#8230; and it is extremely easy, as long as you don&#8217;t have any data, configuration settings, 3rd party libraries, or other issues getting in the way! Actually, all kidding aside, it is pretty easy as [...]]]></description>
			<content:encoded><![CDATA[<p>Last week I posted a short article on how easy it is to move an ASP.NET Web Application to the cloud&#8230; and it is extremely easy, as long as you don&#8217;t have any data, configuration settings, 3rd party libraries, or other issues getting in the way! Actually, all kidding aside, it is pretty easy as long as you understand what’s different and what’s similar when you’re running in the cloud. With a little effort, you should be able to come up with a strategy that doesn’t force you to re-engineer your application; you might even be able to keep your Web application in a state that can be deployed to the Web or to the cloud without any configuration changes!</p>
<p>In this post I’d like to address <strong>configuration</strong>. If you’re an ASP.NET Web developer, you already know all about <em>web.config</em>, and you probably use it all the time to store configuration settings for your application. Let’s assume you want to store a simple message in configuration; your <em>web.config</em> file would contain the following:</p>
<pre>&lt;appSettings&gt;
   &lt;add key="messageText" value="Hello, ASP.NET!"/&gt;
&lt;/appSettings&gt;</pre>
<p>Then you could write some application code that retrieves the value (in this case, displaying it on the Web page using an ASP.NET Label control):</p>
<pre>message.Text = WebConfigurationManager.AppSettings["messageText"];</pre>
<p>The good news is that Web applications running in Windows Azure support <em>web.config</em> so this code will work without any modifications whatsoever. The bad news is that when you deploy an Azure application, the <em>web.config</em> file gets packaged up along with the rest of the Web application components in a <em>.csx</em> file. This sort of defeats the purpose of putting your message in a configuration file, yes? If you didn’t need the ability to change the message without recompiling your application you could have just placed the message text directly into your code. So <em>web.config</em> is a great place for application settings unless you’re app is in the cloud&#8230;</p>
<p>Ah, but Windows Azure does support the idea of a configuration file – it goes by the name <em>ServiceConfiguration.cscfg</em> and it gets deployed separately from the <em>.csx</em> package. And, you can add your own custom settings to it, just like <em>web.config</em>. It takes a bit more effort, since you must first define the setting in <em>ServiceDefinition.csdef</em>:</p>
<pre>&lt;ConfigurationSettings&gt;
   &lt;Setting name="messageText"/&gt;
&lt;/ConfigurationSettings&gt;</pre>
<p>…and then set the actual value in <em>ServiceConfiguration.cscfg</em>:</p>
<pre>&lt;ConfigurationSettings&gt;
   &lt;Setting name="messageText" value="Hello, Azure!"/&gt;
&lt;/ConfigurationSettings&gt;</pre>
<p>Once you’ve done that, you can retrieve the value quite easily:</p>
<pre>message.Text = RoleManager.GetConfigurationSetting("messageText");</pre>
<p>If you’re moving your application into the cloud and you’re “not looking back,” it may make sense to move your settings into the <em>.cscfg</em> file and use that exclusive of <em>web.config</em>. But what about building an application that can be deployed in AND out of the cloud?</p>
<p>Fortunately, it is not difficult to determine at runtime whether you are running in or out of the cloud and retrieve configuration settings as appropriate. In the following code, note how we can check the <em>RoleManager.IsRoleManagerRunning</em> property:</p>
<pre>if (RoleManager.IsRoleManagerRunning)
{
   // we're in the cloud
   message.Text = RoleManager.GetConfigurationSetting("messageText");
}
else if (System.Web.HttpContext.Current != null)
{
   // we're NOT in the cloud, but we're still in a Web application
   message.Text = WebConfigurationManager.AppSettings["messageText"];
}
else
{
   // not in the cloud, not in the web... desktop app maybe?
   message.Text = ConfigurationManager.AppSettings["messageText"];
}</pre>
<p>As you can see, we’ll get the value stored in <em>.cscfg</em> if we’re running in the fabric (the cloud), we get the one from <em>web.config</em> if we’re a “regular” ASP.NET Web application and we can even fall back to the standard .NET Configuration manager.</p>
<p>One more thing – checking <em>RoleManager.IsRoleManagerRunning</em> all the time will surely get tedious if you have a lot of settings to retrieve. You may want to encapsulate the settings retrieval into a reusable component, perhaps similar to the following:</p>
<pre>public class SettingsManager
{
   private static Settings _settings = new Settings();
   public static Settings Settings
   {
      get
      {
         return _settings;
      }
   }
}</pre>
<pre>public class Settings
{
   public string this[string key]
   {
      get
      {
         if (RoleManager.IsRoleManagerRunning)
         {
            return RoleManager.GetConfigurationSetting(key);
         }
         else if (System.Web.HttpContext.Current != null)
         {
            return WebConfigurationManager.AppSettings[key];
         }
         return string.Empty;
      }
   }
}</pre>
<p>You can find a much more comprehensive example (one that also deals with logging) in the <strong>HelloFabric</strong> sample that ships with the <a title="Windows Azure SDK" href="http://go.microsoft.com/fwlink/?LinkID=130232">Windows Azure SDK</a>.</p>
]]></content:encoded>
			<wfw:commentRss>http://blogs.itmentors.com/bill/2009/11/04/configuration-files-and-windows-azure/feed/</wfw:commentRss>
		<slash:comments>6</slash:comments>
		</item>
		<item>
		<title>Migrating Web Applications to Windows Azure</title>
		<link>http://blogs.itmentors.com/bill/2009/10/30/migrating-web-applications-to-windows-azure/</link>
		<comments>http://blogs.itmentors.com/bill/2009/10/30/migrating-web-applications-to-windows-azure/#comments</comments>
		<pubDate>Fri, 30 Oct 2009 22:16:25 +0000</pubDate>
		<dc:creator>bill</dc:creator>
				<category><![CDATA[Microsoft]]></category>
		<category><![CDATA[Windows Azure]]></category>
		<category><![CDATA[migration]]></category>
		<category><![CDATA[web applications]]></category>
		<category><![CDATA[web role]]></category>

		<guid isPermaLink="false">http://blogs.itmentors.com/bill/?p=50</guid>
		<description><![CDATA[With the release of Windows Azure only a few weeks away, it is likely that more and more developers are going to want to move their existing Web applications into the cloud. Fortunately, Microsoft has made it very easy to do so and a big part of that is the decision to make Azure Web Roles [...]]]></description>
			<content:encoded><![CDATA[<p>With the release of Windows Azure only a few weeks away, it is likely that more and more developers are going to want to move their existing Web applications into the cloud. Fortunately, Microsoft has made it very easy to do so and a big part of that is the decision to make Azure Web Roles look (and behave) so much like ASP.NET Web Applications.</p>
<p>Really, a Web Role project and a Web Application project are identical, with one very minor exception: by default, Web Role projects contain a reference to the <em>Microsoft.ServiceHosting.ServiceRuntime</em> assembly and Web Application projects do not:</p>
<div id="attachment_53" class="wp-caption alignnone" style="width: 667px"><img class="size-full wp-image-53" src="http://blogs.itmentors.com/bill/files/2009/10/roleVSapp.png" alt="The ONLY difference between a Web Role project and a Web Application project" width="657" height="428" /><p class="wp-caption-text">The ONLY difference between a Web Role project and a Web Application project</p></div>
<p>Because Web Roles and Web Applications are architecturally identical, you can easily add an existing Web application to a Windows Azure application… It’s a two step process; first, add the Web Application project to your cloud solution:</p>
<div id="attachment_51" class="wp-caption alignnone" style="width: 310px"><img class="size-medium wp-image-51" src="http://blogs.itmentors.com/bill/files/2009/10/addWebApp-300x163.png" alt="Adding a new Web Application project to an existing Cloud Service" width="300" height="163" /><p class="wp-caption-text">Adding a new Web Application project to an existing Cloud Service</p></div>
<p>Second, add the project as a Web Role by right-clicking “Roles” in Solution Explorer and selecting Add &gt; Web Role Project in solution…</p>
<div id="attachment_52" class="wp-caption alignnone" style="width: 310px"><img class="size-medium wp-image-52" src="http://blogs.itmentors.com/bill/files/2009/10/addWebRole-300x167.png" alt="Adding an existing Web Role project in solutions" width="300" height="167" /><p class="wp-caption-text">Adding an existing Web Role project in solutions</p></div>
<p>Your original Web Application project is now part of your Windows Azure application! To make it identical to a Web Role created “from scratch,” simply add a reference to <em>Microsoft.ServiceHosting.ServiceRuntime</em>, which you can find in the Windows Azure SDK (the default location in most cases will be <strong>C:\Program Files\Windows Azure SDK\v1.0\ref\Microsoft.ServiceHosting.ServiceRuntime.dll</strong>.)</p>
<p>One more thing – when you add an existing application to a Visual Studio solution, it just creates a pointer to the original .csproj/.vbproj file from your solution – in other words, make sure you create a backup copy of your original Web Application before you move it into the cloud!</p>
<p>That’s the easy part of migration – however, it can get more complicated and more challenging if your application relies on data storage, services, client-side code or 3rd party libraries. I’ll be posting some short articles on how to deal with these various scenarios in the coming days and weeks.</p>
]]></content:encoded>
			<wfw:commentRss>http://blogs.itmentors.com/bill/2009/10/30/migrating-web-applications-to-windows-azure/feed/</wfw:commentRss>
		<slash:comments>7</slash:comments>
		</item>
		<item>
		<title>Visual Studio 2010 &#8220;Add Reference&#8221; dialog</title>
		<link>http://blogs.itmentors.com/bill/2009/10/29/visual-studio-2010-add-reference-dialog/</link>
		<comments>http://blogs.itmentors.com/bill/2009/10/29/visual-studio-2010-add-reference-dialog/#comments</comments>
		<pubDate>Thu, 29 Oct 2009 16:38:56 +0000</pubDate>
		<dc:creator>bill</dc:creator>
				<category><![CDATA[Microsoft]]></category>
		<category><![CDATA[Windows Azure]]></category>
		<category><![CDATA[add reference]]></category>
		<category><![CDATA[visual studio 2010]]></category>

		<guid isPermaLink="false">http://blogs.itmentors.com/bill/?p=48</guid>
		<description><![CDATA[Scott Guthrie has been publishing a great series of blog posts on the new features in Visual Studio 2010 and .NET 4.0. Today&#8217;s post is about the &#8220;Add Reference&#8221; dialog in VS2010; to me, this is a &#8220;minor tweak&#8221; with a &#8220;major impact.&#8221;
In previous versions of Visual Studio the &#8220;Add Reference&#8221; dialog was always very [...]]]></description>
			<content:encoded><![CDATA[<p><a title="ScottGu's Blog" href="http://weblogs.asp.net/scottgu/">Scott Guthrie</a> has been publishing a great series of blog posts on the new features in Visual Studio 2010 and .NET 4.0. Today&#8217;s post is about the &#8220;Add Reference&#8221; dialog in VS2010; to me, this is a &#8220;minor tweak&#8221; with a &#8220;major impact.&#8221;</p>
<p>In previous versions of Visual Studio the &#8220;Add Reference&#8221; dialog was always very slow to appear the first time you accessed it each session. Turns out this was because the dialog defaults to the &#8220;.NET&#8221; tab and results in a synchronous scan of the global assembly cache (blocking the UI thread). Simply by changing the scan to an asynchronous operation and having the dialog default to the &#8220;Projects&#8221; tab, the dialog will load much faster. More details in <a title="Add Reference Dialog Improvements (VS 2010 and .NET 4.0 Series)" href="http://weblogs.asp.net/scottgu/archive/2009/10/29/add-reference-dialog-improvements-vs-2010-and-net-4-0-series.aspx">Scott&#8217;s post</a>.</p>
<p>Anyway, this is the type of &#8220;feature&#8221; that is likely to get buried amongst more &#8220;exciting&#8221;, <em>new</em> features but it shows the type of thinking going into Visual Studio that has me exciting about this upcoming release. Sure, waiting for the &#8220;Add Reference&#8221; dialog to load may only take a few seconds but multiply that by the number of .NET developers out there and this one little tweak will save countless hours every day.</p>
<p>Minor tweak == Major impact</p>
]]></content:encoded>
			<wfw:commentRss>http://blogs.itmentors.com/bill/2009/10/29/visual-studio-2010-add-reference-dialog/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>New seminar on Azure Worker roles and queue storage</title>
		<link>http://blogs.itmentors.com/bill/2009/10/26/new-seminar-on-azure-worker-roles-and-queue-storage/</link>
		<comments>http://blogs.itmentors.com/bill/2009/10/26/new-seminar-on-azure-worker-roles-and-queue-storage/#comments</comments>
		<pubDate>Mon, 26 Oct 2009 22:42:57 +0000</pubDate>
		<dc:creator>bill</dc:creator>
				<category><![CDATA[Microsoft]]></category>
		<category><![CDATA[Windows Azure]]></category>
		<category><![CDATA[queue storage]]></category>
		<category><![CDATA[worker role]]></category>

		<guid isPermaLink="false">http://blogs.itmentors.com/bill/?p=41</guid>
		<description><![CDATA[It&#8217;s Monday, and these days that means we posted another Web seminar! This is actually the last Web seminar I&#8217;ll be posting until after the PDC, and this one covers Windows Azure Worker roles and Windows Azure queue storage. Here&#8217;s the link to the session itself:
http://www.msdev.com/Directory/Description.aspx?eventId=1499
If you are interested in the sample code, there are [...]]]></description>
			<content:encoded><![CDATA[<p>It&#8217;s Monday, and these days that means we posted another Web seminar! This is actually the last Web seminar I&#8217;ll be posting until after the PDC, and this one covers Windows Azure Worker roles and Windows Azure queue storage. Here&#8217;s the link to the session itself:</p>
<p><a href="http://www.msdev.com/Directory/Description.aspx?eventId=1499">http://www.msdev.com/Directory/Description.aspx?eventId=1499</a></p>
<p>If you are interested in the sample code, there are actually two Visual Studio projects you&#8217;ll need&#8230; The first is a little WPF app that hosts a WCF service. This acts as the SMS &#8220;server&#8221;, and as the name (PsuedoSMS) suggests, there is no actual SMS involved&#8230; I just needed to be able to simulate a service I could invoke from the Worker role.</p>
<p><a title="Source code for fake SMS server" href="http://www.itmentors.com/code/2009/10/PsuedoSMS.zip">PsuedoSMS.zip</a></p>
<p>The second is the cloud service that contains the actual demonstration code from the session. This is a Visual Studio 2008 solution, but you should be able to easily convert it if you want to use it with Visual Studio 2010.</p>
<p><a title="Source code from Worker role and queue storage demo" href="http://www.itmentors.com/code/2009/10/SmsCloudApp.zip">SmsCloudApp.zip</a></p>
<p>Cheers!</p>
<p>Oh, and I need to include some credits as far as the PsuedoSMS app &#8211; the embedded font is called Sveningsson and it was created by Derek Gomez. You can download it from <a title="dafont.com" href="http://www.dafont.com/sveningsson.font">dafont.com</a>. The app also uses a great little library by <a title="Philipp Sumi" href="http://www.hardcodet.net/">Philipp Sumi</a> called <a title="WPF NotifyIcon" href="http://www.hardcodet.net/projects/wpf-notifyicon">WPF NotifyIcon</a> &#8211; it provides an easy way to use WPF for system tray popups.</p>
<p>Also, if you get an &#8220;HTTP could not register URL&#8221; error when you try to run the PsuedoSMS app, you can either run the app as administrator or you can create a reservation for the app&#8230; Start a command prompt with administrator privileges and then execute the following (with appropriate domain/username of course):</p>
<pre>netsh http add urlacl url=http://+:9999/PsuedoSMS/SmsService/ user=DOMAIN\username</pre>
<p>Thanks to <a title="WCF Error: HTTP could not register URL http://+:8000/... Your process does not have access rights to this namespace" href="http://blogs.msdn.com/anirbanc/archive/2008/05/14/wcf-error-http-could-not-register-url-http-8000-your-process-does-not-have-access-rights-to-this-namespace.aspx">Anirban Chakladar&#8217;s blog posting </a>for helping me sort this out quickly&#8230;</p>
]]></content:encoded>
			<wfw:commentRss>http://blogs.itmentors.com/bill/2009/10/26/new-seminar-on-azure-worker-roles-and-queue-storage/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>

