此问题的解决方法是,在 Bicep 脚本中定义条件语句以检查应用服务计划的类型,并仅在类型为 Linux 时部署。以下是示例代码:
resource appServicePlan 'Microsoft.Web/serverfarms@2021-02-01' = {
  name: 'myAppServicePlan'
  location: resourceGroup().location
  sku: {
    name: 'P1V2'
    tier: 'PremiumV2'
  }
  count: if(isEmpty(parameters('appServicePlanKind')) || parameters('appServicePlanKind') == 'Linux', 1, 0)
  properties: {
    reserved: true
    isXenon: false
    hyperV: false
    spotDedicatedCores: 0
    perSiteScaling: false
    maximumElasticWorkerCount: 1
    kind: if(isEmpty(parameters('appServicePlanKind')), 'Linux', parameters('appServicePlanKind'))
  }
}
在上面的示例中,我们定义了一个新的应用服务计划资源,并使用了 if 函数来仅在 appServicePlanKind 参数为 "Linux" 或未定义时才创建该资源。