skip to Main Content

I am trying to delete a virtual machine using the command below

az resource delete --ids /subscriptions/0b1f6471-1bf0-4dda-aec3-111111111111/resourceGroups/MyResourceGroup/providers/Microsoft.Network/virtualMachines/vmlname1 --no-wait

I am getting this error:

unrecognized arguments: --no-wait

When I remove –no-wait it works

By this link:

https://learn.microsoft.com/en-us/cli/azure/resource?view=azure-cli-latest#az-resource-delete-optional-parameters

no-wait is given as a valid parameter

--no-wait
Do not wait for the long-running operation to finish.

Can anyone tell me, whether it is possible to use –no-wait in az resource delete ?

Update:
This is the az cli version i am using:

{
  "azure-cli": "2.40.0",
  "azure-cli-core": "2.40.0",
  "azure-cli-telemetry": "1.0.8",

Thanks

2

Answers


  1. It is possible to use the --no-wait flag with the az resource delete command. My testing using the flag did not produce the error that you are seeing. Is it possible that your azure cli is not up to date?

    You can upgrade your azure cli to the latest version by following these instructions.

    Login or Signup to reply.
  2. I have reproduced in my environment and got below results:

    I have one VM named srivm with Resource ID like below:

    enter image description here
    When I ran the same command as you to delete VM, I got same error as below:

    az resource delete --ids /subscriptions/<subID>/resourceGroups/<rgname>/providers/Microsoft.Network/virtualMachines/<vmname> --no-wait  
    

    Response:

    enter image description here

    Note that, the current version of the Azure CLI is 2.43.0. The error may occur if the CLI version is less than latest version.

    When I checked the az version, I got response like below:

    enter image description here

    To resolve the error, upgrade your CLI version to latest version with az upgrade command or download azure-cli-2.43.0.exe directly.

    After installing the latest version, I’m able to delete the VM successfully after running below command:

    az resource delete --ids /subscriptions/<subID>/resourceGroups/<rgname>/providers/Microsoft.Network/virtualMachines/<vmname> --no-wait  
    

    Response:

    enter image description here
    To confirm that, I checked Portal and VM deleted successfully like below:

    enter image description here

    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search