Bicep error code - BCP311

This error occurs when you provide an invalid index number. Arrays in Bicep are zero-based. For more information, see Arrays.

Error description

The provided index value of <index-value> isn't valid for type <type-name>. Indexes for this type must be between 0 and <zero-based-tuple-index>.

Solutions

Use the correct index number.

Examples

The following example raises the error because the index is out of bounds:

var exampleArray = [
  1
  2
  3
]

output bar int = exampleArray[3]

You can fix the error by using the correct index number:

var exampleArray = [
  1
  2
  3
]

output bar int = exampleArray[2]

Next steps

For more information about Bicep error and warning codes, see Bicep core diagnostics.