AzureBicep-如何避免在what-if输出中产生不必要的噪音?
创始人
2024-09-29 13:30:38
0

使用Bicep的isPreview参数来限制what-if输出,只显示实际变更的资源。

示例代码如下:

param location string = 'eastus'
param functionAppName string
param appInsightsName string

resource appServicePlan 'Microsoft.Web/serverfarms@2018-02-01' = {
  name: format('{0}-plan', functionAppName)
  location: location
  sku: {
    name: 'P1V2'
    tier: 'PremiumV2'
  }
  kind: 'functionapp'
  properties: {
    reserved: true
  }
}

resource appService 'Microsoft.Web/sites@2018-02-01' = {
  name: functionAppName
  location: location
  dependsOn: [
    appServicePlan
  ]
  properties: {
    serverFarmId: appServicePlan.id
  }
}

resource appInsights 'Microsoft.Insights/components@2015-05-01' = if(appInsightsName != '') {
  name: appInsightsName
  location: location
  kind: 'web'
  properties: {}
} else {
  name: ''
  url: ''
}

output appServiceId string = appService.id
output appInsightsId string = appInsights.id

如果这个模板被用于部署新的资源,可以设置isPreview参数为false,以获得详细和准确的what-if输出:

az deployment sub create -n  --template-file  --parameters functionAppName= appInsightsName= --location eastus --mode Complete --isPreview false

如果该模板被用于更新现有资源,则应该将isPreview参数设置为true,以排除不必要的噪音:

az deployment sub create -n  --template-file  --parameters functionAppName= appInsightsName= --location eastus --mode Incremental --isPreview true

相关内容

热门资讯

2026版教学!微乐小程序黑科... 2026版教学!微乐小程序黑科技,小程序微乐辅助器免费版(透视)好像真的有挂(哔哩哔哩)小程序微乐辅...
六分钟教程!微乐小程序黑科技,... 六分钟教程!微乐小程序黑科技,微乐自建房怎么提高运气(开挂)都是真的是有挂(2026)1、首先打开微...
透视系统!微乐小程序黑科技,陕... 透视系统!微乐小程序黑科技,陕西微乐小程序修改器(透视)原来有挂(哔哩哔哩)1、不需要AI权限,帮助...
第4分钟下载!微乐小程序黑科技... 第4分钟下载!微乐小程序黑科技,微乐自建房辅助软件下载(开挂)好像真的是有挂(2026)1、许多玩家...
在玩家背景下!微乐小程序黑科技... 在玩家背景下!微乐小程序黑科技,微乐小程序辅助器出租(透视)都是是真的挂(哔哩哔哩)暗藏猫腻,小编详...
一分钟开挂!微乐小程序黑科技,... 一分钟开挂!微乐小程序黑科技,微乐科技软件下载(开挂)竟然是有挂(2026)1、微乐小程序黑科技免费...
推出新举措!微乐小程序免费黑科... 推出新举措!微乐小程序免费黑科技,微信小程序怎么开挂(透视)竟然真的是有挂(哔哩哔哩)1、每一步都需...
4分钟透视!微乐小程序免费黑科... 4分钟透视!微乐小程序免费黑科技,微乐小程序怎么挂脚本(开挂)好像是真的挂(2026)1)微乐小程序...
透视中牌率!微乐小程序黑科技,... 透视中牌率!微乐小程序黑科技,微乐自建房辅助工具官网(透视)好像是有挂(哔哩哔哩);1、金币登录送、...
第7分钟神器!微乐小程序免费黑... 第7分钟神器!微乐小程序免费黑科技,微信微乐辅助免费(开挂)一贯有挂(2026)1、操作简单,无需微...