【问题标题】:Create Copy Loop for Azure Resource为 Azure 资源创建复制循环
【发布时间】:2021-06-24 21:41:30
【问题描述】:

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

错误:

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"
    }
  }
}

我已尝试这样做,以便命名空间名称和事件中心名称一起迭代。

希望这是有道理的,在此先感谢 :)

【问题讨论】:

    标签: json azure arm-template


    【解决方案1】:

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

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

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

    请参考这个documentation。

    【讨论】:

    • 谢谢 .. 创建资源时问一个简单的问题,它们是 01 和 02 我可以将其更改为 -01 或 -02 等吗?
    • 是的,您可以像 "[concat(Parameters('eventHubNamespaceName'), '-', parameters('eventHubName'))]" 一样使用它来将破折号放在索引之前。
    猜你喜欢
    • 1970-01-01
    • 2019-12-16
    • 1970-01-01
    • 1970-01-01
    • 2021-11-04
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多