Azure Bicep - Deploy Mutliple Resource Groups in same Template
Hi, I am new to Bicep and trying to use it to deploy a new environment I am configuring for one of our businesses. I'd like to get to the point where I can just deploy the file and away it goes and deploys as much of the environment as possible:
- Multiple resources groups
- VNet gateway
- Public IP
- x2 Virtual Machines
etc.
I am however falling over at the first hurdle, I am able to deploy a single resource group in the .bicep file but as soon as I try deploying two, VS code is complaining that I cannot deploy more than one. Is there a way round this?
targetScope = 'subscription'
@description('Name of the resource group to create.')
param rgName string = 'rg-vnetwork-01'
param rgName1 string ='rg-routetables-01'
@description('Azure Region the resource group will be created in.')
param rgLocation string = 'uksouth'
resource resourceGroup 'Microsoft.Resources/resourceGroups@2022-09-01' = {
name: rgName
location: rgLocation
}
resource resourceGroup 'Microsoft.Resources/resourceGroups@2022-09-01' = {
name: rgName1
location: rgLocation
}
When I try this VS Code is showing the following:
"Identifier "resourceGroup" is declared multiple times. Remove or rename the duplicates."
Hope someone can help.
Thanks