Compartir a través de

Bicep 警告代码 - BCP073

将值分配给只读属性时,会出现此警告。

警告说明

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

解决方案

从文件中移除属性分配。

示例

以下示例中引发了警告,因为 sku 只能在 storageAccounts 级别设置。 对于存储帐户(如 blobServicesfileServices)下的服务,它是只读的。

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 警告和错误