Open qooiprww opened 1 year ago
/cc @weidongxu-microsoft
@qooiprww
Delete in step 3 takes time. It could be a minutes or 2. Meanwhile, List in step 4 could still return the VM.
But all depends on timing. If now in step5, when you call the refreshInstanceView
, the VM just get deleted in backend, you will have error.
If you do the refreshInstanceView
when you know the VM may be in the process of getting deleted, please do error handling in your code.
it appears that step 4 is still returning the deleted VM after the delete process is finished.
@qooiprww
Although the virtual machine has been deleted in step 3, the provisioningState
of virtual machine remains in Deleting
because the backend process has not been completed, so the List in step 4 can still return the VM. I think it is necessary to add filter .filter(virtualMachine -> !"Deleting".equals(virtualMachine.provisioningState()))
for com.azure.resourcemanager.compute.models.VirtualMachines.list()
.
Thanks! I'll give it a try and monitor for exceptions.
I did some testing with deleted VMs:
After deleting the VM and verified that it's no longer visible in the Resource Group, the com.azure.resourcemanager.compute.models.VirtualMachines.list()
request still returned deleted vm with provisioningState Succeeded
@qooiprww
Please elaborate on how you did step 3
. If you are doing this via APIs, please provide relevant test code snippets, thanks!
Describe the bug
com.azure.resourcemanager.compute.models.VirtualMachines.list()
query returns deleted VM. Fetching details using the returned VM object will result inResourceNotFound
ApiErrorException
To Reproduce
com.azure.resourcemanager.compute.models.VirtualMachines.list()
com.azure.resourcemanager.compute.models.VirtualMachines.list()
with the same clientrefreshInstanceView
ApiErrorException
with codeResourceNotFound