Skip to content

Instantly share code, notes, and snippets.

@MoimHossain
Created July 15, 2018 16:56
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save MoimHossain/41ba02d12fdf42baf04367b42a7f406e to your computer and use it in GitHub Desktop.
Save MoimHossain/41ba02d12fdf42baf04367b42a7f406e to your computer and use it in GitHub Desktop.
MessageClient.cs
public class MessageClient
{
public MessageClient()
{
}
public virtual async Task SendAsync(string message)
{
var cq = await GetQueueClient();
await cq.AddMessageAsync(new CloudQueueMessage(message));
}
private static async Task<CloudQueue> GetQueueClient( )
{
var keys = await new StorageAccountHelper().GetStorageKeysAsync();
var storageCredentials =
new StorageCredentials(Constants.StorageAccountName, keys.Keys.First().Value);
var csa = new CloudStorageAccount(storageCredentials, true);
var cqc = csa.CreateCloudQueueClient();
var cq = cqc.GetQueueReference(Constants.QueueName);
await cq.CreateIfNotExistsAsync();
return cq;
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment