1

通常,当有多个前端 ID 分配给路由规则时,它们是这样描述的:

...
"routingRules": [
          {
            "name": "routingRule1",
            "properties": {
              "frontendEndpoints": [
                {
                  "id": "[resourceId('Microsoft.Network/frontDoors/frontendEndpoints', parameters('frontDoorName'), 'frontendEndpoint')]"
                },
                {
                  "id": "[resourceId('Microsoft.Network/frontDoors/frontendEndpoints', parameters('frontDoorName'), 'frontendEndpoint2')]"
                }
              ],
...

就我而言,我想将其作为参数类型“数组”来执行,但我收到错误。请看下面我的模板、参数文件和错误信息

这是前门ARM参数部署文件

"$schema": "https://schema.management.azure.com/schemas/2019-04-01/deploymentParameters.json#",
    "contentVersion": "1.0.0.0",
    "parameters": {
        "frontdoor_name":  {
            "value":  "frontdoortest"
        },
        "frontends_all": {
            "value": [
                {
                    "name": "fe1",
                    "properties": {
                        "hostName": "frontdoortest.azurefd.net",
                        "sessionAffinityEnabledState": "Disabled",
                        "sessionAffinityTtlSeconds": 0,
                        "resourceState": "Enabled"
                    }
                },
                {
                    "name": "fe1customdns1",
                    "properties": {
                        "hostName": "dev.custom1.com",
                        "sessionAffinityEnabledState": "Enabled",
                        "sessionAffinityTtlSeconds": 0,
                        "resourceState": "Enabled"
                    }
                },
                {
                    "name": "fe1customdns2",
                    "properties": {
                        "hostName": "dev.custom2.com",
                        "sessionAffinityEnabledState": "Enabled",
                        "sessionAffinityTtlSeconds": 0,
                        "resourceState": "Enabled"
                    }
                }
            ]
        },
        "frontends_one": {
                    "value": [
                        {
                            "id": "[concat(resourceId('Microsoft.Network/frontdoors', parameters('frontdoor_name')), '/FrontendEndpoints/fe1customdns1')]",
                        },
                        {
                            "id": "[concat(resourceId('Microsoft.Network/frontdoors', parameters('frontdoor_name')), '/FrontendEndpoints/fe1customdns2')]",
                        } 
                    ]
        }
    }

这是前门 ARM 资源部署模板的一部分

...
"parameters": {
    "frontends_all": {
        "type": "array"
    },
    "frontends_one": {
        "type": "array"
    },
    "frontdoor_name": {
        "type": "string"
    }
}

...
{
            "type": "Microsoft.Network/frontDoors",
            "apiVersion": "2020-01-01",
            "name": "[parameters('frontdoor_name')]",
            "location": "Global",
            "properties": {
                "resourceState": "Enabled",
                "frontendEndpoints": "[parameters('frontends_all')]",  #### NO ERROR 
                "routingRules": [
                        {
                            "name": "routingRule1",
                            "properties": {
                                  "frontendEndpoints": "[parameters('frontends_one')]",    #### ERROR !!!
                                 "acceptedProtocols": [
                                    "Https"
                                ],
                                "patternsToMatch": [
                                    "/*",
                                ],
                                "enabledState": "Enabled",
                                "resourceState": "Enabled",
                                "routeConfiguration": {
                                    "@odata.type": "#Microsoft.Azure.FrontDoor.Models.FrontdoorForwardingConfiguration",
                                    "forwardingProtocol": "MatchRequest",
                                    "backendPool": {
                                        "id": "[concat(resourceId('Microsoft.Network/frontdoors', parameters('frontdoor_name')), '/backendpools/test')]"
                                    }
                                }
                            }
                        }
...

[错误]BadRequest:在 RoutingRule routingRule1 中缺少 FrontendEndpoint [resourceId('Microsoft.Network/frontDoors/frontendEndpoints', parameters('frontdoor_name'), 'fe1customdns2')] 的主机名。,缺少 FrontendEndpoint 的主机名 [resourceId('Microsoft.Network /frontDoors/frontendEndpoints', parameters('frontdoor_name'), 'fe1customdns')] 在 RoutingRule routingRule1; 资源引用无效:“[resourceId('Microsoft.Network/frontDoors/frontendEndpoints', parameters('frontdoor_name'), 'fe1customdns2')]”; 资源引用无效:“[resourceId('Microsoft.Network/frontDoors/frontendEndpoints', parameters('frontdoor_name'), 'fe1customdns1')]”

4

0 回答 0