FormatExcpetion from Azure Webjobs Host

Question!

Understand this is pre-release :)

When trying to use QueueInput in Azure WebJobs and sticking the hex string of a hash in the message.

public System.Guid GetOwner(CloudQueueMessage msg) 

Looking at ilspy seems like it is trying to parse out $AzureJobsParentId and the JSON parser is throwing the exception I can get around it by encoding my hash in a JSON snippet but I'd prefer not to. Is this a known bug?



Answers
[QueueInput] will normally use JSON.Net to deserialize the queue message payload to the parameter type. So if the queue message is not JSON, you'll get a exception (which should then be wrapped in something more friendly).

You can also work around it by using a string parameter with [QueueInput], like:

    public static void Function([QueueInput] string testqueue)
    {
    }

For string parameter, the SDK will give you the QueueMessage.AsString directly, without any JSON serialization.

FYI, $AzureJobsParentId is a special field placed on json payloads that identifies which function instance enqueued a message. This gets used when you enqueue a message with [QueueOutput]. You can then view that relationship in the SDK dashboard (http://blogs.msdn.com/b/jmstall/archive/2014/01/27/getting-a-dashboard-for-local-development-with-the-webjobs-sdk.aspx)

By : Mike S


This video can help you solving your question :)
By: admin