-
-
Save johndownskloud/6831ab0224236e088a18543d147f5028 to your computer and use it in GitHub Desktop.
Azure Function - Queue Monitor (v1)
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
#r "Microsoft.WindowsAzure.Storage" | |
using System; | |
using Microsoft.WindowsAzure.Storage; | |
public static void Run(TimerInfo myTimer, TraceWriter log) | |
{ | |
log.Info($"C# Timer trigger function executed at: {DateTime.Now}"); | |
// connect to Azure Storage | |
var connectionString = System.Configuration.ConfigurationManager.AppSettings["AzureWebJobsStorage"]; | |
var account = CloudStorageAccount.Parse(connectionString); | |
var queueClient = account.CreateCloudQueueClient(); | |
// check the length of each queue | |
var queueNames = new string[] { "processorders", "processorders-poison" }; | |
foreach (var queueName in queueNames) | |
{ | |
// get a reference to the queue and retrieve the queue length | |
var queue = queueClient.GetQueueReference(queueName); | |
queue.FetchAttributes(); | |
var length = queue.ApproximateMessageCount; | |
// log the length | |
log.Info($"{queueName}: {length}"); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment