共用方式為


Bicep 錯誤/警告碼 - BCP073

當您將值指派給唯讀屬性時,就會發生此錯誤/警告。

錯誤/警告描述

The property <property-name> is read-only. Expressions cannot be assigned to read-only properties.

解決方案

從檔案中移除屬性指派。

範例

下列範例會引發警告,因為 sku 只能在層級上 storageAccounts 設定。 對於在 和 fileServicesblobServices記憶體帳戶下的服務而言,這是唯讀的。

param location string

resource storage 'Microsoft.Storage/storageAccounts@2023-04-01' = {
  name: 'mystore'
  location: location
  sku: {
    name: 'Standard_LRS'
  }
  kind:  'StorageV2'
}

resource blobService 'Microsoft.Storage/storageAccounts/blobServices@2023-04-01' = {
  parent: storage
  name: 'default'
  sku: {}
}

您可以移除 sku 屬性指派來修正此問題:

param location string

resource storage 'Microsoft.Storage/storageAccounts@2023-04-01' = {
  name: 'mystore'
  location: location
  sku: {
    name: 'Standard_LRS'
  }
  kind:  'StorageV2'
}

resource blobService 'Microsoft.Storage/storageAccounts/blobServices@2023-04-01' = {
  parent: storage
  name: 'default'
}

下一步

如需 Bicep 錯誤和警告碼的詳細資訊,請參閱 Bicep 核心診斷