ARM模板ResourceID不正确(添加了逗号?)

时间:2018-06-22 17:24:49

标签: azure azure-resource-manager

我正在尝试从构建的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'))]"
},

1 个答案:

答案 0 :(得分:1)

几件事:

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

2)resourceIds需要相等数量的段和参数。将段视为类型param中的斜杠数。您看到的大多数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