Name: and Parent: values with modules. #3606
-
|
Background: I need to create 4 virtual networks, 3 of them have an identical first subnet; so to keep the bicep compact, I created a file I don't know what a module name should be I re-use the name of the main resource in the module. Unlike a resource a module doesn't become a single object for use later in the script: to connect resources to one defined the module, my file so I can refer to the vnet's ID later with (I have removed some of the properties to save space.) This works, but uses multiple longish blocks for peering which I would like to replace with calls to a module, if I put the code above into a module file VScode and It's not the most helpful error, especially because the bicep has been transformed so I can't see where the error is or what segment lengths are wrong. By a process of trial and error I can find my use of the resource name as the module name is the problem. In the JSON it looks like this and the problem is solved by changing the name line to Which throws out some questions Thoughts ? |
Beta Was this translation helpful? Give feedback.
Replies: 2 comments 13 replies
-
|
In case this helps here is a sample VNET and also VNET Peering template. https://github.com/brwilkinson/AzureDeploymentFramework/blob/main/ADF/bicep/VNET.bicep If I look in the second file for the Peering I see. resource VNETPeering 'Microsoft.Network/virtualNetworks/virtualNetworkPeerings@2017-10-01' = {
name: peeringName
parent: VNETHUBNotice since I am using the parent, which references the VNET, I only need to provide the single segment for the peering name. If I look at your sample: it looks as if that should be: resource vnetPeering_FooToBar 'Microsoft.Network/virtualNetworks/virtualNetworkPeerings@2020-11-01' = {
parent: vnet_Foo
name: 'PeeringToBar' |
Beta Was this translation helpful? Give feedback.
-
|
This is now being addressed in #3889 |
Beta Was this translation helpful? Give feedback.


In case this helps here is a sample VNET and also VNET Peering template.
https://github.com/brwilkinson/AzureDeploymentFramework/blob/main/ADF/bicep/VNET.bicep
https://github.com/brwilkinson/AzureDeploymentFramework/blob/main/ADF/bicep/VNET-Peering.bicep
If I look in the second file for the Peering I see.
Notice since I am using the parent, which references the VNET, I only need to provide the single segment for the peering name.
If I look at your sample: