【问题标题】:ARM template ResourceID incorrect (comma added?)ARM 模板 ResourceID 不正确(添加了逗号?)
【发布时间】:2018-06-22 17:24:48
【问题描述】:

我正在尝试从我构建的 ARM 模板部署 Azure AppGateway。但是我一直遇到错误:

The template variable 'appGatewayFrontendPort' is not valid: Unable to evaluate template language function 'resourceId': function requires exactly one multi-segmented argument which must be resource type including resource provider namespace. Current function arguments 'Microsoft.Network/applicationGateways/,Logis-AppGW-UK/frontendPorts/appGatewayFrontendPort'.

由于某种奇怪的原因,当我连接它时,我的 resourceID 会添加一个逗号。我在其他对象中使用了类似的 resourceID 调用,它按预期进行。附上相关的 ARM 模板。欢迎任何帮助。我试过用单个变量来做这个,它最终得到了同样的错误。如您所见,使用相同方法成功引用了 gatewaySubnetRef 变量,但我无法使其与 appGatewayfrontendPort IP 一起使用。

"variables": {
    "HUBVNET": "[resourceId('Microsoft.Network/virtualNetworks',concat('VNet-Logis-HUB-',parameters('RegionCode')))]",
    "LANVNet": "[resourceId('Microsoft.Network/virtualNetworks',concat('VNet-Logis-LAN-',parameters('RegionCode')))]",
    "DMZVnet": "[resourceId('Microsoft.Network/virtualNetworks',concat('VNet-Logis-DMZ-',parameters('RegionCode')))]",
    "StorageAccountName": "[toLower(concat('logis',parameters('RegionCode'),'storage'))]",
    "DMZServersDNS": "[split(parameters('DMZ DNS Server Address'),',')]",
    "LANServersDNS": "[split(parameters('LAN DNS Server Address'),',')]",
    "gatewaySubnetRef": "[resourceId('Microsoft.Network/virtualNetworks/subnets', concat('VNet-Logis-HUB-',parameters('RegionCode')), 'GatewaySubnet')]",
    "appGatewaySubnetRef": "[resourceId('Microsoft.Network/virtualNetworks/subnets', concat('VNet-Logis-HUB-',parameters('RegionCode')), 'AppGatewaySubnet')]",
    "appGatewayPublicIPRef": "[resourceId('Microsoft.Network/publicIPAddresses/', concat('AppGW-',parameters('RegionCode'),'-PublicIP'))]",
    "RecoveryServicesName": "[concat('BackupVault-Logis-',parameters('RegionCode'))]",
    "AppGwFrontendPortName": "[concat('Logis-AppGW-',parameters('RegionCode'),'/frontendPorts/appGatewayFrontendPort')]",
    "AppGwFrontendIP": "[concat('Logis-AppGW-',parameters('RegionCode'), '/frontendIPConfigurations/appGatewayFrontendIP')]",
    "appGatewayFrontendPort": "[resourceId('Microsoft.Network/applicationGateways/', variables('AppGwFrontendPortName'))]",
    "appGatewayFrontendIP": "[resourceId('Microsoft.Network/applicationGateways/', variables('AppGwFrontendIP'))]"
},

【问题讨论】:

  • 我认为你缺少一个 concat( 在 appGatewayFrontendPort 和 appGatewayFrontendIP 上

标签: azure azure-resource-manager


【解决方案1】:

几件事:

1) 避免使用 concat 创建 resourceIds,这更难,让函数为您完成工作。

2) resourceIds 需要相同数量的段和参数。将段视为类型参数中的斜线数。您看到的大多数 resourceId 函数调用只有一个,例如

    [resourceId('Microsoft.Network/virtualNetworks', 'myVnet')]

但多段的并不少见:

    [resourceId('Microsoft.Network/virtualNetworks/subnets', 'myVnet', 'firstSubnet')]

供您的 AppGateway 前端使用:

    "appGatewayFrontendPort": "[resourceId('Microsoft.Network/applicationGateways/frontendPorts', concat('Logis-AppGW-',parameters('RegionCode')), 'appGatewayFrontEndPort')]"

然后去掉变量“AppGwFrontendPortName”

这里还有一点:https://docs.microsoft.com/en-us/azure/azure-resource-manager/resource-group-template-functions-resource#resourceid

HTH

【讨论】:

    【解决方案2】:

    我也在为此苦苦挣扎。这里有更多例子

    参数

    "authorizationRules": {
            "value": [
                {
                    "name": "RootManageSharedAccessKey",
                    "properties": {
                        "rights": [
                            "Listen",
                            "Manage",
                            "Send"
                        ]
                    }
                },
                {
                    "name": "SendListenAccess",
                    "properties": {
                        "rights": [
                            "Listen",
                            "Send"
                        ]
                    }
                }
            ]
        }
    

    输出声明

    "eventHubAuthorizationRulesId": {
            "type": "array",
            "copy": {
                "count": "[length(parameters('authorizationRules'))]",
                "input": "[resourceId('Microsoft.Eventhub/namespaces/authorizationRules', parameters('namespace'), parameters('authorizationRules')[copyIndex()].name)]"
            }
        },
        "eventHubAuthorizationRulesId2": {
            "type": "array",
            "copy": {
                "count": "[length(parameters('authorizationRules'))]",
                "input": "[resourceId('Microsoft.Eventhub/namespaces/eventhubs/authorizationRules', parameters('namespace'),parameters('eventHubName'), parameters('authorizationRules')[copyIndex()].name)]"
            }
        }
    

    打印:

    "eventHubAuthorizationRulesId": {
        "type": "Array",
        "value": [
          "/subscriptions/xxxxxx/resourceGroups/dummy-rg/providers/Microsoft.Eventhub/namespaces/namespaceEH-dummy-1/authorizationRules/RootManageSharedAccessKey",    
          "/subscriptions/xxxxxx/resourceGroups/dummy-rg/providers/Microsoft.Eventhub/namespaces/namespaceEH-dummy-1/authorizationRules/SendListenAccess"
        ]
      },
      "eventHubAuthorizationRulesId2": {
        "type": "Array",
        "value": [
          "/subscriptions/xxxxxx/resourceGroups/dummy-rg/providers/Microsoft.Eventhub/namespaces/namespaceEH-dummy-1/eventhubs/eventHub-dummy-1/authorizationRules/RootManageSharedAccessKey",
          "/subscriptions/xxxxxx/resourceGroups/dummy-rg/providers/Microsoft.Eventhub/namespaces/namespaceEH-dummy-1/eventhubs/eventHub-dummy-1/authorizationRules/SendListenAccess"
        ]
      }
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2021-03-16
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多