0

I started deploying a VM from a bicep template. https://learn.microsoft.com/en-us/azure/virtual-machines/windows/quick-create-bicep?tabs=CLI

It creates a RG, VM, etc as expected

After adding a new subnet to the VNET the subnet get's deleted when I run the VM deployment again.

I want to add other VMs to the resource group without deleting the other subnets in the VNET.

Please advise.

I tried using the --mode Incremental option but it still deletes the other subnets

  • are you defining subnet inside the vnet resource or on their own ? could you please share relevant part of your bicep files ? – Thomas Nov 22 '22 at 01:23
  • Hi Thomas, I'm not experienced yet in Bicep. resource vn 'Microsoft.Network/virtualNetworks@2021-02-01' = { name: virtualNetworkName location: location properties: { addressSpace: { addressPrefixes: [ addressPrefix ] } subnets: [ { name: subnetName properties: { addressPrefix: subnetPrefix networkSecurityGroup: { id: securityGroup.id – jerrol skwarf Nov 22 '22 at 16:45
  • resource nic 'Microsoft.Network/networkInterfaces@2021-02-01' = { name: nicName location: location properties: { ipConfigurations: [ { name: 'ipconfig1' properties: { privateIPAllocationMethod: 'Dynamic' publicIPAddress: { id: pip.id } subnet: { id: resourceId('Microsoft.Network/virtualNetworks/subnets', vn.name, subnetName) } – jerrol skwarf Nov 22 '22 at 16:50
  • I used the template bicep file from: https://learn.microsoft.com/en-us/azure/virtual-machines/windows/quick-create-bicep?tabs=CLI I have not edited the file – jerrol skwarf Nov 22 '22 at 16:51
  • ARM/Bicep is declarative so it will seek the goal state defined in the template. IOW if you don't have all of the subnets defined in the template, then any not defined in the template will be removed, since they are not in the desired goal state. If you want to keep any added, you need to add them to the template before deploying it again. – bmoore-msft Nov 28 '22 at 21:31

0 Answers0