Azure二头肌:不能将子资源作为数组引用到父资源

zqdjd7g9  于 2023-05-18  发布在  其他
关注(0)|答案(1)|浏览(86)

资源类型

Microsoft.Cdn/profiles/originGroups/origins

API版本

2021-06-01

我正在尝试为多个Azure App Services部署Azure Front Door,并使用自定义域名。我能够部署多个自定义域名,并将它们与自己的路由和类似于自己的WAF策略相关联。然而,我正在努力创建多个起源组和添加他们自己的起源。
每当我尝试引用父资源frontDoorOriginGroup时,我会得到如下错误
'1'行和列'5424'的模板资源'[format('{0}/{1}/{2}',parameters(' frontDoorName '),format('{0}-origins ',replace(parameters(' origins ')[range(0,length(parameters(' origins ')))[parameters(' origins ')[copyIndex()]]],'.','-')),replace(parameters(' origins ')[copyIndex()],'.','')]'无效:无法对数组值计算命名属性或非整数索引“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不适合我,还是我做错了什么?请帮忙。谢谢!

mkh04yzy

mkh04yzy1#

所以,得到了它的工作与改变如下,如果有人与类似的问题斗争

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'
  }
}]

相关问题