Bicep Modules and Loop

how I can use loop in modules in Bicep?

I mean like this.

module vnet01 'vNet.bicep' = [ for vnet in vnets :  { 
        name: vnet.name
        scope:  virtualNetworkRg
        params: { 
          vnetName: vnet.name
          vnetAddressPrefix: vnet.vnetAddressPrefix
          location: location
        }
      }]

I get the error when I run the code

{'code': 'InvalidTemplate', 'message': "Deployment template validation failed: 'The resource ' at line '128' and column '5' is defined multiple times in a template. Please see for usage details.'.", 'additionalInfo': [{'type': 'TemplateViolation', 'info': {'lineNumber': 128, 'linePosition': 5, 'path': 'properties.template.resources[2]'}}]}

Thank you for your support

1

1 Answer

There was a problem in my code (twice use from vnet.name). Thank you from your support.

1

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

David Miller

David Miller

Executive Financial & Market Analyst

David Miller brings 15 years of experience in global economics, personal finance strategy, and market dynamics. He specializes in turning complex economic trends into actionable insights for everyday readers.

Share this article
Twitter Facebook Pinterest