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
It is possible to use the
--no-wait
flag with theaz 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.
I have reproduced in my environment and got below results:
I have one VM named
srivm
with Resource ID like below:When I ran the same command as you to delete VM, I got same error as below:
Response:
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:To resolve the error, upgrade your CLI version to latest version with
az upgrade
command or downloadazure-cli-2.43.0.exe
directly.After installing the latest version, I’m able to delete the VM successfully after running below command:
Response:
To confirm that, I checked Portal and VM deleted successfully like below: