How to speed up vm deletion and creation in azure parallelly

Alvaro Vinicius 41 Reputation points
2022-02-03T14:14:01.67+00:00

How to speed up vm deletion and creation in less time in azure parallelly?
What are the possibilities for that?

Azure Virtual Machines
Azure Virtual Machines
An Azure service that is used to provision Windows and Linux virtual machines.
7,585 questions
0 comments No comments
{count} votes

2 answers

Sort by: Most helpful
  1. kobulloc-MSFT 26,131 Reputation points Microsoft Employee
    2022-02-03T16:12:43.333+00:00

    Hello, @Alvaro Vinicius !

    VM removal should be pretty quick and standard while VM creation can depend on the image you are deploying. For questions about parallel jobs in Azure DevOps, you'll want to reach out to the DevOps community where the Azure DevOps Team and DevOps specialists are actively answering questions.

    The Azure CLI will be one of the faster ways to both remove and create VM resources (although you could also use PowerShell and ARM). For VM deletion, az vm delete can be used to delete all VMs in a resource group which can be very useful.

    VM Removal

    Portal:
    The fastest way to remove a VM in the portal is to delete the resource group. You can delete the VM resources individually but some resources are dependent on others which requires that you delete them in a specific order.

    Azure CLI:
    Using az vm delete, you can delete a single VM without confirmation or all VMs in a resource group. This would be faster than using the portal if you are looking to keep the resource group.

    Delete a VM without a prompt for confirmation

    az vm delete -g MyResourceGroup -n MyVm --yes  
    

    VM Creation
    VM creation will vary depending on which image you use. Certain images have faster creation times while others take longer. Linux and server SKUs tend to be better options when you are looking for rapid deployments.

    Here, the CLI/PowerShell and ARM will be your fastest deployment methods:

    CLI:
    https://learn.microsoft.com/en-us/azure/virtual-machines/windows/quick-create-cli

    az group create --name myResourceGroup --location eastus  
      
    az vm create \  
        --resource-group myResourceGroup \  
        --name myVM \  
        --image Win2019Datacenter \  
        --public-ip-sku Standard \  
        --admin-username azureuser  
    

    ARM:
    https://learn.microsoft.com/en-us/azure/virtual-machines/windows/quick-create-template

    1 person found this answer helpful.
    0 comments No comments

  2. Ethan S 1 Reputation point
    2022-04-28T00:23:00.63+00:00

    If you are able to use Powershell, the Az module can help you truly delete a list of VMs as quickly as possible by triggering each deletion in a background "job".

    https://petri.com/stop-microsoft-azure-virtual-machines-in-parallel-with-powershell/

    But a VM has a lot of other associated objects, so you'll want to enumerate and delete those along with the VM.

    https://4sysops.com/archives/delete-an-azure-vm-with-objects-using-powershell/

    0 comments No comments