<?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>t h e D a v i d A i k e n &#187; Tip</title>
	<atom:link href="http://www.davidaiken.com/tag/tip/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.davidaiken.com</link>
	<description>Not Statistically Significant</description>
	<lastBuildDate>Wed, 16 Nov 2011 04:04:31 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.3.1</generator>
		<item>
		<title>Ten Basic Troubleshooting Tips for Windows Azure</title>
		<link>http://www.davidaiken.com/2011/11/15/ten-basic-troubleshooting-tips-for-windows-azure/#utm_source=feed&#038;utm_medium=feed&#038;utm_campaign=feed</link>
		<comments>http://www.davidaiken.com/2011/11/15/ten-basic-troubleshooting-tips-for-windows-azure/#comments</comments>
		<pubDate>Tue, 15 Nov 2011 21:42:02 +0000</pubDate>
		<dc:creator>theDavidAiken</dc:creator>
				<category><![CDATA[Windows Azure]]></category>
		<category><![CDATA[Tip]]></category>

		<guid isPermaLink="false">http://www.davidaiken.com/2011/11/15/ten-basic-troubleshooting-tips-for-windows-azure/</guid>
		<description><![CDATA[The last few posts I’ve talked a LOT about configuring diagnostics. Much of that comes not because I love pretty graphs, but because I end up working with customers who are troubleshooting problems with applications running on Windows Azure.
Here is MY list of recommendations to help things run a  [...]]]></description>
			<content:encoded><![CDATA[<p>The last few posts I’ve talked a LOT about configuring diagnostics. Much of that comes not because I love pretty graphs, but because I end up working with customers who are troubleshooting problems with applications running on Windows Azure.</p>
<p>Here is MY list of recommendations to help things run a little smoother:</p>
<ol>
<li>Keep your diagnostics account separate from your production account. This will help with performance of both production and diagnostics since they won’t be competing for the same storage account.</li>
<li>Make sure your storage account is in the same data center as your compute. I know. Just saying.</li>
<li>Make sure you collect the right set of performance counters AND check that you are actually collecting data. Make sure you are collecting the .Net 4.0 counters for ASP.NET where applicable.</li>
<li>Use either the .wadcfg or PowerShell scripts I’ve talked about <a href="http://www.davidaiken.com/2011/10/18/how-to-easily-enable-windows-azure-diagnostics-remotely/#utm_source=feed&amp;utm_medium=feed&amp;utm_campaign=feed" target="_blank">here</a> to configure diagnostics. Hard coding it will overwrite any changes you make when an instance restarts.</li>
<li>Knowing and understanding your baseline workload is important. You should look at your performance on a regular basis, and over a period of time.</li>
<li>To troubleshoot, you can enable RDP and perform an upgrade of your service. You can then RDP into specific instances to troubleshoot.</li>
<li>When you are working with Microsoft’s product support, try not to delete old deployments. Once you do it makes finding a root cause more difficult. You can always VIP swap them out and leave them running while they troubleshoot.</li>
<li>Having more instances running means more people can look at the problem at the same time.</li>
<li>Check the status of the service at <a title="http://www.microsoft.com/windowsazure/support/status/servicedashboard.aspx" href="http://www.microsoft.com/windowsazure/support/status/servicedashboard.aspx">http://www.microsoft.com/windowsazure/support/status/servicedashboard.aspx</a></li>
<li>Invest in a diagnostics data viewing tool, such as <a href="http://www.cerebrata.com/Products/AzureDiagnosticsManager/" target="_blank">Cerebrata</a>, or grab a free trail of ManageAxis by following the rabbit hole from the <a href="http://channel9.msdn.com/Shows/Cloud+Cover/Episode-64-Adding-Push-Notifications-to-Windows-Phone-Apps" target="_blank">Cloud Cover Show</a>.</li>
</ol>
<p>&nbsp;</p>
<p>M5$A)4R!03U-424Y&#8217;($E3(%!23U9)1$5$(.*`G$%3($E3XH&#8221;=(%=)5$@@3D\@A5T%24D%.5$E%4RP@04Y$($-/3D9%4E,@3D\@4DE&#8217;2%13`</p>
]]></content:encoded>
			<wfw:commentRss>http://www.davidaiken.com/2011/11/15/ten-basic-troubleshooting-tips-for-windows-azure/feed/</wfw:commentRss>
		<slash:comments>4</slash:comments>
		</item>
		<item>
		<title>How To Easily Enable Windows Azure Diagnostics Remotely</title>
		<link>http://www.davidaiken.com/2011/10/18/how-to-easily-enable-windows-azure-diagnostics-remotely/#utm_source=feed&#038;utm_medium=feed&#038;utm_campaign=feed</link>
		<comments>http://www.davidaiken.com/2011/10/18/how-to-easily-enable-windows-azure-diagnostics-remotely/#comments</comments>
		<pubDate>Wed, 19 Oct 2011 05:57:10 +0000</pubDate>
		<dc:creator>theDavidAiken</dc:creator>
				<category><![CDATA[Windows Azure]]></category>
		<category><![CDATA[Diagnostics]]></category>
		<category><![CDATA[How To]]></category>
		<category><![CDATA[Tip]]></category>

		<guid isPermaLink="false">http://www.davidaiken.com/2011/10/18/how-to-easily-enable-windows-azure-diagnostics-remotely/</guid>
		<description><![CDATA[One of the great things about life is PowerShell. That could be the end of the post, but instead I’m going to add some steps on how to enable Diagnostics on a Windows Azure service once it has been deployed. This turned out to be a long post with lots of PowerShell to get excited about 
Apart from  [...]]]></description>
			<content:encoded><![CDATA[<p>One of the great things about life is PowerShell. That could be the end of the post, but instead I’m going to add some steps on how to enable Diagnostics on a Windows Azure service once it has been deployed. This turned out to be a long post with lots of PowerShell to get excited about <img style="border-bottom-style: none; border-left-style: none; border-top-style: none; border-right-style: none" class="wlEmoticon wlEmoticon-smile" alt="Smile" src="http://www.davidaiken.com/wp-content/uploads/2011/10/wlEmoticon-smile.png" /></p>
<p>Apart from the obvious separation of duties &#8211; unless you are specifically debugging a service deployment issue, you don’t need to write code in your service to enable diagnostics. You will get it wrong anyway by collecting 800 counters at 1 second intervals which is not likely to be any help to anyone.</p>
<p>What I typically start out collecting is some pretty basic things, CPU, Memory Usage, Network and if it is a ASP.NET site some ASP.NET specific counters. Basically I’m looking for enough information to give me a good finger on the pulse. These can be collected at intervals between 5 and 15 minutes because we are really interested in the load over time, rather than individual peaks.</p>
<h2>Getting Started</h2>
<p>First you need to make sure you have a <a href="http://www.davidaiken.com/2009/12/21/how-to-create-a-x509-certificate-for-the-windows-azure-management-api/#utm_source=feed&amp;utm_medium=feed&amp;utm_campaign=feed" target="_blank">management certificate created and installed</a>. </p>
<p>Once you have that, you need to download the PowerShell cmdlets from <a href="http://wappowershell.codeplex.com/" target="_blank">codeplex</a>.</p>
<p>Next figure out what the thumbprint of your certificate is. You can see this in the Windows Azure management portal when you click your certificate. While you are there, make a note of your subscription Id, Storage Account Name and Key and the service name.</p>
<p><strong>Tip</strong>: While I’m figuring out the right commands to use, I usually set these up as variables.</p>
<p>Rather than dump the whole script on you, let me walk you through what is happening and why. You can do this interactively in a PowerShell window if you want to follow along. The entire script is at the end. </p>
<p>Here are a few lines of the script to set the variables up:</p>
<style type="text/css">
<p>.csharpcode, .csharpcode pre
{
	font-size: small;
	color: black;
	font-family: consolas, "Courier New", courier, monospace;
	background-color: #ffffff;
	/*white-space: pre;*/
}
.csharpcode pre { margin: 0em; }
.csharpcode .rem { color: #008000; }
.csharpcode .kwrd { color: #0000ff; }
.csharpcode .str { color: #006080; }
.csharpcode .op { color: #0000c0; }
.csharpcode .preproc { color: #cc6633; }
.csharpcode .asp { background-color: #ffff00; }
.csharpcode .html { color: #800000; }
.csharpcode .attr { color: #ff0000; }
.csharpcode .alt 
{
	background-color: #f4f4f4;
	width: 100%;
	margin: 0em;
}
.csharpcode .lnum { color: #606060; }</style>
<pre class="csharpcode"><span class="rem"># TODO: Cert thumbprint of a certificate already installed into the Windows Azure Portal</span>
$thumb = <span class="str">&quot;PUTTHETHUMBHERE&quot;</span>
$cert = get-item cert:\CurrentUser\My\$thumb
<span class="rem"># TODO: Subscription Id</span>
$subid = <span class="str">&quot;PUTYOURSUBSCRIPTIONIDHERE&quot;</span>
<span class="rem"># TODO: Storage Account Name</span>
$SAN = <span class="str">&quot;PUTYOURSTORAGEACCOUNTNAMEHERE&quot;</span>
<span class="rem"># TODO: Storage Account Key</span>
$SAK = <span class="str">&quot;PUTYOURSTORAGEACCOUNTKEYHERE&quot;</span>
<span class="rem"># TODO: Service Name</span>
$serviceName = <span class="str">&quot;PUTYOURSERVICENAMEHERE&quot;</span></pre>
<style type="text/css">
.csharpcode, .csharpcode pre
{
	font-size: small;
	color: black;
	font-family: consolas, "Courier New", courier, monospace;
	background-color: #ffffff;
	/*white-space: pre;*/
}
.csharpcode pre { margin: 0em; }
.csharpcode .rem { color: #008000; }
.csharpcode .kwrd { color: #0000ff; }
.csharpcode .str { color: #006080; }
.csharpcode .op { color: #0000c0; }
.csharpcode .preproc { color: #cc6633; }
.csharpcode .asp { background-color: #ffff00; }
.csharpcode .html { color: #800000; }
.csharpcode .attr { color: #ff0000; }
.csharpcode .alt 
{
	background-color: #f4f4f4;
	width: 100%;
	margin: 0em;
}
.csharpcode .lnum { color: #606060; }</style>
<p>As you can see, we can grab the actual certificate very easily using the get-item cmdlet.<br />
<style type="text/css">
<p>.csharpcode, .csharpcode pre
{
	font-size: small;
	color: black;
	font-family: consolas, "Courier New", courier, monospace;
	background-color: #ffffff;
	/*white-space: pre;*/
}
.csharpcode pre { margin: 0em; }
.csharpcode .rem { color: #008000; }
.csharpcode .kwrd { color: #0000ff; }
.csharpcode .str { color: #006080; }
.csharpcode .op { color: #0000c0; }
.csharpcode .preproc { color: #cc6633; }
.csharpcode .asp { background-color: #ffff00; }
.csharpcode .html { color: #800000; }
.csharpcode .attr { color: #ff0000; }
.csharpcode .alt 
{
	background-color: #f4f4f4;
	width: 100%;
	margin: 0em;
}
.csharpcode .lnum { color: #606060; }</style>
<h2>Getting a list of services</h2>
<p>You can check really quickly to see if you have everything configured correctly by using the <strong>Get-HostedServices</strong> cmdlet:</p>
<pre class="csharpcode">Get-HostedServices -SubscriptionId $subid -Certificate $cert</pre>
<style type="text/css">
.csharpcode, .csharpcode pre
{
	font-size: small;
	color: black;
	font-family: consolas, "Courier New", courier, monospace;
	background-color: #ffffff;
	/*white-space: pre;*/
}
.csharpcode pre { margin: 0em; }
.csharpcode .rem { color: #008000; }
.csharpcode .kwrd { color: #0000ff; }
.csharpcode .str { color: #006080; }
.csharpcode .op { color: #0000c0; }
.csharpcode .preproc { color: #cc6633; }
.csharpcode .asp { background-color: #ffff00; }
.csharpcode .html { color: #800000; }
.csharpcode .attr { color: #ff0000; }
.csharpcode .alt 
{
	background-color: #f4f4f4;
	width: 100%;
	margin: 0em;
}
.csharpcode .lnum { color: #606060; }</style>
<p>This cmdlet should return a list of services you have deployed to that service account.</p>
<p>To get information on an individual service you can you <strong>Get-HostedService</strong>:</p>
<pre class="csharpcode">Get-HostedService -SubscriptionId $subid -Certificate $cert -ServiceName $serviceName</pre>
<style type="text/css">
.csharpcode, .csharpcode pre
{
	font-size: small;
	color: black;
	font-family: consolas, "Courier New", courier, monospace;
	background-color: #ffffff;
	/*white-space: pre;*/
}
.csharpcode pre { margin: 0em; }
.csharpcode .rem { color: #008000; }
.csharpcode .kwrd { color: #0000ff; }
.csharpcode .str { color: #006080; }
.csharpcode .op { color: #0000c0; }
.csharpcode .preproc { color: #cc6633; }
.csharpcode .asp { background-color: #ffff00; }
.csharpcode .html { color: #800000; }
.csharpcode .attr { color: #ff0000; }
.csharpcode .alt 
{
	background-color: #f4f4f4;
	width: 100%;
	margin: 0em;
}
.csharpcode .lnum { color: #606060; }</style>
<style type="text/css">
<p>.csharpcode, .csharpcode pre
{
	font-size: small;
	color: black;
	font-family: consolas, "Courier New", courier, monospace;
	background-color: #ffffff;
	/*white-space: pre;*/
}
.csharpcode pre { margin: 0em; }
.csharpcode .rem { color: #008000; }
.csharpcode .kwrd { color: #0000ff; }
.csharpcode .str { color: #006080; }
.csharpcode .op { color: #0000c0; }
.csharpcode .preproc { color: #cc6633; }
.csharpcode .asp { background-color: #ffff00; }
.csharpcode .html { color: #800000; }
.csharpcode .attr { color: #ff0000; }
.csharpcode .alt 
{
	background-color: #f4f4f4;
	width: 100%;
	margin: 0em;
}
.csharpcode .lnum { color: #606060; }</style>
<p>Before I get carried away, you can get a full list of cmdlets to explore using:</p>
<pre class="csharpcode">Get-Command -Module WAPPSCmdlets</pre>
<style type="text/css">
.csharpcode, .csharpcode pre
{
	font-size: small;
	color: black;
	font-family: consolas, "Courier New", courier, monospace;
	background-color: #ffffff;
	/*white-space: pre;*/
}
.csharpcode pre { margin: 0em; }
.csharpcode .rem { color: #008000; }
.csharpcode .kwrd { color: #0000ff; }
.csharpcode .str { color: #006080; }
.csharpcode .op { color: #0000c0; }
.csharpcode .preproc { color: #cc6633; }
.csharpcode .asp { background-color: #ffff00; }
.csharpcode .html { color: #800000; }
.csharpcode .attr { color: #ff0000; }
.csharpcode .alt 
{
	background-color: #f4f4f4;
	width: 100%;
	margin: 0em;
}
.csharpcode .lnum { color: #606060; }</style>
<style type="text/css">
<p>.csharpcode, .csharpcode pre
{
	font-size: small;
	color: black;
	font-family: consolas, "Courier New", courier, monospace;
	background-color: #ffffff;
	/*white-space: pre;*/
}
.csharpcode pre { margin: 0em; }
.csharpcode .rem { color: #008000; }
.csharpcode .kwrd { color: #0000ff; }
.csharpcode .str { color: #006080; }
.csharpcode .op { color: #0000c0; }
.csharpcode .preproc { color: #cc6633; }
.csharpcode .asp { background-color: #ffff00; }
.csharpcode .html { color: #800000; }
.csharpcode .attr { color: #ff0000; }
.csharpcode .alt 
{
	background-color: #f4f4f4;
	width: 100%;
	margin: 0em;
}
.csharpcode .lnum { color: #606060; }</style>
<h2>Getting the current deployment</h2>
<p>Back to diagnostics. When configuring diagnostics, you need to know which deployment to work with. You specify the deployment using the deployment id. You can grab the current deployment using the <strong>Get-Deployment</strong> cmdlet:</p>
<pre class="csharpcode">Get-Deployment -ServiceName $serviceName -Certificate $cert -SubscriptionId $subid -Slot Production</pre>
<style type="text/css">
.csharpcode, .csharpcode pre
{
	font-size: small;
	color: black;
	font-family: consolas, "Courier New", courier, monospace;
	background-color: #ffffff;
	/*white-space: pre;*/
}
.csharpcode pre { margin: 0em; }
.csharpcode .rem { color: #008000; }
.csharpcode .kwrd { color: #0000ff; }
.csharpcode .str { color: #006080; }
.csharpcode .op { color: #0000c0; }
.csharpcode .preproc { color: #cc6633; }
.csharpcode .asp { background-color: #ffff00; }
.csharpcode .html { color: #800000; }
.csharpcode .attr { color: #ff0000; }
.csharpcode .alt 
{
	background-color: #f4f4f4;
	width: 100%;
	margin: 0em;
}
.csharpcode .lnum { color: #606060; }</style>
<style type="text/css">
<p>.csharpcode, .csharpcode pre
{
	font-size: small;
	color: black;
	font-family: consolas, "Courier New", courier, monospace;
	background-color: #ffffff;
	/*white-space: pre;*/
}
.csharpcode pre { margin: 0em; }
.csharpcode .rem { color: #008000; }
.csharpcode .kwrd { color: #0000ff; }
.csharpcode .str { color: #006080; }
.csharpcode .op { color: #0000c0; }
.csharpcode .preproc { color: #cc6633; }
.csharpcode .asp { background-color: #ffff00; }
.csharpcode .html { color: #800000; }
.csharpcode .attr { color: #ff0000; }
.csharpcode .alt 
{
	background-color: #f4f4f4;
	width: 100%;
	margin: 0em;
}
.csharpcode .lnum { color: #606060; }</style>
<p>One property of the result is <strong>DeploymentId</strong>. You can grab that and save it to another variable using:</p>
<pre class="csharpcode">$did = (Get-Deployment -ServiceName $serviceName -Certificate $cert -SubscriptionId $subid -Slot Production).DeploymentId</pre>
<style type="text/css">
.csharpcode, .csharpcode pre
{
	font-size: small;
	color: black;
	font-family: consolas, "Courier New", courier, monospace;
	background-color: #ffffff;
	/*white-space: pre;*/
}
.csharpcode pre { margin: 0em; }
.csharpcode .rem { color: #008000; }
.csharpcode .kwrd { color: #0000ff; }
.csharpcode .str { color: #006080; }
.csharpcode .op { color: #0000c0; }
.csharpcode .preproc { color: #cc6633; }
.csharpcode .asp { background-color: #ffff00; }
.csharpcode .html { color: #800000; }
.csharpcode .attr { color: #ff0000; }
.csharpcode .alt 
{
	background-color: #f4f4f4;
	width: 100%;
	margin: 0em;
}
.csharpcode .lnum { color: #606060; }</style>
<style type="text/css">
<p>.csharpcode, .csharpcode pre
{
	font-size: small;
	color: black;
	font-family: consolas, "Courier New", courier, monospace;
	background-color: #ffffff;
	/*white-space: pre;*/
}
.csharpcode pre { margin: 0em; }
.csharpcode .rem { color: #008000; }
.csharpcode .kwrd { color: #0000ff; }
.csharpcode .str { color: #006080; }
.csharpcode .op { color: #0000c0; }
.csharpcode .preproc { color: #cc6633; }
.csharpcode .asp { background-color: #ffff00; }
.csharpcode .html { color: #800000; }
.csharpcode .attr { color: #ff0000; }
.csharpcode .alt 
{
	background-color: #f4f4f4;
	width: 100%;
	margin: 0em;
}
.csharpcode .lnum { color: #606060; }</style>
<p>Once you have the <strong>DeploymentId</strong> you use it in many of the other commands to setup log collection etc.</p>
<p>To get a list of roles you can grab the RoleInstanceList from the deployment:</p>
<pre class="csharpcode">$roles = (Get-Deployment -ServiceName $serviceName -Certificate $cert -SubscriptionId $subid -Slot Production).RoleInstanceList</pre>
<style type="text/css">
.csharpcode, .csharpcode pre
{
	font-size: small;
	color: black;
	font-family: consolas, "Courier New", courier, monospace;
	background-color: #ffffff;
	/*white-space: pre;*/
}
.csharpcode pre { margin: 0em; }
.csharpcode .rem { color: #008000; }
.csharpcode .kwrd { color: #0000ff; }
.csharpcode .str { color: #006080; }
.csharpcode .op { color: #0000c0; }
.csharpcode .preproc { color: #cc6633; }
.csharpcode .asp { background-color: #ffff00; }
.csharpcode .html { color: #800000; }
.csharpcode .attr { color: #ff0000; }
.csharpcode .alt 
{
	background-color: #f4f4f4;
	width: 100%;
	margin: 0em;
}
.csharpcode .lnum { color: #606060; }</style>
<style type="text/css">
<p>.csharpcode, .csharpcode pre
{
	font-size: small;
	color: black;
	font-family: consolas, "Courier New", courier, monospace;
	background-color: #ffffff;
	/*white-space: pre;*/
}
.csharpcode pre { margin: 0em; }
.csharpcode .rem { color: #008000; }
.csharpcode .kwrd { color: #0000ff; }
.csharpcode .str { color: #006080; }
.csharpcode .op { color: #0000c0; }
.csharpcode .preproc { color: #cc6633; }
.csharpcode .asp { background-color: #ffff00; }
.csharpcode .html { color: #800000; }
.csharpcode .attr { color: #ff0000; }
.csharpcode .alt 
{
	background-color: #f4f4f4;
	width: 100%;
	margin: 0em;
}
.csharpcode .lnum { color: #606060; }</style>
<p>This returns both the role names as well as the instance names.</p>
<p><strong>Note</strong>: There is a cmdlet <strong>Get-DiagnosticAwareRoles</strong> which returns the role names but not the instance names. There is also a <strong>Get-DiagnosticAwareRoleInstances</strong> which returns the instance names as strings. You could use both commands…</p>
<h3>Just Web or Worker roles</h3>
<p>Some diagnostics collection you just want to configure on web roles. I haven’t found a way from the PowerShell cmdlets to return a specific role type, so instead I always make sure my role name has the word “Web” in and use the following:</p>
<pre class="csharpcode">$webroles = $roles | where { $_.RoleName <span class="preproc">-match</span> <span class="str">&quot;Web&quot;</span>}</pre>
<style type="text/css">
<p>.csharpcode, .csharpcode pre
{
	font-size: small;
	color: black;
	font-family: consolas, "Courier New", courier, monospace;
	background-color: #ffffff;
	/*white-space: pre;*/
}
.csharpcode pre { margin: 0em; }
.csharpcode .rem { color: #008000; }
.csharpcode .kwrd { color: #0000ff; }
.csharpcode .str { color: #006080; }
.csharpcode .op { color: #0000c0; }
.csharpcode .preproc { color: #cc6633; }
.csharpcode .asp { background-color: #ffff00; }
.csharpcode .html { color: #800000; }
.csharpcode .attr { color: #ff0000; }
.csharpcode .alt 
{
	background-color: #f4f4f4;
	width: 100%;
	margin: 0em;
}
.csharpcode .lnum { color: #606060; }</style>
<p>I haven’t figured out a better way of doing this, if you do let me know.</p>
<p>Guess how I find worker roles?</p>
<pre class="csharpcode">$workerroles = $roles | where { $_.RoleName <span class="preproc">-notmatch</span> <span class="str">&quot;Web&quot;</span>}</pre>
<style type="text/css">
<p>.csharpcode, .csharpcode pre
{
	font-size: small;
	color: black;
	font-family: consolas, "Courier New", courier, monospace;
	background-color: #ffffff;
	/*white-space: pre;*/
}
.csharpcode pre { margin: 0em; }
.csharpcode .rem { color: #008000; }
.csharpcode .kwrd { color: #0000ff; }
.csharpcode .str { color: #006080; }
.csharpcode .op { color: #0000c0; }
.csharpcode .preproc { color: #cc6633; }
.csharpcode .asp { background-color: #ffff00; }
.csharpcode .html { color: #800000; }
.csharpcode .attr { color: #ff0000; }
.csharpcode .alt 
{
	background-color: #f4f4f4;
	width: 100%;
	margin: 0em;
}
.csharpcode .lnum { color: #606060; }</style>
<p>Anyway, if you have a list of roles and instance names, along with the storage account name and key and the deployment id, you are ready to go!</p>
<h2>Configure the Windows Azure Logs</h2>
<p>To configure the Windows Azure Logs you can use the <strong>Set-WindowsAzureLog</strong> cmdlet:</p>
<pre class="csharpcode">$roles | <span class="kwrd">foreach</span> { Set-WindowsAzureLog -LogLevelFilter <span class="str">&quot;Error&quot;</span> -RoleName $_.RoleName -InstanceId $_.InstanceId -StorageAccountName $SAN -StorageAccountKey $SAK -DeploymentId $did -BufferQuotaInMB 50 -TransferPeriod 5 }</pre>
<style type="text/css">
<p>.csharpcode, .csharpcode pre
{
	font-size: small;
	color: black;
	font-family: consolas, "Courier New", courier, monospace;
	background-color: #ffffff;
	/*white-space: pre;*/
}
.csharpcode pre { margin: 0em; }
.csharpcode .rem { color: #008000; }
.csharpcode .kwrd { color: #0000ff; }
.csharpcode .str { color: #006080; }
.csharpcode .op { color: #0000c0; }
.csharpcode .preproc { color: #cc6633; }
.csharpcode .asp { background-color: #ffff00; }
.csharpcode .html { color: #800000; }
.csharpcode .attr { color: #ff0000; }
.csharpcode .alt 
{
	background-color: #f4f4f4;
	width: 100%;
	margin: 0em;
}
.csharpcode .lnum { color: #606060; }</style>
<p>This will tell the diagnostics agent to copy the logs every 5 minutes. The total amount of data in the local log will not exceed 50MB</p>
<p>To check the configuration was set you have to use the <strong>Get-DiagnosticConfiguration</strong> cmdlet:</p>
<pre class="csharpcode">$roles | <span class="kwrd">foreach</span> {Get-DiagnosticConfiguration -DeploymentId $did -StorageAccountName $SAN -StorageAccountKey $SAK -RoleName $_.RoleName -InstanceId $_.InstanceName -BufferName Logs }</pre>
<h2>Configure the Diagnostics Infrastructure Logs</h2>
<p>To configure collection of the Windows Azure infrastructure logs use the <strong>Set-InfrastructureLog </strong>cmdlet:</p>
<pre class="csharpcode">$roles | <span class="kwrd">foreach</span> { Set-InfrastructureLog -LogLevelFilter <span class="str">&quot;Error&quot;</span> -RoleName $_.RoleName -InstanceId $_.InstanceName -BufferQuotaInMB 50 -TransferPeriod 5 -StorageAccountName $SAN -StorageAccountKey $SAK -DeploymentId $did }</pre>
<style type="text/css">
<p>.csharpcode, .csharpcode pre
{
	font-size: small;
	color: black;
	font-family: consolas, "Courier New", courier, monospace;
	background-color: #ffffff;
	/*white-space: pre;*/
}
.csharpcode pre { margin: 0em; }
.csharpcode .rem { color: #008000; }
.csharpcode .kwrd { color: #0000ff; }
.csharpcode .str { color: #006080; }
.csharpcode .op { color: #0000c0; }
.csharpcode .preproc { color: #cc6633; }
.csharpcode .asp { background-color: #ffff00; }
.csharpcode .html { color: #800000; }
.csharpcode .attr { color: #ff0000; }
.csharpcode .alt 
{
	background-color: #f4f4f4;
	width: 100%;
	margin: 0em;
}
.csharpcode .lnum { color: #606060; }</style>
<p>To check the configuration use:</p>
<pre class="csharpcode">$roles | <span class="kwrd">foreach</span> {Get-DiagnosticConfiguration -DeploymentId $did -StorageAccountName $SAN -StorageAccountKey $SAK -RoleName $_.RoleName -InstanceId $_.InstanceName -BufferName DiagnosticInfrastructureLogs }</pre>
<style type="text/css">
<p>.csharpcode, .csharpcode pre
{
	font-size: small;
	color: black;
	font-family: consolas, "Courier New", courier, monospace;
	background-color: #ffffff;
	/*white-space: pre;*/
}
.csharpcode pre { margin: 0em; }
.csharpcode .rem { color: #008000; }
.csharpcode .kwrd { color: #0000ff; }
.csharpcode .str { color: #006080; }
.csharpcode .op { color: #0000c0; }
.csharpcode .preproc { color: #cc6633; }
.csharpcode .asp { background-color: #ffff00; }
.csharpcode .html { color: #800000; }
.csharpcode .attr { color: #ff0000; }
.csharpcode .alt 
{
	background-color: #f4f4f4;
	width: 100%;
	margin: 0em;
}
.csharpcode .lnum { color: #606060; }</style>
<h2>Configure the Windows Event Logs</h2>
<p>To configure the collection of the Windows Event Logs use you need to first specify which logs to collect. If you just want to collect the Application and System logs, you first need to create an array:</p>
<pre class="csharpcode">$logs = <span class="str">&quot;Application!*&quot;</span>,<span class="str">&quot;System!*&quot;</span></pre>
<style type="text/css">
<p>.csharpcode, .csharpcode pre
{
	font-size: small;
	color: black;
	font-family: consolas, "Courier New", courier, monospace;
	background-color: #ffffff;
	/*white-space: pre;*/
}
.csharpcode pre { margin: 0em; }
.csharpcode .rem { color: #008000; }
.csharpcode .kwrd { color: #0000ff; }
.csharpcode .str { color: #006080; }
.csharpcode .op { color: #0000c0; }
.csharpcode .preproc { color: #cc6633; }
.csharpcode .asp { background-color: #ffff00; }
.csharpcode .html { color: #800000; }
.csharpcode .attr { color: #ff0000; }
.csharpcode .alt 
{
	background-color: #f4f4f4;
	width: 100%;
	margin: 0em;
}
.csharpcode .lnum { color: #606060; }</style>
<p>You can then use this list in the following: </p>
<pre class="csharpcode">$roles | <span class="kwrd">foreach</span> { Set-WAEventLog -EventLogs $logs -LogLevel <span class="str">&quot;Error&quot;</span> -RoleName $_.RoleName -InstanceId $_.InstanceName -BufferQuotaInMB 10 -TransferPeriod 5 -StorageAccountName $SAN -StorageAccountKey $SAK -DeploymentId $did }</pre>
<style type="text/css">
<p>.csharpcode, .csharpcode pre
{
	font-size: small;
	color: black;
	font-family: consolas, "Courier New", courier, monospace;
	background-color: #ffffff;
	/*white-space: pre;*/
}
.csharpcode pre { margin: 0em; }
.csharpcode .rem { color: #008000; }
.csharpcode .kwrd { color: #0000ff; }
.csharpcode .str { color: #006080; }
.csharpcode .op { color: #0000c0; }
.csharpcode .preproc { color: #cc6633; }
.csharpcode .asp { background-color: #ffff00; }
.csharpcode .html { color: #800000; }
.csharpcode .attr { color: #ff0000; }
.csharpcode .alt 
{
	background-color: #f4f4f4;
	width: 100%;
	margin: 0em;
}
.csharpcode .lnum { color: #606060; }</style>
<p>To check the configuration use:</p>
<pre class="csharpcode">$roles | <span class="kwrd">foreach</span> {Get-DiagnosticConfiguration -DeploymentId $did -StorageAccountName $SAN -StorageAccountKey $SAK -RoleName $_.RoleName -InstanceId $_.InstanceName -BufferName WindowsEventLogs }</pre>
<style type="text/css">
<p>.csharpcode, .csharpcode pre
{
	font-size: small;
	color: black;
	font-family: consolas, "Courier New", courier, monospace;
	background-color: #ffffff;
	/*white-space: pre;*/
}
.csharpcode pre { margin: 0em; }
.csharpcode .rem { color: #008000; }
.csharpcode .kwrd { color: #0000ff; }
.csharpcode .str { color: #006080; }
.csharpcode .op { color: #0000c0; }
.csharpcode .preproc { color: #cc6633; }
.csharpcode .asp { background-color: #ffff00; }
.csharpcode .html { color: #800000; }
.csharpcode .attr { color: #ff0000; }
.csharpcode .alt 
{
	background-color: #f4f4f4;
	width: 100%;
	margin: 0em;
}
.csharpcode .lnum { color: #606060; }</style>
<h2>Configuring Performance Counters</h2>
<p>To configure performance counters to be collected, you need to first create one or more <strong>PerformanceCounterConfiguration</strong> objects, then pass them into the <strong>Set-PerformanceCounter</strong> cmdlet.</p>
<p>To create a <strong>PerformanceCounterConfiguration</strong> object use:</p>
<pre class="csharpcode">$cpu_perfcounter = new-object Microsoft.WindowsAzure.Diagnostics.PerformanceCounterConfiguration
$cpu_perfcounter.CounterSpecifier = <span class="str">&quot;\Processor(_Total)\% Processor Time&quot;</span>
$cpu_perfcounter.SampleRate = new TimeSpan(0,5,0)</pre>
<p>For all roles, you should create performance counters for the following:</p>
<ul>
<li>\Processor(_Total)\% Processor Time </li>
<li>\Memory\Available Mbytes </li>
<li>\Memory\Committed Bytes </li>
<li>\Network Interface(*)\Bytes Received/sec </li>
<li>\Network Interface(*)\Bytes Sent/sec </li>
</ul>
<p>For a webrole you should add at least:</p>
<ul>
<li>\ASP.NET Applications(__Total__)\Requests/Sec </li>
</ul>
<p>Once you have created each PerformanceCounterConfiguration object create an array then use the Set-PerformanceCounter cmdlet:</p>
<pre class="csharpcode">$cpu_perfcounter = new-object Microsoft.WindowsAzure.Diagnostics.PerformanceCounterConfiguration
$cpu_perfcounter.CounterSpecifier = <span class="str">&quot;\Processor(_Total)\% Processor Time&quot;</span>
$cpu_perfcounter.SampleRate = $counter_time</pre>
<style type="text/css">
.csharpcode, .csharpcode pre
{
	font-size: small;
	color: black;
	font-family: consolas, "Courier New", courier, monospace;
	background-color: #ffffff;
	/*white-space: pre;*/
}
.csharpcode pre { margin: 0em; }
.csharpcode .rem { color: #008000; }
.csharpcode .kwrd { color: #0000ff; }
.csharpcode .str { color: #006080; }
.csharpcode .op { color: #0000c0; }
.csharpcode .preproc { color: #cc6633; }
.csharpcode .asp { background-color: #ffff00; }
.csharpcode .html { color: #800000; }
.csharpcode .attr { color: #ff0000; }
.csharpcode .alt 
{
	background-color: #f4f4f4;
	width: 100%;
	margin: 0em;
}
.csharpcode .lnum { color: #606060; }</style>
<div class="csharpcode">To view the performance counters, you can use:</div>
<pre class="csharpcode">Get-DiagnosticConfiguration -DeploymentId $did -StorageAccountName $SAN -StorageAccountKey $SAK -RoleName $_.RoleName -InstanceId $_.InstanceName -BufferName PerformanceCounters    </pre>
<p>If you actually want to view the performance counter names and sample times you need to look at the datasources property:</p>
<pre class="csharpcode">(Get-DiagnosticConfiguration -DeploymentId $did -StorageAccountName $SAN -StorageAccountKey $SAK -RoleName $_.RoleName -InstanceId $_.InstanceName -BufferName PerformanceCounters).DataSources</pre>
<style type="text/css">
.csharpcode, .csharpcode pre
{
	font-size: small;
	color: black;
	font-family: consolas, "Courier New", courier, monospace;
	background-color: #ffffff;
	/*white-space: pre;*/
}
.csharpcode pre { margin: 0em; }
.csharpcode .rem { color: #008000; }
.csharpcode .kwrd { color: #0000ff; }
.csharpcode .str { color: #006080; }
.csharpcode .op { color: #0000c0; }
.csharpcode .preproc { color: #cc6633; }
.csharpcode .asp { background-color: #ffff00; }
.csharpcode .html { color: #800000; }
.csharpcode .attr { color: #ff0000; }
.csharpcode .alt 
{
	background-color: #f4f4f4;
	width: 100%;
	margin: 0em;
}
.csharpcode .lnum { color: #606060; }</style>
<h2>Configuring IIS Log Files</h2>
<p>Windows Azure lets you configure the collection of any log files. Typically for a web role you would want to grab the IIS log files. In order to do this, you have to configure a datasource that specifies which folder the log files will be located in. To figure this out, the pattern is:</p>
<pre class="csharpcode">C:\Resources\directory\&lt;DeploymentId&gt;.&lt;RoleName&gt;.DiagnosticStore\LogFiles</pre>
<style type="text/css">
<p>.csharpcode, .csharpcode pre
{
	font-size: small;
	color: black;
	font-family: consolas, "Courier New", courier, monospace;
	background-color: #ffffff;
	/*white-space: pre;*/
}
.csharpcode pre { margin: 0em; }
.csharpcode .rem { color: #008000; }
.csharpcode .kwrd { color: #0000ff; }
.csharpcode .str { color: #006080; }
.csharpcode .op { color: #0000c0; }
.csharpcode .preproc { color: #cc6633; }
.csharpcode .asp { background-color: #ffff00; }
.csharpcode .html { color: #800000; }
.csharpcode .attr { color: #ff0000; }
.csharpcode .alt 
{
	background-color: #f4f4f4;
	width: 100%;
	margin: 0em;
}
.csharpcode .lnum { color: #606060; }</style>
</p>
<p>Which can be constructed using:</p>
<pre class="csharpcode">$logfile = <span class="str">&quot;C:\Resources\directory\&quot; + $did + &quot;</span>.<span class="str">&quot; + $WebRoles[0].RoleName + &quot;</span>.DiagnosticStore\LogFiles&quot;</pre>
<style type="text/css">
<p>.csharpcode, .csharpcode pre
{
	font-size: small;
	color: black;
	font-family: consolas, "Courier New", courier, monospace;
	background-color: #ffffff;
	/*white-space: pre;*/
}
.csharpcode pre { margin: 0em; }
.csharpcode .rem { color: #008000; }
.csharpcode .kwrd { color: #0000ff; }
.csharpcode .str { color: #006080; }
.csharpcode .op { color: #0000c0; }
.csharpcode .preproc { color: #cc6633; }
.csharpcode .asp { background-color: #ffff00; }
.csharpcode .html { color: #800000; }
.csharpcode .attr { color: #ff0000; }
.csharpcode .alt 
{
	background-color: #f4f4f4;
	width: 100%;
	margin: 0em;
}
.csharpcode .lnum { color: #606060; }</style>
<p>Other formats are Failed Request Logs</p>
<pre class="csharpcode">C:\Resources\directory\&lt;DeploymentID&gt;.&lt;RoleName&gt;\FailedReqLogFile</pre>
<p>and Crash Dumps:</p>
<pre class="csharpcode"> C:\Resources\directory\&lt;DeploymentId&gt;.&lt;RoleName&gt;\CrashDumps</pre>
<style type="text/css">
<p>.csharpcode, .csharpcode pre
{
	font-size: small;
	color: black;
	font-family: consolas, "Courier New", courier, monospace;
	background-color: #ffffff;
	/*white-space: pre;*/
}
.csharpcode pre { margin: 0em; }
.csharpcode .rem { color: #008000; }
.csharpcode .kwrd { color: #0000ff; }
.csharpcode .str { color: #006080; }
.csharpcode .op { color: #0000c0; }
.csharpcode .preproc { color: #cc6633; }
.csharpcode .asp { background-color: #ffff00; }
.csharpcode .html { color: #800000; }
.csharpcode .attr { color: #ff0000; }
.csharpcode .alt 
{
	background-color: #f4f4f4;
	width: 100%;
	margin: 0em;
}
.csharpcode .lnum { color: #606060; }</style>
<p>To create the actual datasource, you need to create an instance of DirectoryConfiguration:</p>
<pre class="csharpcode">$iisDirectorySource = new-object -TypeName Microsoft.WindowsAzure.Diagnostics.DirectoryConfiguration
$iisDirectorySource.Path = $logfile
$iisDirectorySource.DirectoryQuotaInMB = 100
$iisDirectorySource.Container = <span class="str">&quot;wad-iis-logfiles&quot;</span></pre>
<style type="text/css">
.csharpcode, .csharpcode pre
{
	font-size: small;
	color: black;
	font-family: consolas, "Courier New", courier, monospace;
	background-color: #ffffff;
	/*white-space: pre;*/
}
.csharpcode pre { margin: 0em; }
.csharpcode .rem { color: #008000; }
.csharpcode .kwrd { color: #0000ff; }
.csharpcode .str { color: #006080; }
.csharpcode .op { color: #0000c0; }
.csharpcode .preproc { color: #cc6633; }
.csharpcode .asp { background-color: #ffff00; }
.csharpcode .html { color: #800000; }
.csharpcode .attr { color: #ff0000; }
.csharpcode .alt 
{
	background-color: #f4f4f4;
	width: 100%;
	margin: 0em;
}
.csharpcode .lnum { color: #606060; }</style>
<style type="text/css">
<p>.csharpcode, .csharpcode pre
{
	font-size: small;
	color: black;
	font-family: consolas, "Courier New", courier, monospace;
	background-color: #ffffff;
	/*white-space: pre;*/
}
.csharpcode pre { margin: 0em; }
.csharpcode .rem { color: #008000; }
.csharpcode .kwrd { color: #0000ff; }
.csharpcode .str { color: #006080; }
.csharpcode .op { color: #0000c0; }
.csharpcode .preproc { color: #cc6633; }
.csharpcode .asp { background-color: #ffff00; }
.csharpcode .html { color: #800000; }
.csharpcode .attr { color: #ff0000; }
.csharpcode .alt 
{
	background-color: #f4f4f4;
	width: 100%;
	margin: 0em;
}
.csharpcode .lnum { color: #606060; }</style>
<p>You can then set the directory sources:</p>
<pre class="csharpcode">$webroles | <span class="kwrd">foreach</span> { Set-FileBasedLog -DirectoriesConfiguration @($iisDirectorySource) -RoleName $_.RoleName -InstanceId $_.InstanceId -BufferQuotaInMB 1024 -TransferPeriod 5 -StorageAccountName $SAN -StorageAccountKey $SAK -DeploymentId $did }</pre>
<style type="text/css">
.csharpcode, .csharpcode pre
{
	font-size: small;
	color: black;
	font-family: consolas, "Courier New", courier, monospace;
	background-color: #ffffff;
	/*white-space: pre;*/
}
.csharpcode pre { margin: 0em; }
.csharpcode .rem { color: #008000; }
.csharpcode .kwrd { color: #0000ff; }
.csharpcode .str { color: #006080; }
.csharpcode .op { color: #0000c0; }
.csharpcode .preproc { color: #cc6633; }
.csharpcode .asp { background-color: #ffff00; }
.csharpcode .html { color: #800000; }
.csharpcode .attr { color: #ff0000; }
.csharpcode .alt 
{
	background-color: #f4f4f4;
	width: 100%;
	margin: 0em;
}
.csharpcode .lnum { color: #606060; }</style>
<p>Phew – made it.</p>
<p>Here is the full script for setting the configuration, followed by a script that will display the configuration:</p>
<pre class="csharpcode"><span class="rem"># TODO: Cert thumbprint of a certificate already installed into the Windows Azure Portal</span>
$thumb = <span class="str">&quot;ENTERTHUMBHERE&quot;</span>
$cert = get-item cert:\CurrentUser\My\$thumb
<span class="rem"># TODO: Subscription Id</span>
$subid = <span class="str">&quot;ENTERSUBIDHERE&quot;</span>
<span class="rem"># TODO: Storage Account Name</span>
$SAN = <span class="str">&quot;ENTERSTORAGEACCOUNTNAMEHERE&quot;</span>
<span class="rem"># TODO: Storage Account Key</span>
$SAK = <span class="str">&quot;ENTERSTORAGEACCOUNTKEYHERE&quot;</span>
<span class="rem"># TODO: Service Name</span>
$serviceName = <span class="str">&quot;ENTERSERVICENAMEHERE&quot;</span>

<span class="rem"># You can leave the remainder of the script alone, will collect some good counters at 5 minute intervals and setup logging of event logs etc.</span>
<span class="rem"># Does not setup Fail Request Logs</span>
<span class="rem"># </span>
<span class="rem"># Logs to collect</span>
$logs = <span class="str">&quot;Application!*&quot;</span>,<span class="str">&quot;System!*&quot;</span>
<span class="rem"># configure performance counters sample TimeSpan (h,m,s) - recommended 5 - 15 minutes</span>
$counter_time = new-object TimeSpan(0,10,0)
<span class="rem"># Configure default collection time (recommended 5-15 minutes)</span>
$transferPeriod = 5

<span class="rem"># performance counters</span>
$cpu_perfcounter = new-object Microsoft.WindowsAzure.Diagnostics.PerformanceCounterConfiguration
$cpu_perfcounter.CounterSpecifier = <span class="str">&quot;\Processor(_Total)\% Processor Time&quot;</span>
$cpu_perfcounter.SampleRate = $counter_time

$mem_available_bytes_perfcounter = New-Object Microsoft.WindowsAzure.Diagnostics.PerformanceCounterConfiguration
$mem_available_bytes_perfcounter.CounterSpecifier = <span class="str">&quot;\Memory\Available Mbytes&quot;</span>
$mem_available_bytes_perfcounter.SampleRate = $counter_time

$mem_committed_bytes_perfcounter = New-Object Microsoft.WindowsAzure.Diagnostics.PerformanceCounterConfiguration
$mem_committed_bytes_perfcounter.CounterSpecifier = <span class="str">&quot;\Memory\Committed Bytes&quot;</span>
$mem_committed_bytes_perfcounter.SampleRate =$counter_time

$asp_app_requests_perfcounter =  New-Object Microsoft.WindowsAzure.Diagnostics.PerformanceCounterConfiguration
$asp_app_requests_perfcounter.CounterSpecifier = <span class="str">&quot;\ASP.NET Applications(__Total__)\Requests/Sec&quot;</span>
$asp_app_requests_perfcounter.SampleRate = $counter_time

$net_received_perfcounter =  New-Object Microsoft.WindowsAzure.Diagnostics.PerformanceCounterConfiguration
$net_received_perfcounter.CounterSpecifier = <span class="str">&quot;\Network Interface(*)\Bytes Received/sec&quot;</span>
$net_received_perfcounter.SampleRate = $counter_time

$net_sent_perfcounter =  New-Object Microsoft.WindowsAzure.Diagnostics.PerformanceCounterConfiguration
$net_sent_perfcounter.CounterSpecifier = <span class="str">&quot;\Network Interface(*)\Bytes Sent/sec&quot;</span>
$net_sent_perfcounter.SampleRate = $counter_time

<span class="rem"># deployment Id</span>
$did = (Get-Deployment -ServiceName $serviceName -Certificate $cert -SubscriptionId $subid -Slot Production).DeploymentId
<span class="rem"># Role List</span>
$roles = (Get-Deployment -ServiceName $serviceName -Certificate $cert -SubscriptionId $subid -Slot Production).RoleInstanceList

<span class="rem">#Web Role List</span>
$webroles = $roles | where { $_.RoleName <span class="preproc">-match</span> <span class="str">&quot;Web&quot;</span>}
<span class="rem">#worker Role List</span>
$workerroles = $roles | where { $_.RoleName <span class="preproc">-notmatch</span> <span class="str">&quot;Web&quot;</span>}

$roles | <span class="kwrd">foreach</span> { Set-WindowsAzureLog -LogLevelFilter <span class="str">&quot;Error&quot;</span> -RoleName $_.RoleName -InstanceId $_.InstanceName -BufferQuotaInMB 50 -TransferPeriod $transferPeriod -StorageAccountName $SAN -StorageAccountKey $SAK -DeploymentId $did}

$roles | <span class="kwrd">foreach</span> { Set-InfrastructureLog -LogLevelFilter <span class="str">&quot;Error&quot;</span> -RoleName $_.RoleName -InstanceId $_.InstanceName -BufferQuotaInMB 50 -TransferPeriod $transferPeriod -StorageAccountName $SAN -StorageAccountKey $SAK -DeploymentId $did }

$logs = <span class="str">&quot;Application!*&quot;</span>,<span class="str">&quot;System!*&quot;</span>
$roles | <span class="kwrd">foreach</span> { Set-WAEventLog -EventLogs $logs -LogLevel <span class="str">&quot;Error&quot;</span> -RoleName $_.RoleName -InstanceId $_.InstanceName -BufferQuotaInMB 10 -TransferPeriod $transferPeriod -StorageAccountName $SAN -StorageAccountKey $SAK -DeploymentId $did }

<span class="rem">#Web Role Specific Configuration</span>
<span class="kwrd">if</span> ($WebRoles <span class="preproc">-ne</span> $null)
{
    $logfile = <span class="str">&quot;C:\Resources\directory\&quot; + $did + &quot;</span>.<span class="str">&quot; + $WebRoles[0].RoleName + &quot;</span>.DiagnosticStore\LogFiles<span class="str">&quot;

    $iisDirectorySource = new-object -TypeName Microsoft.WindowsAzure.Diagnostics.DirectoryConfiguration
    $iisDirectorySource.Path = $logfile
    $iisDirectorySource.DirectoryQuotaInMB = 100
    $iisDirectorySource.Container = &quot;</span>wad-iis-logfiles&quot;

    $webroles | <span class="kwrd">foreach</span> { Set-FileBasedLog -DirectoriesConfiguration @($iisDirectorySource) -RoleName $_.RoleName -InstanceId $_.InstanceId -BufferQuotaInMB 1024 -TransferPeriod 5 -StorageAccountName $SAN -StorageAccountKey $SAK -DeploymentId $did }

    $web_perf_counters = $cpu_perfcounter, $mem_available_bytes_perfcounter, $mem_committed_bytes_perfcounter, $net_received_perfcounter, $net_sent_perfcounter, $asp_app_requests_perfcounter
    $webroles | <span class="kwrd">foreach</span> { Set-PerformanceCounter -PerformanceCounters $web_perf_counters -RoleName $_.RoleName -InstanceId $_.InstanceName -BufferQuotaInMB 10 -TransferPeriod $transferPeriod -StorageAccountName $SAN -StorageAccountKey $SAK -DeploymentId $did }
}

<span class="rem">#Worker Role Specific Configuration</span>
<span class="kwrd">if</span> ($workerroles <span class="preproc">-ne</span> $null)
{
    $worker_perf_counters = $cpu_perfcounter, $mem_available_bytes_perfcounter, $mem_committed_bytes_perfcounter, $net_received_perfcounter, $net_sent_perfcounter
    $workerroles | <span class="kwrd">foreach</span> { Set-PerformanceCounter -PerformanceCounters $worker_perf_counters -RoleName $_.RoleName -InstanceId $_.InstanceName -BufferQuotaInMB 10 -TransferPeriod $transferPeriod -StorageAccountName $SAN -StorageAccountKey $SAK -DeploymentId $did }
}</pre>
<style type="text/css">
.csharpcode, .csharpcode pre
{
	font-size: small;
	color: black;
	font-family: consolas, "Courier New", courier, monospace;
	background-color: #ffffff;
	/*white-space: pre;*/
}
.csharpcode pre { margin: 0em; }
.csharpcode .rem { color: #008000; }
.csharpcode .kwrd { color: #0000ff; }
.csharpcode .str { color: #006080; }
.csharpcode .op { color: #0000c0; }
.csharpcode .preproc { color: #cc6633; }
.csharpcode .asp { background-color: #ffff00; }
.csharpcode .html { color: #800000; }
.csharpcode .attr { color: #ff0000; }
.csharpcode .alt 
{
	background-color: #f4f4f4;
	width: 100%;
	margin: 0em;
}
.csharpcode .lnum { color: #606060; }</style>
<p>The display script:</p>
<pre class="csharpcode"><span class="rem"># TODO: Cert thumbprint of a certificate already installed into the Windows Azure Portal</span>
$thumb = <span class="str">&quot;ENTERTHUMBHERE&quot;</span>
$cert = get-item cert:\CurrentUser\My\$thumb
<span class="rem"># TODO: Subscription Id</span>
$subid = <span class="str">&quot;ENTERSUBIDHERE&quot;</span>
<span class="rem"># TODO: Storage Account Name</span>
$SAN = <span class="str">&quot;ENTERSTORAGEACCOUNTNAMEHERE&quot;</span>
<span class="rem"># TODO: Storage Account Key</span>
$SAK = <span class="str">&quot;ENTERSTORAGEACCOUNTKEYHERE&quot;</span>
<span class="rem"># TODO: Service Name</span>
$serviceName = <span class="str">&quot;ENTERSERVICENAMEHERE&quot;</span>

<span class="rem"># deployment Id</span>
$did = (Get-Deployment -ServiceName $serviceName -Certificate $cert -SubscriptionId $subid -Slot Production).DeploymentId
<span class="rem"># Role List</span>
$roles = (Get-Deployment -ServiceName $serviceName -Certificate $cert -SubscriptionId $subid -Slot Production).RoleInstanceList

$roles | <span class="kwrd">foreach</span> {
    write-host <span class="str">&quot;======================================================&quot;</span>
    write-host $_.RoleName
    write-host $_.InstanceName

    write-host <span class="str">&quot;Event Logs&quot;</span>
    Get-DiagnosticConfiguration -DeploymentId $did -StorageAccountName $SAN -StorageAccountKey $SAK -RoleName $_.RoleName -InstanceId $_.InstanceName -BufferName WindowsEventLogs | out-host

    write-host <span class="str">&quot;Infrastructure Logs&quot;</span>
    Get-DiagnosticConfiguration -DeploymentId $did -StorageAccountName $SAN -StorageAccountKey $SAK -RoleName $_.RoleName -InstanceId $_.InstanceName -BufferName DiagnosticInfrastructureLogs 

    write-host <span class="str">&quot;Logs&quot;</span>
    Get-DiagnosticConfiguration -DeploymentId $did -StorageAccountName $SAN -StorageAccountKey $SAK -RoleName $_.RoleName -InstanceId $_.InstanceName -BufferName Logs 

    write-host <span class="str">&quot;Performance Counters&quot;</span>
    Get-DiagnosticConfiguration -DeploymentId $did -StorageAccountName $SAN -StorageAccountKey $SAK -RoleName $_.RoleName -InstanceId $_.InstanceName -BufferName PerformanceCounters | out-host
    (Get-DiagnosticConfiguration -DeploymentId $did -StorageAccountName $SAN -StorageAccountKey $SAK -RoleName $_.RoleName -InstanceId $_.InstanceName -BufferName PerformanceCounters).DataSources | out-host

    write-host <span class="str">&quot;Directories&quot;</span>
    Get-DiagnosticConfiguration -DeploymentId $did -StorageAccountName $SAN -StorageAccountKey $SAK -RoleName $_.RoleName -InstanceId $_.InstanceName -BufferName Directories | out-host
    (Get-DiagnosticConfiguration -DeploymentId $did -StorageAccountName $SAN -StorageAccountKey $SAK -RoleName $_.RoleName -InstanceId $_.InstanceName -BufferName Directories).DataSources | fl | out-host

    write-host <span class="str">&quot;&quot;</span>
}</pre>
<p>THIS POSTING IS PROVIDED “AS IS” WITH NO WARRANTIES, AND CONFERS NO RIGHTS, EVEN IF YOU HAVE CHOCOLATE</p>
]]></content:encoded>
			<wfw:commentRss>http://www.davidaiken.com/2011/10/18/how-to-easily-enable-windows-azure-diagnostics-remotely/feed/</wfw:commentRss>
		<slash:comments>4</slash:comments>
		</item>
		<item>
		<title>How To Block un-validated Windows Azure Deployments</title>
		<link>http://www.davidaiken.com/2011/10/13/how-to-block-un-validated-windows-azure-deployments/#utm_source=feed&#038;utm_medium=feed&#038;utm_campaign=feed</link>
		<comments>http://www.davidaiken.com/2011/10/13/how-to-block-un-validated-windows-azure-deployments/#comments</comments>
		<pubDate>Thu, 13 Oct 2011 22:23:06 +0000</pubDate>
		<dc:creator>theDavidAiken</dc:creator>
				<category><![CDATA[Windows Azure]]></category>
		<category><![CDATA[Tip]]></category>

		<guid isPermaLink="false">http://www.davidaiken.com/2011/10/13/how-to-block-un-validated-windows-azure-deployments/</guid>
		<description><![CDATA[One of the great things about the 1.4/1.5 SDK tools is the validation that is now performed on Windows Azure packages. This makes it easy to check before you deploy things like missing dependencies. As an example, here is a project warning generated when a dependency is not set to be copied  [...]]]></description>
			<content:encoded><![CDATA[<p>One of the great things about the 1.4/1.5 SDK tools is the validation that is now performed on Windows Azure packages. This makes it easy to check before you deploy things like missing dependencies. As an example, here is a project warning generated when a dependency is not set to be copied local.</p>
<p><a href="http://www.davidaiken.com/wp-content/uploads/2011/10/image.png#utm_source=feed&amp;utm_medium=feed&amp;utm_campaign=feed"><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="image" border="0" alt="image" src="http://www.davidaiken.com/wp-content/uploads/2011/10/image_thumb.png" width="575" height="139" /></a></p>
<p>One thing that always annoyed me is that it is a warning and not an error. I may have in the past deployed packages that failed, just because I wasn’t looking at the errors.</p>
<p>However you can actually have these warnings block your deployment by setting the “Treat warnings as errors” option on your Windows Azure project to true. (Tip: right click your Windows Azure project, click properties, then click Development.)</p>
<p><a href="http://www.davidaiken.com/wp-content/uploads/2011/10/image1.png#utm_source=feed&amp;utm_medium=feed&amp;utm_campaign=feed"><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="image" border="0" alt="image" src="http://www.davidaiken.com/wp-content/uploads/2011/10/image_thumb1.png" width="293" height="193" /></a></p>
<p>Which changes the warnings to errors:</p>
<p><a href="http://www.davidaiken.com/wp-content/uploads/2011/10/image2.png#utm_source=feed&amp;utm_medium=feed&amp;utm_campaign=feed"><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="image" border="0" alt="image" src="http://www.davidaiken.com/wp-content/uploads/2011/10/image_thumb2.png" width="578" height="181" /></a></p>
<p>Awesome.</p>
<p>THIS POSTING IS PROVIDED “AS IS” WITH NO WARRANTIES, AND CONFERS NO RIGHTS OR DANCING CATS</p>
]]></content:encoded>
			<wfw:commentRss>http://www.davidaiken.com/2011/10/13/how-to-block-un-validated-windows-azure-deployments/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>Running Azure startup tasks as a real user</title>
		<link>http://www.davidaiken.com/2011/01/19/running-azure-startup-tasks-as-a-real-user/#utm_source=feed&#038;utm_medium=feed&#038;utm_campaign=feed</link>
		<comments>http://www.davidaiken.com/2011/01/19/running-azure-startup-tasks-as-a-real-user/#comments</comments>
		<pubDate>Thu, 20 Jan 2011 01:40:10 +0000</pubDate>
		<dc:creator>theDavidAiken</dc:creator>
				<category><![CDATA[Windows Azure]]></category>
		<category><![CDATA[Startup Tasks]]></category>
		<category><![CDATA[Tip]]></category>

		<guid isPermaLink="false">http://www.davidaiken.com/2011/01/19/running-azure-startup-tasks-as-a-real-user/</guid>
		<description><![CDATA[In my post about enabling PowerShell. I mentioned I got blocked for a while and would explain later why and what happened.
Problem: Windows Azure runs startup tasks as localsystem. Some startup tasks need to be running in the context of a user.
Solution: Use the task scheduler in Windows Server to  [...]]]></description>
			<content:encoded><![CDATA[<p>In my post about enabling PowerShell. I mentioned I got blocked for a while and would explain later why and what happened.</p>
<p>Problem: Windows Azure runs startup tasks as localsystem. Some startup tasks need to be running in the context of a user.</p>
<p>Solution: Use the task scheduler in Windows Server to execute the command.</p>
<p>A few people have already asked how to apply the technique to other things so here goes.</p>
<p>Lets take a look at the original startup task I was trying to execute.</p>
<div id="codeSnippetWrapper">
<div style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; background-color: #f4f4f4; border-left-style: none; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &#39;Courier New&#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; border-right-style: none; font-size: 8pt; overflow: visible; padding-top: 0px" id="codeSnippet">
<pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; background-color: white; margin: 0em; border-left-style: none; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &#39;Courier New&#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; border-right-style: none; font-size: 8pt; overflow: visible; padding-top: 0px">netsh advfirewall firewall add rule name=<span style="color: #006080">&quot;Windows Remote Management (HTTP-In)&quot;</span> dir=<span style="color: #0000ff">in</span> action=allow service=any enable=yes profile=any localport=5985 protocol=tcp</pre>
<p><!--CRLF--></p>
<pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; background-color: #f4f4f4; margin: 0em; border-left-style: none; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &#39;Courier New&#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; border-right-style: none; font-size: 8pt; overflow: visible; padding-top: 0px">Powershell -Command Enable-PSRemoting -Force</pre>
<p><!--CRLF--></div>
</div>
<style type="text/css">
.csharpcode, .csharpcode pre
{
	font-size: small;
	color: black;
	font-family: consolas, "Courier New", courier, monospace;
	background-color: #ffffff;
	/*white-space: pre;*/
}
.csharpcode pre { margin: 0em; }
.csharpcode .rem { color: #008000; }
.csharpcode .kwrd { color: #0000ff; }
.csharpcode .str { color: #006080; }
.csharpcode .op { color: #0000c0; }
.csharpcode .preproc { color: #cc6633; }
.csharpcode .asp { background-color: #ffff00; }
.csharpcode .html { color: #800000; }
.csharpcode .attr { color: #ff0000; }
.csharpcode .alt 
{
	background-color: #f4f4f4;
	width: 100%;
	margin: 0em;
}
.csharpcode .lnum { color: #606060; }</style>
<p>This doesn’t work because the powershell command “Enable-PSRemoting” doesn’t work unless it runs as an elevated user that belongs to the administrators group. Localsystem doesn’t belong to this group.</p>
<p>In my original blog post, I showed how you could enable this using winrm. But sometimes you want this something to happen when the role starts.</p>
<p>To make a task run as a user account as a startup task simply create a new task for the Windows Scheduler to execute as shown below.</p>
<div id="codeSnippetWrapper">
<div style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; background-color: #f4f4f4; border-left-style: none; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &#39;Courier New&#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; border-right-style: none; font-size: 8pt; overflow: visible; padding-top: 0px" id="codeSnippet">
<pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; background-color: white; margin: 0em; border-left-style: none; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &#39;Courier New&#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; border-right-style: none; font-size: 8pt; overflow: visible; padding-top: 0px">netsh advfirewall firewall add rule name=<span style="color: #006080">&quot;Windows Remote Management (HTTP-In)&quot;</span> dir=<span style="color: #0000ff">in</span> action=allow service=any enable=yes profile=any localport=5985 protocol=tcp</pre>
<p><!--CRLF--></p>
<pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; background-color: #f4f4f4; margin: 0em; border-left-style: none; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &#39;Courier New&#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; border-right-style: none; font-size: 8pt; overflow: visible; padding-top: 0px">&#160;</pre>
<p><!--CRLF--></p>
<pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; background-color: white; margin: 0em; border-left-style: none; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &#39;Courier New&#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; border-right-style: none; font-size: 8pt; overflow: visible; padding-top: 0px">net user scheduser Secr3tC0de /add</pre>
<p><!--CRLF--></p>
<pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; background-color: #f4f4f4; margin: 0em; border-left-style: none; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &#39;Courier New&#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; border-right-style: none; font-size: 8pt; overflow: visible; padding-top: 0px">net localgroup Administrators scheduser /add</pre>
<p><!--CRLF--></p>
<pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; background-color: white; margin: 0em; border-left-style: none; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &#39;Courier New&#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; border-right-style: none; font-size: 8pt; overflow: visible; padding-top: 0px">&#160;</pre>
<p><!--CRLF--></p>
<pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; background-color: #f4f4f4; margin: 0em; border-left-style: none; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &#39;Courier New&#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; border-right-style: none; font-size: 8pt; overflow: visible; padding-top: 0px">schtasks /CREATE /TN <span style="color: #006080">&quot;EnablePS-Remoting&quot;</span> /SC ONCE /SD 01/01/2020 /ST 00:00:00 /RL HIGHEST /RU scheduser /RP Secr3tC0de /TR <span style="color: #006080">&quot;powershell -Command Enable-PSRemoting -Force&quot;</span> /F</pre>
<p><!--CRLF--></p>
<pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; background-color: white; margin: 0em; border-left-style: none; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &#39;Courier New&#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; border-right-style: none; font-size: 8pt; overflow: visible; padding-top: 0px">schtasks /RUN /TN <span style="color: #006080">&quot;EnablePS-Remoting&quot;</span></pre>
<p><!--CRLF--></div>
</div>
<style type="text/css">
.csharpcode, .csharpcode pre
{
	font-size: small;
	color: black;
	font-family: consolas, "Courier New", courier, monospace;
	background-color: #ffffff;
	/*white-space: pre;*/
}
.csharpcode pre { margin: 0em; }
.csharpcode .rem { color: #008000; }
.csharpcode .kwrd { color: #0000ff; }
.csharpcode .str { color: #006080; }
.csharpcode .op { color: #0000c0; }
.csharpcode .preproc { color: #cc6633; }
.csharpcode .asp { background-color: #ffff00; }
.csharpcode .html { color: #800000; }
.csharpcode .attr { color: #ff0000; }
.csharpcode .alt 
{
	background-color: #f4f4f4;
	width: 100%;
	margin: 0em;
}
.csharpcode .lnum { color: #606060; }</style>
<p>Works like a charm. Hopefully you can figure out how to run your own commands instead of PowerShell.</p>
<p>It is safe to say that you probably want to secure the username and password that is created. I think ideally a wrapper that can read a username and encrypted password from config, create all the scheduled tasks and then execute them. Maybe that is a job for next time.</p>
<p>THIS POSTING IS PROVIDED “AS IS” WITH NO WARRANTIES, AND CONFERS NO RIGHTS</p>
]]></content:encoded>
			<wfw:commentRss>http://www.davidaiken.com/2011/01/19/running-azure-startup-tasks-as-a-real-user/feed/</wfw:commentRss>
		<slash:comments>3</slash:comments>
		</item>
		<item>
		<title>address is not the same as Address</title>
		<link>http://www.davidaiken.com/2010/05/04/address-is-not-the-same-as-address/#utm_source=feed&#038;utm_medium=feed&#038;utm_campaign=feed</link>
		<comments>http://www.davidaiken.com/2010/05/04/address-is-not-the-same-as-address/#comments</comments>
		<pubDate>Tue, 04 May 2010 18:17:16 +0000</pubDate>
		<dc:creator>theDavidAiken</dc:creator>
				<category><![CDATA[Windows Azure]]></category>
		<category><![CDATA[Tip]]></category>

		<guid isPermaLink="false">http://www.davidaiken.com/2010/05/04/address-is-not-the-same-as-address/</guid>
		<description><![CDATA[When using Windows Azure table storage – keep in mind the property names are case sensitive!
Yesterday one of our developers was working on refactoring some code. As is standard practice, they changed the class properties on the table storage entity classes from a lower case address to an upper  [...]]]></description>
			<content:encoded><![CDATA[<p>When using Windows Azure table storage – keep in mind the property names are case sensitive!</p>
<p>Yesterday one of our developers was working on refactoring some code. As is standard practice, they changed the class properties on the table storage entity classes from a lower case address to an upper case Address. This worked fine in the developer fabric, but when we pushed to the cloud the app broke. Upon investigation it turned out each entity now had an address property as well as the new Address property.</p>
<p>Easy fix, we changed everything back to lower case.</p>
<p>THIS POSTING IS PROVIDED “AS IS” WITH NO WARRANTIES, AND CONFERS NO RIGHTS EVEN IF YOU HAVE A NOTE FROM YOUR MUM</p>
]]></content:encoded>
			<wfw:commentRss>http://www.davidaiken.com/2010/05/04/address-is-not-the-same-as-address/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>

