johnstaveley
johnstaveley

Reputation: 1499

Set Access key of service bus in Arm Template

I have trying to set up the access keys to an azure service bus in an azure resource manager template. No matter what I do the template ignores the keys and sets some random ones instead without giving any errors. I have the following parameters file:

{
  "$schema": "https://schema.management.azure.com/schemas/2015-01-01/deploymentParameters.json#",
  "contentVersion": "1.0.0.0",
  "parameters": {
    "environmentName": { "value": "Integration" },
    "primaryKey": {
      "value": "<myKey1>"
    },
    "secondaryKey": {
      "value": "<myKey2>"
    }
  }
}

where myKey are substitued the real value of the keys. I also have the following template (part of it below):

{
  "$schema": "https://schema.management.azure.com/schemas/2015-01-01/deploymentTemplate.json#",
  "contentVersion": "1.0.0.0",
  "parameters": {
    "environmentName": {
      "type": "string"
    },
    "primaryKey": {
      "type": "string"
    },
    "secondaryKey": {
      "type": "string"
    }
  },
  "variables": {
    "ServiceBus_ReadWriteKey": "[concat(parameters('environmentName'), '/ReadWrite')]",
    "servicebus_namespace": "[parameters('environmentName')]",
    "servicebus_topic_name": "[concat(parameters('environmentName'), '/products')]",

This is the resource that creates the access policy and should set it's keys:

{
      "type": "Microsoft.ServiceBus/namespaces/AuthorizationRules",
      "name": "[variables('ServiceBus_ReadWriteKey')]",
      "apiVersion": "2015-08-01",
      "scale": null,
      "properties": {
        "keyName": "ReadWrite",
        "claimType": "SharedAccessKey",
        "claimValue": "None",
        "primaryKey": "[parameters('primaryKey')]",
        "secondaryKey": "[parameters('secondaryKey')]",
        "rights": [
          "Listen",
          "Send"
        ],
        "revision": -1
      },
      "dependsOn": [
        "[resourceId('Microsoft.ServiceBus/namespaces', variables('servicebus_namespace'))]"
      ]
    },

The access policy is created, always with a random key, never the one I specified. How do I set this programmatically and what is wrong with the code above?

Upvotes: 0

Views: 1241

Answers (1)

Peter
Peter

Reputation: 27944

You are using a different api version as the sample you are using:

  • sample api version 2014-09-01
  • your api version 2015-08-01

try to change the api version to see if that causes the issue

Upvotes: 1

Related Questions