azureazure-storage-queuesazure-scheduler

Azure scheduler: Add JSON message to Azure Storage Queue


I created a scheduler that runs at a specific time and inserts a JSON message into a storage queue. The JSON message is fixed, I put it in the BODY field (which says text/plain) during scheduler setup. The message is:

{ "action": "SendReminderMessages" }

On the receiver side (a WebJob), I poll the queue and then try to deserialize the JSON in these messages. Instead of the expected JSON above, I get the JSON message wrapped in an XML message:

<?xml version="1.0" encoding="utf-16"?>
<StorageQueueMessage xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
  <ExecutionTag>(Some Hex String)</ExecutionTag>
  <ClientRequestId>(Some GUID)</ClientRequestId>
  <ExpectedExecutionTime>2015-09-17T07:00:00</ExpectedExecutionTime>
  <SchedulerJobId>reminder-mails</SchedulerJobId>
  <SchedulerJobCollectionId>scheduler-jobs</SchedulerJobCollectionId>
  <Region>West Europe</Region>
  <Message>{ "action": "SendReminderMessages" }</Message>
</StorageQueueMessage>

How do I send the JSON message as-is, i.e. without the envelope?


Solution

  • Scheduler currently adds an XML wrapper to the body as a means to pass the job metadata. You can use the StorageQueueMessage class (under Microsoft.WindowsAzure.Scheduler.Models) from the Scheduler SDK that would properly deserialize the message. You can vote for the Azure Scheduler feature to add the ability to not include the wrapper on our Azure Scheduler User Voice forum.