Created
September 10, 2015 20:29
-
-
Save gweinhold/58f4e928378ab6329a3f to your computer and use it in GitHub Desktop.
Workaround for Azure Webjobs in development machine.
This file contains hidden or 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 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