为 Azure 资源创建复制循环

Create Copy Loop for Azure Resource

您好,我正在尝试为事件中心创建一个复制循环,但我一直收到以下错误,我不太正确,希望有人能看到我哪里出错了

错误:

New-AzResourceGroupDeployment : 22:36:18 - Resource Microsoft.EventHub/namespaces 'gor1' failed with message '{
  "error": {
    "message": "The specified service namespace is invalid. CorrelationId: 422868d5-f63c-441f-9741-a2db633a72cf",
    "code": "BadRequest"
  }
}'

ARM 模板:

{
  "$schema": "https://schema.management.azure.com/schemas/2019-04-01/deploymentTemplate.json#",
  "contentVersion": "1.0.0.0",
  "parameters": {
    "eventHubName": {
      "type": "string",
      "metadata": {
        "description": "Specifies a event name."
      }
    },
    "eventHubNamespaceName": {
      "type": "string",
      "metadata": {
        "description": "Specifies the Namespace name."
      }
    },
    "looplength": {
      "type": "int",
      "defaultValue": 1
    },
    "location": {
      "type": "string",
      "defaultValue": "[resourceGroup().location]",
      "metadata": {
        "description": "Specifies the Azure location for all resources."
      }
    },
    "eventHubSku": {
      "type": "string",
      "defaultValue": "Standard",
      "allowedValues": [ "Basic", "Standard" ],
      "metadata": {
        "description": "Specifies the messaging tier for Event Hub Namespace."
      }
    }
  },
  "variables": {
  },
  "resources": [
    {
      "type": "Microsoft.EventHub/namespaces",
      "apiVersion": "2018-01-01-preview",
      "name": "[concat(Parameters('eventHubNamespaceName'), copyIndex(1))]",
      "location": "[parameters('location')]",
      "sku": {
        "name": "[parameters('eventHubSku')]",
        "tier": "[parameters('eventHubSku')]",
        "capacity": 1
      },
      "copy": {
        "name": "EVLoop",
        "count": "[parameters('looplength')]"
      },
      "properties": {
        "isAutoInflateEnabled": false,
        "maximumThroughputUnits": 0
      }
    },
    {
      "type": "Microsoft.EventHub/namespaces/eventhubs",
      "apiVersion": "2017-04-01",
      "name": "[concat(Parameters('eventHubNamespaceName'), '/', parameters('eventHubName'))]",
      "location": "[parameters('location')]",
      "copy": {
        "name": "EVLoop",
        "count": "[parameters('looplength')]"
      },
      "dependsOn": [
        "[concat(Parameters('eventHubNamespaceName'), copyIndex(1))]"
      ],
      "properties": {
        "messageRetentionInDays": 7,
        "partitionCount": 1
      }
    }
  ]
}

参数文件:

{
  "$schema": "http://schema.management.azure.com/schemas/2015-01-01/deploymentParameters.json#",
  "contentVersion": "1.0.0.0",
  "parameters": {
    "eventHubName": {
      "value": "gone"
    },
    "eventHubNamespaceName": {
      "value": "gor"
    },
    "looplength": {
      "value": 1
    },
    "location": {
      "value": "west europe"
    },
    "eventHubSku": {
      "value": "Basic"
    }
  }
}

我已经尝试这样做,因此命名空间名称和事件中心名称都一起迭代。

希望这是有道理的,提前致谢:)

您为“eventHubNamespaceName”传递的参数值不正确。

根据 Microsoft Azure 资源命名限制 - 事件中心命名空间名称的长度应为 6-50,可以是字母数字和连字符,以字母开头,以字母或数字结尾。

目前在您的参数值中,您传递的名称少于 6 个字符,这就是部署失败的原因。

请参考这个documentation