You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

使用Azure Bicep创建Azure Function App托管计划失败求助

问题分析与修复方案

你遇到的Object reference not set to an instance of an object错误,是因为托管计划的Bicep代码缺少了消耗计划(Y1/Dynamic SKU)必需的配置项。

错误原因

对于Azure Function的消耗计划(Y1层级),部署Microsoft.Web/serverfarms资源时必须包含两个关键配置:

  • kind: 'functionapp':明确指定该计划是为Function App服务的专用计划类型
  • properties.reserved: true:这是消耗计划部署的强制验证属性,无论Windows还是Linux环境都需要设置

修正后的Bicep代码

param functionAppName string = 'abctest'
param env string = 'pri2'
param location string = 'westeurope'

var hostingPlanName = '${functionAppName}-${env}-plan'

resource hostingPlan_resource 'Microsoft.Web/serverfarms@2020-10-01' = {
  name: hostingPlanName
  location: location
  kind: 'functionapp'
  sku: {
    tier: 'Y1'
    name: 'Dynamic'
  }
  properties: {
    reserved: true
  }
}

验证后单独部署这个托管计划,或者整合到完整的Function App部署模板中,即可解决报错问题。

内容的提问来源于stack exchange,提问作者Mattias

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.08.21 03:45:39