Share via


OnDemandTransferInfo.FromQueueMessage Method (String)

 

Creates an OnDemandTransferInfo object from queue messages sent by a diagnostic monitor when an on-demand transfer completes.

Namespace:   Microsoft.WindowsAzure.Diagnostics.Management
Assembly:  Microsoft.WindowsAzure.Diagnostics (in Microsoft.WindowsAzure.Diagnostics.dll)

Syntax

public static OnDemandTransferInfo FromQueueMessage(
    string queueMessage
)
public:
static OnDemandTransferInfo^ FromQueueMessage(
    String^ queueMessage
)
static member FromQueueMessage : 
        queueMessage:string -> OnDemandTransferInfo
Public Shared Function FromQueueMessage (
    queueMessage As String
) As OnDemandTransferInfo

Parameters

Return Value

Type: Microsoft.WindowsAzure.Diagnostics.Management.OnDemandTransferInfo

Returns OnDemandTransferInfo.

Remarks

The FromQueueMessage method creates an OnDemandTransferInfo object from the queue notification message sent by a diagnostic monitor when an on-demand transfer completes. Using this method does not remove the message from the queue, it must be removed manually.

Example

The following code snippet reads the queue where on-demand transfer information is stored, creates an OnDemandTransferInfo object using the FromQueueMessage method, and outputs the contents to the console.

// Get the connection string. It's recommended that you store the connection string in your web.config or app.config file.
// Use the ConfigurationManager type to retrieve your storage connection string.  You can find the account name and key in
// the Windows Azure classic portal (https://manage.windowsazure.com).
//string connectionString = "DefaultEndpointsProtocol=https;AccountName=<AccountName>;AccountKey=<AccountKey>";
string connectionString = System.Configuration.ConfigurationManager.ConnectionStrings["StorageConnectionString"].ConnectionString;

CloudStorageAccount storageAccount = CloudStorageAccount.Parse(connectionString);

// Create a CloudQueueClient and get the queue where notifications are stored.
CloudQueueClient cloudQueueClient = storageAccount.CreateCloudQueueClient();
CloudQueue notificationQueue = cloudQueueClient.GetQueueReference("wad-on-demand-transfers");

// Stores the resulting on-demand transfer information.
OnDemandTransferInfo transferInfo;

// If the on-demand transfer queue exists, then process the queue message.
if (null != notificationQueue.GetMessage())
{
   CloudQueueMessage notificationMessage = notificationQueue.GetMessage();

   // Create a new OnDemandTransferInfo object from the notification message.
   transferInfo = OnDemandTransferInfo.FromQueueMessage(notificationMessage.AsString);

   // Write the values of the OnDemandTransferInfo to the console.
   Console.WriteLine("DeploymentId = " + transferInfo.DeploymentId);
   Console.WriteLine("NotificationQueueName = " + transferInfo.NotificationQueueName);
   Console.WriteLine("RequestId = " + transferInfo.RequestId);
   Console.WriteLine("RoleInstanceId = " + transferInfo.RoleInstanceId);
   Console.WriteLine("RoleName = " + transferInfo.RoleName);
}

Warning

This API is not supported in Azure SDK versions 2.5 and higher. Instead, use the diagnostics.wadcfg XML configuration file. For more information, see Collect Logging Data by Using Azure Diagnostics.

See Also

OnDemandTransferInfo Class
Microsoft.WindowsAzure.Diagnostics.Management Namespace

Return to top