【发布时间】:2021-04-13 14:51:33
【问题描述】:
假设,我只想在param isProduction bool 时部署一个单独的资源
是true。
二头肌可以吗?
我在文档中找不到这个。
【问题讨论】:
标签: azure arm conditional-statements infrastructure-as-code azure-bicep
假设,我只想在param isProduction bool 时部署一个单独的资源
是true。
二头肌可以吗?
我在文档中找不到这个。
【问题讨论】:
标签: azure arm conditional-statements infrastructure-as-code azure-bicep
除了已经给出的答案之外,不仅可以基于条件部署整个资源,还可以使用条件三元运算符针对特定环境更改资源的各个属性。以下是 Azure Front Door 的示例,其中仅在生产环境中使用高级层:
resource profile 'Microsoft.Cdn/profiles@2020-09-01' = {
name: 'azureFrontDoor'
location: 'global'
sku: {
name: isProduction ? 'Premium_AzureFrontDoor' : 'Standard_AzureFrontDoor'
}
tags: tags
}
【讨论】:
if(isProduction)后面有一个语法if(isProduction),例如:
param isProduction bool
resource prodWebApp 'Microsoft.Web/sites@2020-12-01' = if (isProduction) {
name: 'MyWebApp'
...<other props>...
}
【讨论】: