我正在使用 Bicep 模板在 Azure 上部署 App Gateway(相關部分如下所示)。
var applicationGatewayId = resourceId('Microsoft.Network/applicationGateways', applicationGatewayName)
resource applicationGateway 'Microsoft.Network/applicationGateways@2021-08-01' = {
properties: {
urlPathMaps: [
{
properties: {
defaultBackendAddressPool: {
id: '${applicationGatewayId}/backendAddressPools/backendpool-test'
}
}
]
}
}
我的問題是關于id
示例中的 backendAddressPool 的。編譯時我收到警告:Warning use-resource-id-functions: If property "id" represents a resource ID, it must use a symbolic resource reference, be a parameter or start with one of these functions: extensionResourceId, guid, if, reference, resourceId, subscription, subscriptionResourceId, tenantResourceId. [https://aka.ms/bicep/linter/use-resource-id-functions]
.
- 我嘗試使用
${applicationGateway.id}/backendAddressPools/backendpool-test
,但這會導致回圈參考錯誤。對于我使用的其他資源型別resourceId()
,但對于這個示例我不知道如何使用。 - 例如,我嘗試過,
resourceId('Microsoft.Network/ApplicationGatewayBackendAddressPool', '${prefix}-backendpool-infocat')
但這似乎會導致完全不同的資源型別(至少不會編譯成相同的 ID)。
這個問題也適用于其他子資源,例如:
applicationGateway.urlPathMaps.defaultBackendAddressPool
applicationGateway.urlPathMaps.pathRules.backendAddressPool
applicationGateway.urlPathMaps.pathRules.backendHttpSettings
- ...
那么,當沒有易于定義的 resourceType 可以使用時,如何正確地參考這些子資源resourceId()
呢?可以避免警告嗎?
提前致謝!
uj5u.com熱心網友回復:
嘗試這個:
id:resourceId('Microsoft.Network/applicationGateways/backendAddressPools', applicationGatewayName, applicationGatewayBackendAddressPoolName)
轉載請註明出處,本文鏈接:https://www.uj5u.com/yidong/534074.html
標籤:天蓝色模板
下一篇:Android動態權限申請