1
votes

Im trying to deploy a ServiceBus through an ARM template. I ive tried all these versions as the serviceBusNamespaceName value with the same error message:

Not working (using resource group named: 'INT001-TestOrderStore-Cert' ) :

  • "[concat('INT1001-ServiceBus-', uniqueString(resourceGroup().id))]"
  • "[concat('INT1001-ServiceBus', uniqueString(resourceGroup().id))]"
  • "[concat('INT1001-MyOwnName', uniqueString(resourceGroup().id))]"
  • "[concat('int1001-myownname', uniqueString(toLower(resourceGroup().id))]"

but always get the same error message:

2020-03-22T11:54:07.2612863Z ##[error]BadRequest: { "error": { "message": "The specified service namespace is invalid. CorrelationId: 43105e81-4248-41d6-ba91-9070e8ac4637", "code": "BadRequest" } }

This is the only one that has worked so far: "sbnslau-1fa155e2-b3fb-48b9-a204-af1d2a02f40c"

So i need to understand what is going wrong when i try to use concat and unique string. Is there anyway in the azure portal i can evaluate the expression to se what it resolves too?

This is what my ARM looks like:

sbArmDeploy.json

    {
  "$schema": "https://schema.management.azure.com/schemas/2015-01-01/deploymentTemplate.json#",
  "contentVersion": "1.0.0.0",
  "parameters": {
    "serviceBusNamespaceName": {
      "type": "string",
      "metadata": {
        "description": "Name of the Service Bus namespace"
      }
    },
    "location": {
      "type": "string",
      "defaultValue": "[resourceGroup().location]",
      "metadata": {
        "description": "Location for all resources."
      }
    }
  },
  "variables": {},
  "resources": [
    {
      "apiVersion": "2017-04-01",
      "name": "[parameters('serviceBusNamespaceName')]",
      "type": "Microsoft.ServiceBus/namespaces",
      "location": "[parameters('location')]",
      "sku": {
        "name": "Standard",
        "tier": "Standard"
      }
    }
  ],
  "outputs": {}
}

SbArmDeploy-Parameters.json

    {
  "$schema": "https://schema.management.azure.com/schemas/2015-01-01/deploymentParameters.json#",
  "contentVersion": "1.0.0.0",
  "parameters": {
    "serviceBusNamespaceName": {
      "value": "sbns_1fa155e2-b3fb-48b9-a204-af1d2a02f40c"
    }
  }
}
1
Hi, is there any update for this issue? Please check if Gaurav Mantri's answer helps to resolve your issue. See this, just a reminder :) - LoLance

1 Answers

3
votes

When I try to create a Service Bus Namespace using the name you provided (sbns_1fa155e2-b3fb-48b9-a204-af1d2a02f40c) in Azure Portal, I got the following error:

The namespace can contain only letters, numbers, and hyphens. The namespace must start with a letter, and it must end with a letter or number

Basically the issue is that you have an underscore (_) in the namespace name which is not allowed. Please remove that or change that to a hyphen (-) and you will not get the error.

You can find the naming rules for a Service Bus Namespace here: https://docs.microsoft.com/en-us/rest/api/servicebus/create-namespace.


As discussed in the comments, the problem is coming because you're defining a variable in parameters file. What you would need to do is define them in variables section in your main template file.

For example, here're the ArmDeploy.json and Parameters.json files I used:

{
    "$schema": "https://schema.management.azure.com/schemas/2015-01-01/deploymentTemplate.json#",
    "contentVersion": "1.0.0.0",
    "parameters": {
        "location": {
            "defaultValue": "[resourceGroup().location]",
            "type": "String",
            "metadata": {
                "description": "Location for all resources."
            }
        }
    },
    "variables": {
        "serviceBusNamespaceName": "[concat('INT1001-ServiceBus-', uniqueString(resourceGroup().id))]"
    },
    "resources": [
        {
            "type": "Microsoft.ServiceBus/namespaces",
            "apiVersion": "2017-04-01",
            "name": "[variables('serviceBusNamespaceName')]",
            "location": "[parameters('location')]",
            "sku": {
                "name": "Standard",
                "tier": "Standard"
            }
        }
    ],
    "outputs": {}
}

{
  "$schema": "https://schema.management.azure.com/schemas/2015-01-01/deploymentParameters.json#",
  "contentVersion": "1.0.0.0",
  "parameters": {
    "location": {
      "value": "eastus"
    }
  }
}