title: Subnet DemoSubnet is in use and cannot be updated
body: <p>I have created a DemoSubnet and an ElasticIP, then I am trying to deploy a ARM template which has a Virtual machine which is trying to attach with that existing elastic IP. The template works fine initially, and after some time its failing due to below error</p>
  
  <blockquote>
    <p>"At least one resource deployment operation failed. Please list
    deployment operations for details"</p>
  </blockquote>
  
  <p>Here is the detailed error message from the arm template deployment:</p>
  
  <blockquote>
    <p>Details=[{"code":"BadRequest","message":"{\r\n  \"error\": {\r\n<br>
    \"code\": \"InUseSubnetCannotBeUpdated\",\r\n    \"message\": \"Subnet
    DemoSubnet is in use and cannot be updated.\",\r\n    \"details\":
    []\r\n  }\r\n}"}]</p>
  </blockquote>
  
  <p>ARM Temaplate</p>
  
  <p>{
      "$schema": "<a href="https://schema.management.azure.com/schemas/2015-01-01/deploymentTemplate.json#" rel="nofollow noreferrer">https://schema.management.azure.com/schemas/2015-01-01/deploymentTemplate.json#</a>",
      "contentVersion": "1.0.0.0",
      "parameters": {
          "addressPrefixes": {
              "defaultValue": [
                  "10.0.0.0/16"
              ],
             "type": "Array",
              "metadata": {
                  "description": "Address prefix of the virtual network"
              }
          },
          "location": {
              "defaultValue": "[resourceGroup().location]",
              "type": "String",
              "metadata": {
                  "description": "Location for all resources."
              }
          },
          "publicIpNewOrExisting": {
              "defaultValue": "existing",
              "type": "String",
              "metadata": {
                  "description": "Determines whether or not a new public ip should be provisioned."
              }
          },
          "publicIpResourceGroupName": {
              "defaultValue": "[resourceGroup().name]",
              "type": "String",
              "metadata": {
                  "description": "Name of the resource group for the public ip address"
              }
          },
          "storageAccountResourceGroupName": {
              "defaultValue": "[resourceGroup().name]",
              "type": "String",
              "metadata": {
                  "description": "Name of the resource group for the existing storage account"
              }
          },
          "storageNewOrExisting": {
              "defaultValue": "existing",
              "type": "String",
              "metadata": {
                  "description": "Determines whether or not a new storage account should be provisioned."
              }
          },
          "subnetPrefix": {
              "defaultValue": "10.0.0.0/24",
              "type": "String",
              "metadata": {
                  "description": "Subnet prefix of the virtual network"
              }
          },
          "virtualNetworkNewOrExisting": {
              "defaultValue": "existing",
              "type": "String",
              "metadata": {
                  "description": "Determines whether or not a new virtual network should be provisioned."
              }
          },
          "virtualNetworkResourceGroupName": {
              "defaultValue": "[resourceGroup().name]",
              "type": "String",
              "metadata": {
                  "description": "Name of the resource group for the existing virtual network"
              }
          }
      },
      "resources": [
          {
              "type": "Microsoft.Compute/virtualMachines",
              "apiVersion": "2018-10-01",
              "name": "SampleVM",
              "location": "[parameters('location')]",
              "dependsOn": [
                  "[resourceId(parameters('storageAccountResourceGroupName'),'Microsoft.Storage/storageAccounts/', 'SampleStorageAccnt')]",
                  "[resourceId('Microsoft.Network/networkInterfaces/', 'SampleNIF')]"
              ],
              "properties": {
                  "diagnosticsProfile": {
                      "bootDiagnostics": {
                          "enabled": true,
                          "storageUri": "[reference(resourceId(parameters('storageAccountResourceGroupName'),'Microsoft.Storage/storageAccounts/', 'SampleStorageAccnt')).primaryEndpoints.blob]"
                      }
                  },
                  "hardwareProfile": {
                      "vmSize": "Standard_A2"
                  },
                  "networkProfile": {
                      "networkInterfaces": [
                          {
                              "id": "[resourceId('Microsoft.Network/networkInterfaces','SampleNIF')]"
                          }
                      ]
                  },
                  "osProfile": {
                      "adminPassword": "rajnikaur@253",
                      "adminUsername": "adminuser",
                      "computerName": "SampleVM"
                  },
                  "storageProfile": {
                      "dataDisks": [
                          {
                              "createOption": "Empty",
                              "diskSizeGB": 1023,
                              "lun": 0
                          }
                      ],
                      "imageReference": {
                          "offer": "WindowsServer",
                          "publisher": "MicrosoftWindowsServer",
                          "sku": "2016-Datacenter",
                          "version": "latest"
                      },
                      "osDisk": {
                          "createOption": "FromImage"
                      }
                  }
              }
          },
          {
              "type": "Microsoft.Storage/storageAccounts",
              "apiVersion": "2019-04-01",
              "name": "SampleStorageAccnt",
              "location": "[parameters('location')]",
              "kind": "Storage",
              "condition": "[equals(parameters('storageNewOrExisting'), 'existing')]"
          },
          {
              "type": "Microsoft.Network/networkInterfaces",
              "apiVersion": "2019-09-01",
              "name": "SampleNIF",
              "location": "[parameters('location')]",
              "dependsOn": [
                  "[resourceId(parameters('virtualNetworkResourceGroupName'),'Microsoft.Network/virtualNetworks/', 'sampleVnet')]",
                  "[resourceId(parameters('publicIpResourceGroupName'),'Microsoft.Network/publicIPAddresses', 'DemoEIP')]"
              ],
              "properties": {
                  "ipConfigurations": [
                      {
                          "name": "ipconfig",
                          "properties": {
                              "privateIPAllocationMethod": "Dynamic",
                              "publicIPAddress": {
                                  "id": "[resourceId(parameters('publicIpResourceGroupName'),'Microsoft.Network/publicIPAddresses', 'DemoEIP')]"
                              },
                              "subnet": {
                                  "id": "[resourceId(parameters('virtualNetworkResourceGroupName'),'Microsoft.Network/virtualNetworks/subnets', 'sampleVnet', 'DemoSubnet')]"
                              }
                          }
                      }
                  ]
              }
          },
          {
              "type": "Microsoft.Network/publicIPAddresses",
              "apiVersion": "2017-09-01",
              "name": "DemoEIP",
              "location": "[parameters('location')]",
              "properties": {
                  "publicIPAllocationMethod": "Static"
              },
              "condition": "[equals(parameters('publicIpNewOrExisting'), 'existing')]"
          },
          {
              "type": "Microsoft.Network/virtualNetworks",
              "apiVersion": "2017-09-01",
              "name": "sampleVnet",
              "location": "[parameters('location')]",
              "properties": {
                  "addressSpace": {
                      "addressPrefixes": "[parameters('addressPrefixes')]"
                  },
                  "subnets": [
                      {
                          "name": "DemoSubnet",
                          "properties": {
                              "addressPrefix": "[parameters('subnetPrefix')]"
                          }
                      }
                  ]
              },
              "condition": "[equals(parameters('virtualNetworkNewOrExisting'), 'existing')]"
          }
      ]
  }</p>