Windows Azure Developer and Project Guidance
Monitoring Options
Windows Azure is a cloud services operating system that serves as the development, service hosting and service management environment for the Windows Azure platform. Windows Azure provides developers with on-demand compute and storage to host, scale, and manage web applications on the internet through Microsoft datacenters.
Diagnostic API (Diagnostic Data Collection)
A separate storage account will be created to store diagnostic data, ensuring that application and monitoring data is separated and can be accessed independently.
The Windows Azure Web and Worker roles must be instrumented to enable collection for the Windows Azure diagnostic data sources shown below
Data Source | Windows Azure platform setting | Details | Stored On |
Windows Azure logs | Enabled | · Requires that trace listener be added to web.config or application.config: <system.diagnostics> · The ScheduledTransferPeriod is set to 1 minute. · The Windows Azure diagnostics agent filter verbosity level will be set for Warning (and higher). | WADLogsTable (table) |
Windows event logs | Enabled | · Events from application and system event logs · The ScheduledTransferPeriod is set to 1 minute. · The Windows Azure diagnostics agent filter verbosity level will be set for Warning (and higher). | WADWindowsEventLogsTable (table) |
IIS 7.0 Logs | Enabled | · The ScheduledTransferPeriod is set to 10 minutes. | wad-iis-logfiles (blob container) |
IIS7 Failed Request logs | Enabled | · Enable tracing for all failed requests with status codes 400–599 under the system.webServer section of the role's web.config file. · The ScheduledTransferPeriod is set to 10 minutes. | wad-iis-failedreqlogfiles (blob container) |
Performance counters | Enabled | · Enable logging for performance counters. · Set the SampleRate and ScheduledTransferPeriod to 5 minutes. | WADPerformanceCountersTable (table) |
Azure Storage Guidance and Policies
A separate storage account is created to store diagnostic data. The diagnostic data stored in Windows Azure storage is used for monitoring as well as to create application baselines.
Data Source | Windows Azure platform setting | Retention period | Stored On |
Windows Azure logs | Enabled | 1 week | WADLogsTable (table) |
Windows event logs | Enabled | 1 month | WADWindowsEventLogsTable (table) |
IIS 7.0 Logs | Enabled | 1 week | wad-iis-logfiles (blob container) |
IIS7 Failed Request logs | Enabled | 1 week | wad-iis-failedreqlogfiles (blob container) |
Performance counters | Enabled | 1 month | WADPerformanceCountersTable (table) |
For some data sources, the size of the data can be estimated in advance (performance counters); for other sources (Microsoft Internet Information Services [IIS} logs), it cannot.
These are the minimal retention requirements; they can be change based on business or operational requirements.
Application-specific data is not stored in the same store as the diagnostic data and is not subject to this policy.
Enable Windows Azure Diagnostics Data Sources
The Windows Azure diagnostic monitor runs in Windows Azure and collects data locally for the role instance. The DiagnosticMonitor class provides methods for working with the diagnostic monitor from code running within a role.
To initialize the diagnostic monitor, override the RoleEntryPoint.OnStart method. Within this method, call the DiagnosticMonitor.Start method to start the diagnostic monitor.
The code in the following example starts the diagnostic monitor with the default initial configuration. The default initial configuration collects the Windows Azure, Windows Azure Diagnostic Infrastructure, and IIS 7.0 logs:
Code snippet:
public override bool OnStart()
{
//Get Default Config
DiagnosticMonitorConfiguration config = DiagnosticMonitor.GetDefaultInitialConfiguration();
//Windows Performance Counters
List<string> counters = new List<string>();
counters.Add(@"\Processor(_Total)\% Processor Time");
counters.Add(@"\Memory\Available Mbytes");
counters.Add(@"\TCPv4\Connections Established");
counters.Add(@"\ASP.NET Applications(__Total__)\Requests/Sec");
counters.Add(@"\Network Interface(*)\Bytes Received/sec");
counters.Add(@"\Network Interface(*)\Bytes Sent/sec");
foreach (string counter in counters)
{
PerformanceCounterConfiguration counterConfig = new PerformanceCounterConfiguration();
counterConfig.CounterSpecifier = counter;
counterConfig.SampleRate = TimeSpan.FromMinutes(5);
config.PerformanceCounters.DataSources.Add(counterConfig);
}
config.PerformanceCounters.ScheduledTransferPeriod = TimeSpan.FromMinutes(5);
//Windows Event Logs
config.WindowsEventLog.DataSources.Add("System!*");
config.WindowsEventLog.DataSources.Add("Application!*");
config.WindowsEventLog.ScheduledTransferPeriod = TimeSpan.FromMinutes(1);
config.WindowsEventLog.ScheduledTransferLogLevelFilter = LogLevel.Warning;
//Azure Trace Logs
config.Logs.ScheduledTransferPeriod = TimeSpan.FromMinutes(1);
config.Logs.ScheduledTransferLogLevelFilter = LogLevel.Warning;
//Crash Dumps
CrashDumps.EnableCollection(true);
//IIS Logs
config.Directories.ScheduledTransferPeriod=TimeSpan.FromMinutes(10);
DiagnosticMonitor.Start("DiagnosticsConnectionString", config);
// For information on handling configuration changes
// see the MSDN topic at http://go.microsoft.com/fwlink/?LinkId=166357.
RoleEnvironment.Changing += RoleEnvironmentChanging;
return base.OnStart();
}
Using the TraceSource to Log Events
Configuration file sections (configure the Windows Azure trace listener for this specific trace source)
<system.diagnostics>
<sources>
<source name="MyTraceSource" switchName="sourceSwitch" switchType="System.Diagnostics.SourceSwitch">
<listeners>
<add type="Microsoft.WindowsAzure.Diagnostics.DiagnosticMonitorTraceListener, Microsoft.WindowsAzure.Diagnostics, Version=1.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35" name="AzureDiagnostics">
<filter type="" />
</add>
</listeners>
</source>
</sources>
<switches>
<add name="sourceSwitch" value="Warning"/>
</switches>
</system.diagnostics>
C# code (use the TraceSource to log events)
public static class Logging
{
private static TraceSource Ts = new TraceSource("MyTraceSource", SourceLevels.Warning);
public static void Write(TraceEventType traceType, int eventId, string message)
{
//Log event
Ts.TraceEvent(traceType, eventId, message);
}
}
Web.Config Setting for Failed Request Tracing
<tracing>
<traceFailedRequests>
<add path="*">
<traceAreas>
<add provider="ASP" verbosity="Verbose" />
<add provider="ASPNET" areas="Infrastructure,Module,Page,AppServices" verbosity="Verbose" />
<add provider="ISAPI Extension" verbosity="Verbose" />
<add provider="WWW Server" areas="Authentication,Security,Filter,StaticFile,CGI,Compression,Cache,RequestNotifications,Module" verbosity="Verbose" />
</traceAreas>
<failureDefinitions statusCodes="400-599" />
</add>
</traceFailedRequests>
</tracing>
For Details on Implementation, Refer

