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

Sign up or log in

Sign up using Google Sign up using Facebook Sign up using Email and Password

Post as a guest

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.