Description : In this post how to retrive queue message from azure using c#. here same steps for get message in my previous post of how to get message from azure using c#
Step 1 : Downlod below NuGet package for add message using c#. Install both package one by one in your project use NuGet console or NuGet package managerr
- WindowsAzure.Storage
- WindowsAzure.ConfigurationManager
Step 2 : Get your connection string from Azure. Go to Azure Portal
Go to Storage Account -> Click on your storage account -> Inside Setting Click on Access keys -> In this window select Copy connection string. your connection string look like below
- DefaultEndpointsProtocol=https;AccountName=YourStorageAccountName;AccountKey=YourStorageAccountKey
Step 3 : Create class for add json message in azure queue using c#
public class ResponseClass
{
public string id { get; set; }
public string name { get; set; }
}
Step 3 : Write below code for retrive queue from azure using c#
string ConnectionString = "DefaultEndpointsProtocol=https;AccountName=YourStorageAccountName;AccountKey=YourStorageAccountKey"
CloudStorageAccount account = CloudStorageAccount.Parse(ConnectionString); // Cloud Storage Account
CloudQueueClient queueClient = account.CreateCloudQueueClient(); // Queue Client Create
CloudQueue messageQueue = queueClient.GetQueueReference("YourAzureQueueName"); // Get Queue Reference
// this line for retrive 10 messages from azure queue
List<CloudQueueMessage> retrievedMessage = messageQueue.GetMessages(10).ToList();
using for loop one by one get queue response like below code
for (int i = 0; i < retrievedMessage.Count; i++)
{
string Message = retrievedMessage[i].AsString;
string ID = retrievedMessage[i].Id;
string PopReceipt = retrievedMessage[i].PopReceipt; // this PopReceipt use for delete queue
JsonResponse obj = Newtonsoft.Json.JsonConvert.DeserializeObject<ResponseClass>(Message);
}
Step 1 : Downlod below NuGet package for add message using c#. Install both package one by one in your project use NuGet console or NuGet package managerr
- WindowsAzure.Storage
- WindowsAzure.ConfigurationManager
Step 2 : Get your connection string from Azure. Go to Azure Portal
Go to Storage Account -> Click on your storage account -> Inside Setting Click on Access keys -> In this window select Copy connection string. your connection string look like below
- DefaultEndpointsProtocol=https;AccountName=YourStorageAccountName;AccountKey=YourStorageAccountKey
Step 3 : Create class for add json message in azure queue using c#
public class ResponseClass
{
public string id { get; set; }
public string name { get; set; }
}
Step 3 : Write below code for retrive queue from azure using c#
string ConnectionString = "DefaultEndpointsProtocol=https;AccountName=YourStorageAccountName;AccountKey=YourStorageAccountKey"
CloudStorageAccount account = CloudStorageAccount.Parse(ConnectionString); // Cloud Storage Account
CloudQueueClient queueClient = account.CreateCloudQueueClient(); // Queue Client Create
CloudQueue messageQueue = queueClient.GetQueueReference("YourAzureQueueName"); // Get Queue Reference
// this line for retrive 10 messages from azure queue
List<CloudQueueMessage> retrievedMessage = messageQueue.GetMessages(10).ToList();
using for loop one by one get queue response like below code
for (int i = 0; i < retrievedMessage.Count; i++)
{
string Message = retrievedMessage[i].AsString;
string ID = retrievedMessage[i].Id;
string PopReceipt = retrievedMessage[i].PopReceipt; // this PopReceipt use for delete queue
JsonResponse obj = Newtonsoft.Json.JsonConvert.DeserializeObject<ResponseClass>(Message);
}
No comments:
Post a Comment