1

I'm creating Azure resource manager template with ServiceBus, queue and couple shared access rules. I'm creating the namespace and the queue correctly but when I try to add authorization rule I get:

Resource Microsoft.ServiceBus/namespaces/authorizationRules 'myservicebusnamespace/SendOnlyKey' failed with message 'Request payload is not in the expected format.

First of all is this possible? There's no samples out there and do documentation either..

Since this is quite generic message I was wondering if anyone else has encountered similar issues using ARM Template for creating Queues? This is what I have so far:

{
  "$schema": "https://schema.management.azure.com/schemas/2015-01-01/deploymentTemplate.json#",
  "contentVersion": "1.0.0.0",
  "parameters": {
    "sbNamespace": {
      "type": "string",
      "metadata": {
        "description": "The service bus namespace"
      }
    }
  },
  "variables": {
    "location": "[resourceGroup().location]",
    "sbVersion": "[providers('Microsoft.ServiceBus', 'namespaces').apiVersions[0]]",
    "queueName": "testQueue",
    "defaultSASKeyName": "RootManageSharedAccessKey",
    "authRuleResourceId": "[resourceId('Microsoft.ServiceBus/namespaces/authorizationRules', parameters('sbNamespace'), variables('defaultSASKeyName'))]",
    "sendAuthRuleResourceId": "[resourceId('Microsoft.ServiceBus/namespaces/authorizationRules', parameters('sbNamespace'), 'SendOnlyKey')]",
    "keyGeneratorTemplateUri": "https://raw.githubusercontent.com/sjkp/Azure.ARM.ServiceBus/master/Azure.ARM.ServiceBus/Templates/keygenerator.json"
  },
  "resources": [
    {
      "apiVersion": "2015-01-01",
      "name": "primaryKey",
      "type": "Microsoft.Resources/deployments",
      "properties": {
        "mode": "incremental",
        "templateLink": {
          "uri": "[variables('keyGeneratorTemplateUri')]",
          "contentVersion": "1.0.0.0"
        },
        "parameters": {
          "seed": { "value": "1234a5" }
        }
      }
    },
    {
      "apiVersion": "2015-01-01",
      "name": "secondaryKey",
      "type": "Microsoft.Resources/deployments",
      "properties": {
        "mode": "incremental",
        "templateLink": {
          "uri": "[variables('keyGeneratorTemplateUri')]",
          "contentVersion": "1.0.0.0"
        },
        "parameters": {
          "seed": { "value": "ac34a5" }
        }
      }
    },
    {
      //namespace
      "apiVersion": "[variables('sbVersion')]",
      "name": "[parameters('sbNamespace')]",
      "type": "Microsoft.ServiceBus/namespaces",
      "location": "[variables('location')]",
      "properties": {
        "messagingSku": 2
      },
      "resources": [
        {
          //queue
          "apiVersion": "[variables('sbVersion')]",
          "name": "[variables('queueName')]",
          "type": "Queues",
          "dependsOn": [
            "[concat('Microsoft.ServiceBus/namespaces/', parameters('sbNamespace'))]"
          ],
          "properties": {
            "path": "[variables('queueName')]",
            "defaultMessageTimeToLive": "14.0:0:0",
            "maxQueueSizeInMegaBytes": "1024",
            "maxDeliveryCount": "10"
          }
        }
        ,{
          //auth rule 1
          "apiVersion": "[variables('sbVersion')]",
          "name": "[concat(parameters('sbNamespace'),'/SendOnlyKey')]",
          "type": "Microsoft.ServiceBus/namespaces/authorizationRules",
          "dependsOn": [
            "[concat('Microsoft.ServiceBus/namespaces/', parameters('sbNamespace'))]",
            "[concat('Microsoft.Resources/deployments/', 'primaryKey')]",
            "[concat('Microsoft.Resources/deployments/', 'secondaryKey')]"
          ],
          "location": "[variables('location')]",
          "properties": {
            "keyName": "SendOnlyKey",
            "PrimaryKey": "[reference('primaryKey').outputs.key.value]",
            "SecondaryKey": "[reference('secondaryKey').outputs.key.value]"
          }
        }
      ]
    }
  ],
  "outputs": {
    "NamespaceDefaultConnectionString": {
      "type": "string",
      "value": "[listkeys(variables('authRuleResourceId'), variables('sbVersion')).primaryConnectionString]"
    }
  }
}
Milen
  • 8,697
  • 7
  • 43
  • 57

2 Answers2

1

Sounds like something is failing with the sub template that should generate the keys.

Could you try to generate they keys with e.g. powershell instead:

$bytes = New-Object Byte[] 32
$rand = [System.Security.Cryptography.RandomNumberGenerator]::Create()
$rand.GetBytes($bytes)
$rand.Dispose()
$key = [System.Convert]::ToBase64String($bytes)

To see if that fixes the error.

sjkp
  • 885
  • 6
  • 16
  • It could also be the claimType that is wrong. If you are not making a authorizationRule with Send Rights only you should use, claimType: "SharedAccessKey" – sjkp Dec 20 '15 at 17:30
  • Just had a look at the new file ServiceBusQueues.json in your GitHub repo - looks like what I need, thanks. – Milen Dec 21 '15 at 10:29
0

Difficult stuff, that's for sure. Have a look at

Community
  • 1
  • 1
Sascha Gottfried
  • 3,303
  • 20
  • 30
  • I've been using the first link as a source for my investigations. Unfortunately there's not a lot of information out there (I think the ServiceBus provider is in beta at the moment) – Milen Dec 18 '15 at 16:35