gpt4 book ai didi

azure 二头肌 : Cannot reference a child resource to a parent resource as an array

转载 作者:行者123 更新时间:2023-12-02 23:52:55 25 4
gpt4 key购买 nike

资源类型

Microsoft.Cdn/profiles/originGroups/origins

API版本

2021-06-01

我正在尝试使用自定义域名为多个 Azure 应用服务部署 Azure Front Door。我能够部署多个自定义域名,并将它们与自己的路由关联起来,类似于他们自己的 WAF 策略。但是,我正在努力创建多个源组并添加它们自己的源。

每当我尝试引用父资源 frontDoorOriginGroup 时,都会收到如下错误

'模板资源'[format('{0}/{1}/{2}',parameters('frontDoorName'),format('{0}-origins',replace(parameters('origins') [范围(0,长度(参数('origins')))[参数('origins')[copyIndex()]]],'.','-')),替换(参数('origins')[copyIndex ()]、'.'、''))]' 在第 1 行和第 5424 列无效:无法评估命名属性或非整数索引 'web-app-name.azurewebsites.net'数组值...

我的二头肌代码

resource frontDoorOriginGroup 'Microsoft.Cdn/profiles/originGroups@2021-06-01' = [for i in range(0, length(origins)): {
name: replace(origins[i], '.', '-')
parent: frontDoorProfile
properties: {
loadBalancingSettings: {
sampleSize: 4
successfulSamplesRequired: 2
}
healthProbeSettings: {
probePath: healthCheckPath
probeRequestType: 'GET'
probeProtocol: 'Https'
probeIntervalInSeconds: 120
}
}
}]

resource frontDoorOrigin 'Microsoft.Cdn/profiles/originGroups/origins@2021-06-01' = [for origin in origins: {
name: frontDoorOriginGroup[origin].name
parent: frontDoorOriginGroup[origin]
properties: {
hostName: '${origin}'
httpPort: 80
httpsPort: 443
originHostHeader: '${origin}'
priority: 1
weight: 50
enabledState: 'Enabled'
}
}]

有没有办法将子资源作为数组引用到父资源?我读了这个文档Set name and type for child resources in Bicep不适合我,或者我做错了什么?请协助。谢谢!

最佳答案

因此,如果有人遇到类似问题,请进行如下更改以使其正常工作

resource frontDoorOriginGroup 'Microsoft.Cdn/profiles/originGroups@2021-06-01' = [for i in range(0, length(origins)): {
name: replace(origins[i], '.', '-')
parent: frontDoorProfile
properties: {
loadBalancingSettings: {
sampleSize: 4
successfulSamplesRequired: 2
}
healthProbeSettings: {
probePath: healthCheckPath
probeRequestType: 'GET'
probeProtocol: 'Https'
probeIntervalInSeconds: 120
}
}
}]

resource frontDoorOrigin 'Microsoft.Cdn/profiles/originGroups/origins@2021-06-01' = [for i in range(0, length(origins)): {
name: frontDoorOriginGroup[i].name
parent: frontDoorOriginGroup[i]
properties: {
hostName: origins[i]
httpPort: 80
httpsPort: 443
originHostHeader: origins[i]
priority: 1
weight: 50
enabledState: 'Enabled'
}
}]

关于 azure 二头肌 : Cannot reference a child resource to a parent resource as an array,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/76203872/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com