Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
Workaround for Azure Webjobs in development machine.
public static void Main(string[] args)
{
#if DEBUG
GetJobsFromQueue();
#else
var host = new JobHost();
host.RunAndBlock();
#endif
}
private static void GetJobsFromQueue()
{
Log("Getting Load jobs from queue...");
var storageAccount = CloudStorageAccount.Parse(CloudConfigurationManager.GetSetting("StorageConnectionString"));
var queueClient = storageAccount.CreateCloudQueueClient();
var queue = queueClient.GetQueueReference("loadqueue");
var retrievedMessage = queue.GetMessage();
if (retrievedMessage == null)
{
return;
}
Log($"Retrieved message with content '{retrievedMessage.AsString}'");
ProcessMessage(retrievedMessage.AsString);
queue.DeleteMessage(retrievedMessage);
Log("Deleted message");
}
public static void ProcessQueueMessage([QueueTrigger("loadqueue")] string inputText, TextWriter logger)
{
if (logger != null)
{
_logger = logger;
}
ProcessMessage(inputText);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment