<?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; azure</title>
	<atom:link href="http://blogs.itmentors.com/bill/tag/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>Azure Web Seminars</title>
		<link>http://blogs.itmentors.com/bill/2009/10/13/azure-web-seminars/</link>
		<comments>http://blogs.itmentors.com/bill/2009/10/13/azure-web-seminars/#comments</comments>
		<pubDate>Wed, 14 Oct 2009 02:44:43 +0000</pubDate>
		<dc:creator>bill</dc:creator>
				<category><![CDATA[Microsoft]]></category>
		<category><![CDATA[Windows Azure]]></category>
		<category><![CDATA[azure]]></category>

		<guid isPermaLink="false">http://blogs.itmentors.com/bill/?p=19</guid>
		<description><![CDATA[Ola and I are working and a series of Web seminars on the Windows Azure Platform&#8230; Just posted &#8220;Windows Azure Fundamentals&#8221; and &#8220;Developing a Windows Azure Application&#8220;&#8230; Hope you enjoy!
]]></description>
			<content:encoded><![CDATA[<p>Ola and I are working and a <a title="Azure Web seminars" href="http://www.msdev.com/Directory/SeriesDescription.aspx?CourseId=129">series of Web seminars</a> on the Windows Azure Platform&#8230; Just posted &#8220;<a title="Windows Azure Fundamentals" href="http://www.msdev.com/Directory/Description.aspx?eventId=1496">Windows Azure Fundamentals</a>&#8221; and &#8220;<a title="Developing a Windows Azure Application" href="http://www.msdev.com/Directory/Description.aspx?eventId=1497">Developing a Windows Azure Application</a>&#8220;&#8230; Hope you enjoy!</p>
]]></content:encoded>
			<wfw:commentRss>http://blogs.itmentors.com/bill/2009/10/13/azure-web-seminars/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Windows Azure Log Viewer</title>
		<link>http://blogs.itmentors.com/bill/2009/02/10/windows-azure-log-viewer/</link>
		<comments>http://blogs.itmentors.com/bill/2009/02/10/windows-azure-log-viewer/#comments</comments>
		<pubDate>Tue, 10 Feb 2009 20:24:23 +0000</pubDate>
		<dc:creator>bill</dc:creator>
				<category><![CDATA[Windows Azure]]></category>
		<category><![CDATA[azure]]></category>
		<category><![CDATA[log viewer]]></category>
		<category><![CDATA[logging]]></category>

		<guid isPermaLink="false">http://blogs.itmentors.com/bill/?p=6</guid>
		<description><![CDATA[As Chris and Don are fond of saying, Windows Azure is a “nascent” technology. This means that there are features that, although they may be in a future release, are simply not there right now. One of these is the ability to easily read the log entries from your Windows Azure applications running in the [...]]]></description>
			<content:encoded><![CDATA[<p>As <a title="Chris Anderson" href="http://www.simplegeek.com/">Chris</a> and <a title="Don Box" href="http://www.pluralsight.com/community/blogs/dbox/">Don</a> are fond of saying, Windows Azure is a “nascent” technology. This means that there are features that, although they may be in a future release, are simply not there right now. One of these is the ability to easily read the log entries from your Windows Azure applications running in the cloud. I’ve built a little app that will hopefully make it a bit easier!</p>
<p>First, a quick intro: You can write messages to Windows Azure Logs by calling the <em>RoleManager.WriteToLog() </em>method in the <em>Microsoft.ServiceHosting.ServiceRuntime</em> namespace. When the app is running in the development fabric, you can see the messages in the Development Fabric UI. When the app is running in the cloud, the messages just sort of exist in the Web or Worker role that they originated in. To view them, you first need to copy them to a Windows Azure storage account. You do this by clicking the Configure button for your app, and then clicking <strong>Copy Logs</strong>.</p>
<p>At this point, your logs are now stored as blobs in Windows Azure storage. To get at them using just the SDK tools, you can use the <em>CloudDrive</em> sample (as described in this great post by <a title="Using the CloudDrive Sample to Access Windows Azure Logs" href="http://blogs.msdn.com/jnak/archive/2008/11/12/using-the-clouddrive-sample-to-access-windows-azure-logs.aspx">Jim Nakashima</a>.) Inspired by David Aiken’s <a title="Windows Azure Online Log Reader" href="http://davidaiken.com/windows-azure/windows-azure-online-log-reader/">Windows Azure Online Log Reader</a>, I’ve created a WPF app that should make it really easy to view your logs.</p>
<p>Using it is pretty straightforward: when the application starts up it will prompt you for a storage account name and secret key. When you log in, the app scans blob storage for any container that includes a blob whose name begins with “WebRole” or “WorkerRole”. That way, it filters out blob containers that don’t contain log entries. Then it parses the blob names and creates a tree view of the logs (essentially, recreating the hierarchy shown in the development fabric UI.)</p>
<p>You can also modify various display settings. As always, there are a few things that I still want to add:</p>
<ul>
<li>Search functionality</li>
<li>Support for combining logs (so that you don’t need to look at logs in 15 minute increments)</li>
<li>Sorting by column (it’s why I made the column headers buttons – they don’t do anything right now!)</li>
<li>Persist settings in-between sessions</li>
</ul>
<p>At any rate, I hope you find it useful!</p>
<p><a title="Windows Azure Log Viewer" href="http://www.itmentors.com/code/2009/02/AzureLogViewer.zip">Download Azure Log Viewer</a></p>
]]></content:encoded>
			<wfw:commentRss>http://blogs.itmentors.com/bill/2009/02/10/windows-azure-log-viewer/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
	</channel>
</rss>

