MessageClient.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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