Skip to content

Instantly share code, notes, and snippets.

@MoimHossain

MoimHossain/MessageClient.cs Secret

Created Jul 15, 2018
Embed
What would you like to do?
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
You can’t perform that action at this time.