Intro

In my current project we use Azure Resource Manager (ARM) templates to help with deployments across multiple subscriptions and environments. One of the elements of the ARM template is adding a couple of Shared Access Policies to enable Read and Write on the queues we have in place. The policies have been defined on Service Bus level because they span multiple queues.

Our ARM template functioned just fine, (automated) deployment was up & running and life was beautiful. Until our automated deployment to our development environment triggered in the night of January 24th. Our ARM template, not having been changed for a while, suddenly errored out with a Bad Request. The message read:

Request payload is not in the expected format.

Searching for the issue

We checked everything: API versions (still version 2015-08-01, so no changes there), variables we introduced (no changes there) and parameters. We even stripped out all dynamic behavior just to be sure that wasn’t the cause. And it wasn’t.

The offending part of the ARM template (the one that had functioned before) looked like this:
{
    "apiVersion": "2015-08-01",
    "name": "[concat(variables('servicebus_namespace_name'), '/', 'RoleName')]",
    "type": "Microsoft.ServiceBus/namespaces/authorizationRules",
    "dependsOn": [
"[concat('Microsoft.ServiceBus/namespaces/', variables('servicebus_namespace_name'))]"
     ],
    "location": "[variables('location')]",
    "properties": {
        "Rights": [
            //"Send",
            "Listen"
            //"Manage"
]
}
}

I found an article Create a Service Bus authorization rule for namespace and queue using an Azure Resource Manager template. One of the things in that article is an exmple, that also holds a piece of template to create an Authorization Rule on Service Bus level:

{
    "apiVersion": "[variables('sbVersion')]",
    "name": "[variables('namespaceAuthRuleName')]",
    "type": "Microsoft.ServiceBus/namespaces/authorizationRules",
    "dependsOn": ["[concat('Microsoft.ServiceBus/namespaces/', parameters('serviceBusNamespaceName'))]"],
    "location": "[resourceGroup().location]",
    "properties": {
        "Rights": ["Send"]
}
}

I put the two parts next to each other and started removing all differences between the two. Spacing, newlines… I made sure everything matched. And what do you know? The damned thing worked.

Several tries (and failures) later, I now know what caused our ARM template to fail. It were the comments in the Rights element.

Solution

In the end, the only thing I had to do to get our template working again was remove the comments in the Rights element. I did try with several different comments (with and without a comma in there, for instance) but the comments I tried all made the template fail. As said earlier, the template worked earlier, including the comments. The fact that there are comments all over the place in our ARM template makes it even stranger…

Hope this helps.