Search code examples
azureservicebusazure-servicebus-subscriptions

Parsing JSON in an Azure Service Bus rule


I am trying to add a rule on a subscription on Azure service bus. The payload of the message looks like this:

{
  header: {
    // a bunch of data
  },
  body: {
    type: "payment",
    // a bunch of data
  }
}

Using New-AzureRMServiceBusRule to create a new rule, i get a 400 error when i try to add "body.type = 'payment'". If I just use "type = 'payment'" everything is fine, but the standard library my client uses forces everything into its own envelope structure.

Is there a way to parse a JSON payload in a service bus rule?


Solution

  • Azure Service Bus rules only operate on headers. If you'd like to evaluate things from the payload/body, you will have to promote those into custom/user headers.

    An FYI, if you're filtering based on equality, Correlation filters is much more efficient than SQL filters.