当资源使用内部范围的表达式计算并包含对父模板中定义的符号的任何引用时 Microsoft.Resources/deployments
,此 linter 规则将触发诊断。
请在 Bicep 配置文件中使用以下值自定义规则设置:
nested-deployment-template-scoping
以下示例失败此测试,因为在 fizz
父模板的命名空间中定义。
var fizz = 'buzz'
resource nested 'Microsoft.Resources/deployments@2024-03-01' = {
name: 'name'
properties: {
mode: 'Incremental'
expressionEvaluationOptions: {
scope: 'inner'
}
template: {
'$schema': 'https://schema.management.azure.com/schemas/2019-04-01/deploymentTemplate.json#'
contentVersion: '1.0.0.0'
resources: [
{
apiVersion: '2024-03-01'
type: 'Microsoft.Resources/tags'
name: 'default'
properties: {
tags: {
tag1: fizz // <-- Error! `fizz` is defined in the parent template's namespace
}
}
}
]
}
}
}
有关 Linter 的详细信息,请参阅使用 Bicep Linter。