Export (0) Print
Expand All

Configuring Diagnostics for Azure Cloud Services and Virtual Machines

Updated: December 10, 2014

When you need to troubleshoot an Azure cloud service or Azure virtual machine, you can configure Azure diagnostics more easily by using Visual Studio. Azure diagnostics captures system data and logging data on the virtual machines and virtual machine instances that run your cloud service and brings transfers that data into your storage account. You can also access Azure Diagnostics programmatically and by editing configuration files directly. See Collect Logging Data by Using Azure Diagnostics for more information.

You can configure Azure Diagnostics in the following ways:

  • Use the diagnostics configuration dialog box in Visual Studio or directly modify the configuration files. The configuration file, diagnostics.wadcfg (for Azure SDK 2.4 or earlier) or diagnostics.wadcfgx (for Azure SDK 2.5), is added to your project.

    If you use this method, your configuration changes take effect the next time you deploy the cloud service to Azure or run the service in the emulator.

  • By using Server Explorer to change the diagnostics settings for a running cloud service or virtual machine.

This topic has the following sections.

If you're upgrading your project from Azure SDK 2.4 to Azure SDK 2.5, you should bear in mind the following diagnostics functionality differences.

  • Emulators aren't fully supported – You can't use diagnostics with the local emulators. Tracing statements will appear locally in the Output window, but they aren't transferred to Azure storage.

  • Configuration APIs are deprecated – Programmatic configuration of diagnostics is available in Azure SDK 2.4 or earlier versions, but is deprecated in Azure SDK 2.5. If your diagnostics configuration is currently defined in code, you'll need to reconfigure those settings from scratch in the migrated project in order for diagnostics to keep working. The diagnostics configuration file for Azure SDK 2.4 is diagnostics.wadcfg, and diagnostics.wadcfgx for Azure SDK 2.5.

  • Diagnostics for cloud service applications can only be configured at the role level, not at the instance level anymore.

  • Every time you deploy your app, the diagnostics configuration is updated – This can cause parity issues if you change your diagnostics configuration from Server Explorer and then redeploy your app.

  • In Azure SDK 2.5, crash dumps are configured in the diagnostics configuration file, not in code – If you have crash dumps configured in code, you'll have to manually transfer the configuration from code to the configuration file, because the crash dumps aren't transferred during the migration to Azure 2.5.

In Visual Studio, you can choose to collect diagnostics data for roles that run in Azure, when you run the service in the emulator before deploying it. All changes to diagnostics settings in Visual Studio are saved in the diagnostics.wadcfg configuration file in Azure SDK 2.4 or earlier and in diagnostics.wadcfgx in Azure SDK 2.5. These settings are used when you deploy your cloud service.

You can run the service in the emulator and use diagnostics in Azure SDK 2.4 and earlier versions. In Azure SDK 2.5, you can still enable diagnostics before deployment and the configuration will be saved in the diagnostics.wadcfgx file.

  1. On the shortcut menu for the role that interests you, choose Properties, and then choose the Configuration tab in the role’s Properties window.

  2. In the Diagnostics section, make sure that the Enable Diagnostics check box is selected.

    Accessing the Enable Diagnostics option
  3. Choose the Configure button to view the Diagnostics configuration dialog box.

    Each tab (except for General and Log Directories) represents a diagnostic data source that you can collect.

    Choose Custom plan, then the Edit button

    The default tab, General, offers you the following diagnostics data collection options: Errors only, All information, and Custom plan. The default option, Errors only, takes the least amount of storage because it doesn’t transfer warnings or tracing messages. The All information option transfers the most information and is, therefore, the most expensive option.

  4. For this example, select the Custom plan option so you can customize the data collected.

  5. Choose the Configure button to specify the storage account in which you want to collect the diagnostics data.

  6. The Disk Quota in MB box specifies how much space you want to allocate in your storage account for diagnostics data. You can change the default value if you want.

  7. On each tab of diagnostics data you want to collect, select its Enable Transfer of check box.

    For example, if you want to collect application logs, select the Enable transfer of Application Logs check box on the Application Logs tab. Also, specify any other information required by each diagnostics data type. See the section Configure diagnostics data sources later in this topic for configuration information on each tab.

  8. After you’ve enabled collection of all the diagnostics data you want, choose the OK button.

  9. Run your project in Visual Studio as usual. As you use your application, the log information that you enabled is saved to your Azure storage.

In Visual Studio, you can choose to collect diagnostics data for Azure virtual machines.

  1. In Server Explorer, choose the Azure node and then connect to your Azure subscription, if you're not already connected.

  2. Expand the Virtual Machines node. You can create a new virtual machine, or select one that's already there.

  3. On the shortcut menu for the virtual machine that interests you, choose Configure. This shows the virtual machine configuration dialog box.

    Configuring an Azure virtual machine
  4. In the Installed Extensions list, choose the Select an available extension drop-down menu and then choose Microsoft Monitoring Agent Diagnostics.

    Installing an Azure virtual machine extension
  5. Choose the Add button to view the Diagnostics configuration dialog box.

  6. Choose the Configure button to specify a storage account and then choose the OK button.

    Each tab (except for General and Log Directories) represents a diagnostic data source that you can collect.

    Choose Custom plan, then the Edit button

    The default tab, General, offers you the following diagnostics data collection options: Errors only, All information, and Custom plan. The default option, Errors only, takes the least amount of storage because it doesn’t transfer warnings or tracing messages. The All information option transfers the most information and is, therefore, the most expensive option.

  7. For this example, select the Custom plan option so you can customize the data collected.

  8. Choose the Configure button to specify the storage account in which you want to collect the diagnostics data.

  9. The Disk Quota in MB box specifies how much space you want to allocate in your storage account for diagnostics data. You can change the default value if you want.

  10. On each tab of diagnostics data you want to collect, select its Enable Transfer of check box.

    For example, if you want to collect application logs, select the Enable transfer of Application Logs check box on the Application Logs tab. Also, specify any other information required by each diagnostics data type. See the section Configure diagnostics data sources later in this topic for configuration information on each tab.

  11. After you’ve enabled collection of all the diagnostics data you want, choose the OK button.

  12. Save the updated project.

    You'll see a message in the Microsoft Azure Activity Log window that the virtual machine had been updated.

After you enable diagnostics data collection, you can choose exactly what data sources you want to collect and what information is collected. The following is a list of tabs in the Diagnostics configuration dialog box and what each configuration option means.

Application logs contain diagnostics information produced by a web application. If you want to capture application logs, select the Enable transfer of Application Logs check box. You can increase or decrease the number of minutes when the application logs are transferred to your storage account by changing the Transfer Period (min) value. You can also change the amount of information captured in the log by setting the Log level value. For example, you can choose Verbose to get more information or choose Critical to only capture critical errors. If you have a specific diagnostics provider that emits application logs, you can capture them by adding the provider’s GUID to the Provider GUID box.

Application Logs

See Enable diagnostic logging for Azure Websites for more information about application logs.

If you want to capture Windows event logs, select the Enable transfer of Windows Event Logs check box. You can increase or decrease the number of minutes when the event logs are transferred to your storage account by changing the Transfer Period (min) value. Select the check boxes for the types of events that you want to track. These categories correspond to the filters in the Windows Event Viewer.

Event Logs

If you want to specify a custom data source, you can add it to the WindowsEventLog section of the diagnostics.wadcfgx file, such as in the following example.

<WindowsEventLog scheduledTransferPeriod="PT1M">
   <DataSource name="Application!*" />
   <DataSource name="CustomDataSource!*" />
</WindowsEventLog>

Performance counter information can help you locate system bottlenecks and fine-tune system and application performance. See Create and Use Performance Counters in an Azure Application for more information. If you want to capture performance counters, select the Enable transfer of Performance Counters check box. You can increase or decrease the number of minutes when the event logs are transferred to your storage account by changing the Transfer Period (min) value. Select the check boxes for the performance counters that you want to track.

Performance Counters

To track a performance counter that isn’t listed, enter it by using the suggested syntax and then choose the Add button. The operating system on the virtual machine determines which performance counters you can track. For more information about syntax, see Specifying a Counter Path.

If you want to capture infrastructure logs, which contain information about the Azure diagnostic infrastructure, the RemoteAccess module, and the RemoteForwarder module, select the Enable transfer of Infrastructure Logs check box. You can increase or decrease the number of minutes when the logs are transferred to your storage account by changing the Transfer Period (min) value.

Diagnostics Infrastructure Logs

See Collect Logging Data by Using Azure Diagnostics for more information.

If you want to capture log directories, which contain data collected from log directories for Internet Information Services (IIS) requests, failed requests, or folders that you choose, select the Enable transfer of Log Directories check box. You can increase or decrease the number of minutes when the logs are transferred to your storage account by changing the Transfer Period (min) value.

You can select the boxes of the logs you want to collect, such as IIS Logs and Failed Request Logs. Default storage container names are provided, but you can change the names if you want.

Also, you can capture logs from any folder. Just specify the path in the Log from Absolute Directory section and then choose the Add Directory button. The logs will be captured to the specified containers.

Log Directories

If you use Event Tracing for Windows (ETW) and want to capture ETW logs, select the Enable transfer of ETW Logs check box. You can increase or decrease the number of minutes when the logs are transferred to your storage account by changing the Transfer Period (min) value.

The events are captured from event sources and event manifests that you specify. To specify an event source, enter a name in the Event Sources section and then choose the Add Event Source button. Similarly, you can specify an event manifest in the Event Manifests section and then choose the Add Event Manifest button.

ETW logs

The ETW framework is supported in ASP.NET through classes in the System.Diagnostics namespace. The Microsoft.WindowsAzure.Diagnostics namespace, which inherits from and extends standard System.Diagnostics classes, enables the use of System.Diagnostics as a logging framework in the Azure environment. For more information, see Take Control of Logging and Tracing in Microsoft Azure and Enabling Diagnostics in Azure Cloud Services and Virtual Machines.

If you want to capture information about when a role instance crashes, select the Enable transfer of Crash Dumps check box. (Because ASP.NET handles most exceptions, this is generally useful only for worker roles.) You can increase or decrease the percentage of storage space devoted to the crash dumps by changing the Directory Quota (%) value. You can change the storage container where the crash dumps are stored, and you can select whether you want to capture a Full or Mini dump.

The processes currently being tracked are listed. Select the check boxes for the processes that you want to capture. To add another process to the list, enter the process name and then choose the Add Process button.

Crash dumps

See Take Control of Logging and Tracing in Microsoft Azure for more information.

After you’ve collected the diagnostics data for a cloud service or a virtual machine, you can view it.

  1. Deploy your cloud service as usual and then run it.

  2. You can view the diagnostics data in either a report that Visual Studio generates or tables in your storage account. To view the data in a report, open Server Explorer, open the shortcut menu of the node for the role that interests you, and then choose View Diagnostic Data.

    View Diagnostics Data

    A report that shows the available data appears.

    Windows Azure Diagnostics Report in Visual Studio

    If the most recent data doesn't appear, you might have to wait for the transfer period to elapse.

    Choose the Refresh button to update the data in real time.

    In Server Explorer, open the storage account that's associated with the deployment.

  3. Open the diagnostics tables in the table viewer, and then review the data that you collected. For IIS logs and custom logs, you can open a blob container. By reviewing the following table, you can find the table or blob container that contains the data that interests you. In addition to the data for that log file, the table entries contain EventTickCount, DeploymentId, Role, and RoleInstance to help you identify what virtual machine and role generated the data and when.

     

    Diagnostic data Description Location

    Application Logs

    Logs that your code generates by calling methods of the System.Diagnostics.Trace class.

    WADLogsTable

    Event Logs

    This data is from the Windows event logs on the virtual machines. Windows stores information in these logs, but applications and services also use them to report errors or log information.

    WADWindowsEventLogsTable

    Performance Counters

    You can collect data on any performance counter that’s available on the virtual machine. The operating system provides performance counters, which include many statistics such as memory usage and processor time.

    WADPerformanceCountersTable

    Infrastructure Logs

    These logs are generated from the diagnostics infrastructure itself.

    WADDiagnosticInfrastructureLogsTable

    IIS Logs

    These logs record web requests. If your cloud service gets a significant amount of traffic, these logs can be quite lengthy, so you should collect and store this data only when you need it.

    You can find failed-request logs in the blob container under wad-iis-failedreqlogs under a path for that deployment, role, and instance. You can find complete logs under wad-iis-logfiles. Entries for each file are made in the WADDirectories table.

    Crash dumps

    This information provides binary images of your cloud service’s process (typically a worker role).

    wad-crush-dumps blob container

    Custom log files

     

    You can specify in code the location of custom log files in your storage account. For example, you can specify a custom blob container.

  4. If data of any type is truncated, you can try increasing the buffer for that data type or shortening the interval between transfers of data from the virtual machine to your storage account.

  5. (optional) Purge data from the storage account occasionally to reduce overall storage costs.

  6. When you do a full deployment, the .wadcfg/.wadcfgx file is updated in Azure, and your cloud service picks up any changes to your diagnostics configuration. If you, instead, update an existing deployment, the .wadcfg/.wadcfgx file isn’t updated in Azure. You can still change diagnostics settings, though, by following the steps in the next section. For more information about performing a full deployment and updating an existing deployment, see Publish Azure Application Wizard.

  1. On the shortcut menu for the virtual machine, choose View Diagnostics Data.

    View diagnostics data in Azure virtual machine

    This opens the Diagnostics summary window.

    Azure virtual machine diagnostics summary

If you're investigating a problem with a cloud service that already running, you might want to collect data that you didn't specify before you originally deployed the role. In this case, you can start to collect that data by using the settings in Server Explorer. You can configure diagnostics for either a single instance or all the instances in a role, depending on whether you open the Diagnostics Configuration dialog box from the shortcut menu for the instance or the role. If you configure the role node, any changes apply to all instances. If you configure the instance node, any changes apply to that instance only.

  1. In Server Explorer, expand the Cloud Services node, and then expand nodes to locate the role or instance that you want to investigate or both.

    Configuring Diagnostics
  2. On the shortcut menu for an instance node or a role node, choose Update Diagnostics Settings, and then choose the diagnostic settings that you want to collect.

    For information about the configuration settings, see the previous procedure in this topic.

  3. On the shortcut menu for the role or instance, choose View Diagnostics Data.

    A report shows the available data.

    Windows Azure Diagnostics Report in Visual Studio

    If the most recent data doesn't appear, you might have to wait for the transfer period to elapse.

    Choose the Refresh button to update the data in real time. You can also open the storage account that your cloud service uses, and watch for the data that you collected to appear in tables or blob containers. You might have to refresh the tables to see the most recent data.

If you change data collection in Server Explorer, these changes remain in effect until you fully redeploy your cloud service. If you use the default publish settings, the changes are not overwritten, since the default publish setting is to update the existing deployment, rather than do a full redeployment. To make sure the settings clear at deployment time, go to the Advanced Settings tab in the Publish Wizard, and clear the Deployment update checkbox. When you redeploy with that checkbox cleared, the settings revert to those in the .wadcfg/.wadcfgx file (as set through the Properties editor for the role). If you update your deployment, Azure keeps the old settings.

If you experience problems with your cloud service projects, such as a role that gets stuck in a "busy" status, repeatedly recycles, or throws an internal server error, there are tools and techniques you can use to diagnose and fix these problems. For specific examples of common problems and solutions, as well as an overview of the concepts and tools used to diagnose and fix such errors, see Windows Azure PaaS Compute Diagnostics Data.

What if I have competing diagnostics configuration in code, in an application from outside my organization, or in the diagnostics.wadcfg/.wadcfgx file? Which information is used?

The diagnostics data that you set in the role designer, before deployment, changes the diagnostics.wadcfg/.wadcfgx file. You can further customize the collection of data by editing that file directly. Azure copies this configuration file to a Azure blob resource that's named wad-control-container under the deploymentID, role name, and role instance. Azure loads this configuration file from the blob container when your cloud service starts its diagnostic monitor. You can also use the APIs for Azure Diagnostics to control diagnostics in code, which overrides the configuration settings in diagnostics.wadcfg/.wadcfgx. However, these runtime changes are lost whenever a role restarts. You can also affect diagnostic configuration at runtime by using Server Explorer or writing your own utility that manages diagnostics configuration by using the diagnostic management APIs directly. Because these changes affect the configuration file in the blob container, they persist when a role restarts. For information about how to use each type of configuration and their precedence, see Collect Logging Data by Using Azure Diagnostics.

What is the buffer size, and how large should it be?

On each virtual machine instance, quotas limit how much diagnostic data can be stored on the local file system. In addition, you specify a buffer size for each type of diagnostic data that's available. This buffer size acts like an individual quota for that type of data. By checking the bottom of the dialog box, you can determine the overall quota and the amount of memory that remains. If you specify larger buffers or more types of data, you'll approach the overall quota. You can change the overall quota by modifying the diagnostics.wadcfg/.wadcfgx configuration file. The diagnostics data is stored on the same filesystem as your application’s data, so if your application uses a lot of disk space, you shouldn’t increase the overall diagnostics quota.

What is the transfer period, and how long should it be?

The transfer period is the amount of time that elapses between data captures. After each transfer period, data is moved from the local filesystem on a virtual machine to tables in your storage account. If the amount of data that's collected exceeds the quota before the end of a transfer period, older data is discarded. You might want to decrease the transfer period if you're losing data because your data exceeds the buffer size or the overall quota.

What time zone are the time stamps in?

The time stamps are in the local time zone of the data center that hosts your cloud service.

How do I manage costs when collecting diagnostic information?

The default settings (Log level set to Error and transfer period set to 1 minute) are designed to minimize cost. Your compute costs will increase if you collect more diagnostic data or decrease the transfer period. Don’t collect more data than you need, and don’t forget to disable data collection when you no longer need it. You can always enable it again, even at runtime, as the previous section shows.

How do I collect failed-request logs from IIS?

By default, IIS doesn’t collect failed-request logs. You can configure IIS to collect them if you edit the web.config file for your web role.

I’m not getting trace information from RoleEntryPoint methods like OnStart. What’s wrong?

The methods of RoleEntryPoint are called in the context of WAIISHost.exe, not IIS. Therefore, the configuration information in web.config that normally enables tracing doesn’t apply. To resolve this issue, add a .config file to your web role project, and name the file to match the output assembly that contains the RoleEntryPoint code. In the default web role project, the name of the .config file would be WAIISHost.exe.config. Then add the following lines to this file:

<system.diagnostics>
    <trace>
        <listeners>
            <add name “AzureDiagnostics” type=”Microsoft.WindowsAzure.Diagnostics.DiagnosticMonitorTraceListener”>
                <filter type=”” />
            </add>
        </listeners>
    </trace>
</system.diagnostics>

Now, in the Properties window, set the Copy to Output Directory property to Copy always.

Show:
© 2014 Microsoft