-
Notifications
You must be signed in to change notification settings - Fork 28
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Microsoft.Network/virtualNetworks/subnets asking to delete on redeploy #2040
Comments
@Scot-Bernard: This is covered in #1687. The third solution in this comment should address your needs. From that comment... resource vnet 'Microsoft.Network/virtualNetworks@2020-06-01' = {
name: 'vnet1'
location: resourceGroup().location
properties: {
addressSpace: {
addressPrefixes: [
'10.0.0.0/16'
]
}
subnets: [
{
name: 'subnet1'
properties: {
addressPrefix: '10.0.0.1/24'
}
}
]
}
// pattern 3 extra resource block inside of parent
resource subnet1 'subnets' existing = {
name: 'subnet1'
}
} // inside of vnet resource
resource networkInterface 'Microsoft.Network/networkInterfaces@2020-11-01' = {
name: 'name'
location: resourceGroup().location
properties: {
ipConfigurations: [
{
name: 'name'
properties: {
privateIPAllocationMethod: 'Dynamic'
subnet: {
id: vnet::subnet1.id // pattern 3 reference for property e.g. id
}
}
}
]
}
} Use the |
Curious if there is something like this for #2042 ... would like to deploy without erasing all my websites each and every time. 🤞🙏 |
Thank you @jarz, that will do to refer the subnet by name while avoiding this issue. As in the same comment is mentioned, I'd like a more integrated support on bicep notation to easily refer to sub-resource array items by name, but that'll be another topic. |
I consider this issue can be closed with the provided solution, thank you again. |
Bicep version
Bicep CLI version 0.24.24 (5646341b0c)
Describe the bug
When declaring a subnet resource separately, referring the vnet as a parent, it works on the first deployment, but gives an error on deleting it on a subsequent deployment when the resource is already created and other resource depends on it, in my case a private endpoint network interface. This doesn't happen if the subnet is declared inside the VNET.
It's expected for the deployment process not trying to delete the subnet resource that hasn't changed on its template definition.
To Reproduce
Declare a vnet and a subnet separately, putting the vnet as parent of the subnet.
Declare a private endpoint pointing to the subnet.
run the az deploy command, the subnet is created.
run the az deploy again, the following error message displays:
Note that the link "aka.ms/deletesubnet" points to a page which mentions this kind of error but in another context.
Additional context
Why do I want to declare the subnet separately may you ask, to output a property referring to it directly avoiding using the vnet subnets array that can't be accessed by name or using a function.
The text was updated successfully, but these errors were encountered: