Zend_Service_WindowsAzure_Storage_Blob

Zend_Service_WindowsAzure_Diagnostics_Manager

Blob Storage stores sets of binary data. Blob storage offers the following three Windows Azure Diagnostics enables you to collect diagnostic data from a service running in Windows Azure. It can be used for tasks like debugging and troubleshooting, measuring performance, monitoring resource usage, traffic analysis, capacity planning, and auditing. Once collected, diagnostic data can be transferred to a Windows Azure storage account for persistence. Transfers can either be scheduled or on-demand.

You can configure Windows Azure Diagnostics from code running within a role. You can also configure it remotely from an application running outside of the Windows Azure; for example, you can manage Windows Azure Diagnostics from a custom dashboard application running locally. By managing Windows Azure Diagnostics remotely, you can start your service with an initial diagnostic configuration, and then tweak that configuration from code running outside of your service, without having to upgrade your service.

More information on which logs, performance counters, crash dumps, ... can be monitored can be found on the » corresponding MSDN web page.

Note: Diagnostics are configured on a per-role basis. This means that each role should be configured separately. Specifying diagnostics instructions for one role instance does not imply this configuration is loaded on other role instances.

Note: Diagnostics are configured on a per-role basis. This means that each The Diagnostics API in the Windows Azure SDK for PHP can only be used when the DiagnosticsMonitor has been started during role startup. Currently, this is only supported when an application is packaged with the Windows Azure Command-line Tools for PHP Developers.

API Examples

This topic lists some examples of using the Zend_Service_WindowsAzure_Diagnostics_Manager class. Other features are available in the download package, as well as a detailed API documentation of those features.

Checking if a diagnostics configuration for the current role instance exists

Using the following code, you can check if a diagnostics configuration for the current role instance exists.

Example #1 Checking if a diagnostics configuration for the current role instance exists

  1. /** Zend_Service_WindowsAzure_Storage_Blob */
  2. require_once 'Zend/Service/WindowsAzure/Storage/Blob.php';
  3.  
  4. /** Zend_Service_WindowsAzure_Diagnostics_Manager */
  5. require_once 'Zend/Service/WindowsAzure/Diagnostics/Manager.php';
  6.  
  7. $storageClient = new Zend_Service_WindowsAzure_Storage_Blob();
  8. $manager = new Zend_Service_WindowsAzure_Diagnostics_Manager($storageClient);
  9.  
  10. $configurationExists = $manager->configurationForCurrentRoleInstanceExists();
  11.  
  12. echo 'The configuration ' . ($configurationExists ? 'exists' : 'does not exist';

Loading the current role instance diagnostics configuration

Using the following code, you can load the current role instance diagnostics configuration.

Example #2 Loading the current role instance diagnostics configuration

  1. /** Zend_Service_WindowsAzure_Storage_Blob */
  2. require_once 'Zend/Service/WindowsAzure/Storage/Blob.php';
  3.  
  4. /** Zend_Service_WindowsAzure_Diagnostics_Manager */
  5. require_once 'Zend/Service/WindowsAzure/Diagnostics/Manager.php';
  6.  
  7. $storageClient = new Zend_Service_WindowsAzure_Storage_Blob();
  8. $manager = new Zend_Service_WindowsAzure_Diagnostics_Manager($storageClient);
  9.  
  10. $configuration = $manager->getConfigurationForCurrentRoleInstance();

Storing the current role instance diagnostics configuration

Using the following code, you can store the current role instance diagnostics configuration.

Example #3 Storing the current role instance diagnostics configuration

  1. /** Zend_Service_WindowsAzure_Storage_Blob */
  2. require_once 'Zend/Service/WindowsAzure/Storage/Blob.php';
  3.  
  4. /** Zend_Service_WindowsAzure_Diagnostics_Manager */
  5. require_once 'Zend/Service/WindowsAzure/Diagnostics/Manager.php';
  6.  
  7. $storageClient = new Zend_Service_WindowsAzure_Storage_Blob();
  8. $manager = new Zend_Service_WindowsAzure_Diagnostics_Manager($storageClient);
  9.  
  10. $configuration = // ...;
  11. $manager->setConfigurationForCurrentRoleInstance($configuration);

Subscribing to a performance counter

Using the following code, you can subscribe to a performance counter.

Example #4 Subscribing to a performance counter

  1. /** Zend_Service_WindowsAzure_Storage_Blob */
  2. require_once 'Zend/Service/WindowsAzure/Storage/Blob.php';
  3.  
  4. /** Zend_Service_WindowsAzure_Diagnostics_Manager */
  5. require_once 'Zend/Service/WindowsAzure/Diagnostics/Manager.php';
  6.  
  7. $storageClient = new Zend_Service_WindowsAzure_Storage_Blob();
  8. $manager = new Zend_Service_WindowsAzure_Diagnostics_Manager($storageClient);
  9.  
  10. $configuration = $manager->getConfigurationForCurrentRoleInstance();
  11.  
  12. // Subscribe to \Processor(*)\% Processor Time
  13. $configuration->DataSources->PerformanceCounters->addSubscription('\Processor(*)\% Processor Time', 1);
  14.  
  15. $manager->setConfigurationForCurrentRoleInstance($configuration);

Getting the current role instance id

The current role instance id is defined in the server variable RdRoleId. It will only be available when the application is run in Development Fabric or Windows Azure Fabric.

Example #5 Getting the current role instance id

  1. echo 'The role instance id is ' . $_SERVER['RdRoleId'];

Zend_Service_WindowsAzure_Storage_Blob