bicep icon indicating copy to clipboard operation
bicep copied to clipboard

unexpected warning on Microsoft.Web/sites/config for bicep(BCP179) for loop on SQL Connection Strings

Open kplantus opened this issue 2 years ago • 0 comments

Bicep version Bicep CLI version 0.10.61 (8f44805506)

Describe the bug looping on a SQL Connection String Config produces the following error: Unique resource or deployment name is required when looping. The loop item variable "databaseName" must be referenced in at least one of the value expressions of the following properties: "name", "parent" bicep(BCP179)

sqlServerFQDN string = 'sqlServer.database.windows.net'
databaseNames array = [
  'databaseA'
  'databaseB'
]

resource sqlConnString 'Microsoft.Web/sites/config@2021-03-01' = [for databaseName in databaseNames:  {
  name: 'connectionstrings'
  kind: 'string'
  parent: webapp
  properties: {
    '${databaseName}': {
      value: 'Server=${sqlServerFQDN},1433;Database=${databaseName};Authentication=Active Directory Default'
      type: 'SQLAzure'
    }
  }
}]

The name is required to be connectionstrings and the parent is referencing the parent webapp. The looping is occurring on the properties and database connection string.

To Reproduce Steps to reproduce the behavior: VSCode provide squiggly warning and deploying a webapp with a loop of two sql connection strings using the connection string sub-resource provides a deployment warning.

Additional context Add any other context about the problem here.

kplantus avatar Sep 30 '22 18:09 kplantus