title: Build a similar VM from an existing VM in Azure
body: <p>I am new to Azure. I have this existing VM. It was built by my colleague and I think he built it through the Marketplace with the Azure portal.</p>
  <p>Now I want to build a new one with the same settings (that have the same performance spec) such as the VM sku, OS disk, and data disk. I don't want to keep any existing data. It will be built in a different RG with a different VNet and subnet. What is the best way to do it?</p>
  <p>I tried to &quot;export template&quot; on the current VM but I think the JSON file just specifies the existing disks and NIC to use, instead of creating new ones. Here is what it looks like</p>
  <pre><code>{
  &quot;$schema&quot;: &quot;https://schema.management.azure.com/schemas/2019-04-01/deploymentTemplate.json#&quot;,
  &quot;contentVersion&quot;: &quot;1.0.0.0&quot;,
  &quot;parameters&quot;: {
      &quot;virtualMachines_myCurrentVM_name&quot;: {
          &quot;defaultValue&quot;: &quot;myCurrentVM&quot;,
          &quot;type&quot;: &quot;String&quot;
      },
      &quot;disks_myCurrentVM_OsDisk_1_xxxxxx_externalid&quot;: {
          &quot;defaultValue&quot;: &quot;/subscriptions/12345678-abcd-abcd-abcd-12345678/resourceGroups/nmtprdarmrgp001/providers/Microsoft.Compute/disks/myCurrentVM_OsDisk_1_xxxxxx&quot;,
          &quot;type&quot;: &quot;String&quot;
      },
      &quot;disks_myCurrentVM_DataDisk_0_externalid&quot;: {
          &quot;defaultValue&quot;: &quot;/subscriptions/12345678-abcd-abcd-abcd-12345678/resourceGroups/nmtprdarmrgp001/providers/Microsoft.Compute/disks/myCurrentVM_DataDisk_0&quot;,
          &quot;type&quot;: &quot;String&quot;
      },
      &quot;networkInterfaces_myCurrentVM290_externalid&quot;: {
          &quot;defaultValue&quot;: &quot;/subscriptions/12345678-abcd-abcd-abcd-12345678/resourceGroups/nmtprdarmrgp001/providers/Microsoft.Network/networkInterfaces/myCurrentVM290&quot;,
          &quot;type&quot;: &quot;String&quot;
      }
  },
  &quot;variables&quot;: {},
  &quot;resources&quot;: [
      {
          &quot;type&quot;: &quot;Microsoft.Compute/virtualMachines&quot;,
          &quot;apiVersion&quot;: &quot;2021-11-01&quot;,
          &quot;name&quot;: &quot;[parameters('virtualMachines_myCurrentVM_name')]&quot;,
          &quot;location&quot;: &quot;westus2&quot;,
          &quot;tags&quot;: {
              &quot;a&quot;: &quot;1&quot;,
              &quot;b&quot;: &quot;2&quot;
          },
          &quot;plan&quot;: {
              &quot;name&quot;: &quot;f5-bigiq-virtual-edition-byol&quot;,
              &quot;product&quot;: &quot;f5-big-iq&quot;,
              &quot;publisher&quot;: &quot;f5-networks&quot;
          },
          &quot;properties&quot;: {
              &quot;hardwareProfile&quot;: {
                  &quot;vmSize&quot;: &quot;Standard_D4_v3&quot;
              },
              &quot;storageProfile&quot;: {
                  &quot;imageReference&quot;: {
                      &quot;publisher&quot;: &quot;f5-networks&quot;,
                      &quot;offer&quot;: &quot;f5-big-iq&quot;,
                      &quot;sku&quot;: &quot;f5-bigiq-virtual-edition-byol&quot;,
                      &quot;version&quot;: &quot;latest&quot;
                  },
                  &quot;osDisk&quot;: {
                      &quot;osType&quot;: &quot;Linux&quot;,
                      &quot;name&quot;: &quot;[concat(parameters('virtualMachines_myCurrentVM_name'), '_OsDisk_1_xxxxxx')]&quot;,
                      &quot;createOption&quot;: &quot;FromImage&quot;,
                      &quot;caching&quot;: &quot;ReadWrite&quot;,
                      &quot;managedDisk&quot;: {
                          &quot;storageAccountType&quot;: &quot;StandardSSD_LRS&quot;,
                          &quot;id&quot;: &quot;[parameters('disks_myCurrentVM_OsDisk_1_xxxxxx_externalid')]&quot;
                      },
                      &quot;deleteOption&quot;: &quot;Detach&quot;,
                      &quot;diskSizeGB&quot;: 120
                  },
                  &quot;dataDisks&quot;: [
                      {
                          &quot;lun&quot;: 0,
                          &quot;name&quot;: &quot;[concat(parameters('virtualMachines_myCurrentVM_name'), '_DataDisk_0')]&quot;,
                          &quot;createOption&quot;: &quot;Attach&quot;,
                          &quot;caching&quot;: &quot;ReadOnly&quot;,
                          &quot;writeAcceleratorEnabled&quot;: false,
                          &quot;managedDisk&quot;: {
                              &quot;storageAccountType&quot;: &quot;StandardSSD_LRS&quot;,
                              &quot;id&quot;: &quot;[parameters('disks_myCurrentVM_DataDisk_0_externalid')]&quot;
                          },
                          &quot;deleteOption&quot;: &quot;Detach&quot;,
                          &quot;diskSizeGB&quot;: 128,
                          &quot;toBeDetached&quot;: false
                      }
                  ]
              },
              &quot;osProfile&quot;: {
                  &quot;computerName&quot;: &quot;[parameters('virtualMachines_myCurrentVM_name')]&quot;,
                  &quot;adminUsername&quot;: &quot;azureuser&quot;,
                  &quot;linuxConfiguration&quot;: {
                      &quot;disablePasswordAuthentication&quot;: true,
                      &quot;ssh&quot;: {
                          &quot;publicKeys&quot;: [
                              {
                                  &quot;path&quot;: &quot;/home/azureuser/.ssh/authorized_keys&quot;,
                                  &quot;keyData&quot;: &quot;ssh-rsa &lt;some key here&gt;&quot;
                              }
                          ]
                      },
                      &quot;provisionVMAgent&quot;: true,
                      &quot;patchSettings&quot;: {
                          &quot;patchMode&quot;: &quot;ImageDefault&quot;,
                          &quot;assessmentMode&quot;: &quot;ImageDefault&quot;
                      }
                  },
                  &quot;secrets&quot;: [],
                  &quot;allowExtensionOperations&quot;: true,
                  &quot;requireGuestProvisionSignal&quot;: true
              },
              &quot;networkProfile&quot;: {
                  &quot;networkInterfaces&quot;: [
                      {
                          &quot;id&quot;: &quot;[parameters('networkInterfaces_myCurrentVM290_externalid')]&quot;
                      }
                  ]
              },
              &quot;diagnosticsProfile&quot;: {
                  &quot;bootDiagnostics&quot;: {
                      &quot;enabled&quot;: true
                  }
              }
          }
      }
  ]
  </code></pre>
  <p>}</p>
  <p>Is it the best way to edit and modify the JSON file, or there is another way to do this? Thanks!</p>