Azure bicep 存储帐户 sku 是只读的

Azure bicep Storage account sku is read-only

我正在尝试使用 azure bicep 部署存储帐户。

在我的代码中:

resource storageAccounts_storageacntin_name_default 'Microsoft.Storage/storageAccounts/blobServices@2021-04-01' = {
  parent: storageAccounts_storageacntin_name_resource
  name: 'default'
  sku: {
    name: 'Standard_RAGRS'
    tier: 'Standard'
  }
  properties: {
    changeFeed: {
      enabled: false
    }
    restorePolicy: {
      enabled: false
    }
    containerDeleteRetentionPolicy: {
      enabled: true
      days: 7
    }
    cors: {
      corsRules: []
    }
    deleteRetentionPolicy: {
      enabled: true
      days: 30
    }
    isVersioningEnabled: true
  }
}

我收到 SKU 错误。错误如下。

The property "sku" is read-only. Expressions cannot be assigned to read-only properties.bicep(BCP073)

我不完全明白为什么会出现此错误,我对 azure bicep 还是个新手,并试图从 terraform 部署慢慢转移到 azure bicep。 谁能解释一下为什么会出现此错误以及如何解决? 非常感谢

更新代码:

这是我在删除 sku 时遇到的错误

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'
  }
}]

resource storageAccounts_hamzaelaouane1_name_default 'Microsoft.Storage/storageAccounts/blobServices@2021-04-01' = [ for storageName in storageAccounts: {
  parent: [storage_Accounts]
  name: storageName
  properties: {
    changeFeed: {
      enabled: false
    }
    restorePolicy: {
      enabled: false
    }
    containerDeleteRetentionPolicy: {
      enabled: true
      days: 7
    }
    cors: {
      corsRules: []
    }
    deleteRetentionPolicy: {
      enabled: true
      days: 30
    }
    isVersioningEnabled: true
  }
}
]

错误在最后两行。它说那时候期待 }]。逐行检查,我看不到任何语法错误

sku 字段对于 blobServicesfileServices 等存储帐户下的服务是只读的。

您可以(仅)在存储帐户级别设置 SKU (Microsoft.Storage/storageAccounts@2021-04-01)。

待完成; tier 字段在存储帐户上也是只读的,因为它基于 SKU 名称。删除这些字段,您就可以开始了。