Bicep diagnostic code - BCP040

This diagnostic occurs when the Bicep compiler can't determine the exact value of an interpolated string key.

Description

String interpolation is not supported for keys on objects of type <type-definition>.

Level

Warning / Error

Solution

Remove string interpolation.

Examples

The following example raises the diagnostic because string interpolation is used for specifying the key sku1:

var name = 'sku'

type storageAccountConfigType = {
  name: string
  sku1: string
}

param foo storageAccountConfigType = {
  name: 'myStorage'
  '${name}1': 'Standard_LRS' 
}

You can fix the issue by adding the missing properties:

var name = 'sku'

type storageAccountConfigType = {
  name: string
  sku1: string
}

param foo storageAccountConfigType = {
  name: 'myStorage'
  sku1: 'Standard_LRS' 
}

Next steps

For more information about Bicep diagnostics, see Bicep core diagnostics.