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

Azure Bicep部署存储账户遇sku只读报错及语法校验错误问题

Azure Bicep存储账户部署问题解决方案

问题1:blobServices资源sku字段报错BCP073

报错原因

Microsoft.Storage/storageAccounts/blobServices为存储账户的子资源,本身无可写的sku属性,sku配置仅属于父级存储账户,子资源的sku为继承父级的只读属性,强制赋值会触发只读属性报错。

解决方法

直接删除blobServices资源定义中的sku代码块即可,无需在子资源中重复配置sku。

问题2:调整代码后提示缺少}/]符号

报错原因

代码中存在多处语法错误,错误使用方括号导致括号匹配异常,同时子资源配置不符合规范:

  • 存储账户循环定义中,name: [storageName]错误添加方括号,storageName为字符串类型,不需要用方括号包裹
  • blobServices子资源循环定义中,parent: [storage_Accounts]错误使用方括号,且未匹配对应下标的父存储账户
  • blobServices子资源的name固定为default,不能设置为存储账户名

解决方法

修正语法错误和子资源配置,以下为可正常运行的完整代码:

param storageAccounts array = [
  'storage1'
]

resource storage_Accounts 'Microsoft.Storage/storageAccounts@2021-04-01' = [for storageName in storageAccounts: {
  name: storageName // 移除多余方括号
  location: 'westeurope'
  sku: {
    name: 'Standard_RAGRS'
    tier: 'Standard'
  }
  kind: 'StorageV2'
  properties: {
    allowCrossTenantReplication: true
    minimumTlsVersion: 'TLS1_2'
    allowBlobPublicAccess: false
    allowSharedKeyAccess: true
    networkAcls: {
      bypass: 'AzureServices'
      virtualNetworkRules: []
      ipRules: []
      defaultAction: 'Allow'
    }
    supportsHttpsTrafficOnly: true
    encryption: {
      services: {
        file: {
          keyType: 'Account'
          enabled: true
        }
        blob: {
          keyType: 'Account'
          enabled: true
        }
      }
      keySource: 'Microsoft.Storage'
    }
    accessTier: 'Hot'
  }
}]

// 循环创建对应存储账户的blobServices子资源,增加index匹配父资源
resource storageAccounts_blob_default 'Microsoft.Storage/storageAccounts/blobServices@2021-04-01' = [for (storageName, index) in storageAccounts: {
  parent: storage_Accounts[index] // 匹配对应下标的父存储账户,移除多余方括号
  name: 'default' // blob服务资源名固定为default
  properties: {
    changeFeed: {
      enabled: false
    }
    restorePolicy: {
      enabled: false
    }
    containerDeleteRetentionPolicy: {
      enabled: true
      days: 7
    }
    cors: {
      corsRules: []
    }
    deleteRetentionPolicy: {
      enabled: true
      days: 30
    }
    isVersioningEnabled: true
  }
}]

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

相关产品推荐
方舟 Agent Plan

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

最近更新时间:2026.10.02 05:15:04