question

RodrigoMoro-1796 avatar image
0 Votes"
RodrigoMoro-1796 asked ManuPhilip commented

Operation 'Image Delete' is not allowed

Hi there,

A couple of week ago some collegues and I were testing the Virtual Machine Scale Set service with a generalized custom Image created from a VM within Azure (something basic, WinServer2019, IIS, etc)

After the test of these services we tried to delete the Resource Group with all the components within it. Everything got deleted but the Azure Image.
The error is the following:

Operation 'Image Delete' is not allowed since the Virtual Machine ScaleSet '/subscriptions/XXXX/resourceGroups/XXXXX/providers/Microsoft.Compute/virtualMachineScaleSets/XXXX' is currently using the Image 'VMXXXXX-image-XXXXXX'.

The fact is that the VMSS is deleted and nothing but the Image is in the Resource Group.

I tried using PowerShell, AzureCLI, trying to create a new VMSS over that Image... nothing worked.
It seems that got linked to a ghost VMSS. That happened to some of my collegues too.

Could anyone plase help me on this?
It could be a pain and generate unnecessary charges.

Happy to provide any additional information you may need.

Thanks in advance,

azure-virtual-machines-scale-setazure-virtual-machines-images
5 |1600 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.

ManuPhilip avatar image
0 Votes"
ManuPhilip answered ManuPhilip edited

The error message indicates that there is a VM image exists and due to that deletion is not working.
Let's check that using any of the following cmdlets

 az image list --output table
 az image list --resource-group

Delete those images first and see how it goes

5 |1600 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.

RodrigoMoro-1796 avatar image
0 Votes"
RodrigoMoro-1796 answered

I cannot remove the Image. That is the only existing component in the resource group.

Output of your commands:

PS C:\> az image list --output table
HyperVGeneration Location Name ProvisioningState ResourceGroup


V1 westeurope VM1-image-20211116202900 Succeeded CICE-VMSS-LB



PS C:\> az image list --resource-group CICE-VMSS-LB
[
{
"extendedLocation": null,
"hyperVGeneration": "V1",
"id": "/subscriptions/XXXXXXXXXXXXXXX/resourceGroups/CICE-VMSS-LB/providers/Microsoft.Compute/images/VM1-image-20211116202900",
"location": "westeurope",
"name": "VM1-image-20211116202900",
"provisioningState": "Succeeded",
"resourceGroup": "CICE-VMSS-LB",
"sourceVirtualMachine": {
"id": "/subscriptions/XXXXXXXXXXXXXXX/resourceGroups/CICE-VMSS-LB/providers/Microsoft.Compute/virtualMachines/VM1",
"resourceGroup": "CICE-VMSS-LB"
},
"storageProfile": {
"dataDisks": [],
"osDisk": {
"blobUri": null,
"caching": "ReadWrite",
"diskEncryptionSet": null,
"diskSizeGb": 127,
"managedDisk": {
"id": "/subscriptions/XXXXXXXXXXXXXXX/resourceGroups/CICE-VMSS-LB/providers/Microsoft.Compute/disks/VM1_OsDisk_1_60f76b34bef24cc5ac1ed0c195c37909",
"resourceGroup": "CICE-VMSS-LB"
},
"osState": "Generalized",
"osType": "Windows",
"snapshot": null,
"storageAccountType": "Premium_LRS"
},
"zoneResilient": false
},
"tags": {},
"type": "Microsoft.Compute/images"
}
]

5 |1600 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.

ManuPhilip avatar image
0 Votes"
ManuPhilip answered

It is evident from the error message that, deletion is not possible as there is an associated image. As, you need to retain the image, what you think moving the image to a different Resource Group and delete gracefully?

5 |1600 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.

RodrigoMoro-1796 avatar image
0 Votes"
RodrigoMoro-1796 answered RodrigoMoro-1796 commented

Thanks for the suggestion.
I've just tried to move the image to another new empty resource group. This error is shown:

Error code: ResourceMoveFailed
Message:
Resources '/subscriptions/XXXXXXXXX/resourceGroups/CICE-VMSS-LB/providers/Microsoft.Compute/images/VM1-image-20211116202900' move actions failed. The correlation Id is 'c79f3cc4-a34a-4867-a20f-0b336a0af233'

{
"statusCode": "Conflict",
"statusMessage": "{\"error\":{\"code\":\"ResourceMoveFailed\",\"message\":\"Resources '/subscriptions/XXXXXXXXX/resourceGroups/CICE-VMSS-LB/providers/Microsoft.Compute/images/VM1-image-20211116202900' move actions failed. The correlation Id is 'c79f3cc4-a34a-4867-a20f-0b336a0af233'\",\"details\":[{\"code\":\"InternalOperationError\",\"target\":\"Microsoft.Compute/images\",\"message\":\"An internal error occurred in the operation.\"}]}}",
"eventCategory": "Administrative",
"entity": "/subscriptions/XXXXXXXXX/resourceGroups/CICE-VMSS-LB",
"message": "Microsoft.Resources/subscriptions/resourceGroups/moveresources/action",
"hierarchy": "XXXXXXXXX"
}


· 4
5 |1600 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.

Please share the command you tried for this move. Also, use -Verbose to get more details on the error message.

You may also try the command something as below:

 Move-AzResource -ResourceId <your resource id> -DestinationSubscriptionId <destination subscription id> -DestinationResourceGroupName <Resource Group Nmae> -Force
0 Votes 0 ·

I tried the movement using Azure Portal.
Using the PowerShell command I'm getting something similar:

 PS C:\> Move-AzResource -ResourceId "/subscriptions/XXXXXXXXXXXX/resourceGroups/CICE-VMSS-LB/providers/Microsoft.Compute/images/VM1-image-20211116202900" -DestinationSubscriptionId "XXXXXXXXXXXX" -DestinationResourceGroupName "RG-Image-Error" -Force -Verbose
    
 VERBOSE: Performing the operation "Moving the resources." on target "/subscriptions/XXXXXXXXXXXX/resourceGroups/RG-Image-Error".
 Move-AzResource: ResourceMoveProviderValidationFailed : Resource move validation failed. Please see details. Diagnostic information: timestamp '20211215T173121Z', subscription id 'XXXXXXXXXXXX', tracking id 'f823431e-a011-469b-a4e5-59bac7cb01b6', request correlation id 'ca8a3d00-d09b-4293-bc94-100914360b1e'.
 CorrelationId: 7e6e8d7e-7cef-479b-8048-59eb7a197457



0 Votes 0 ·

Following is a good reference showing the tips while moving resources across. Make sure that you are following the pre-requisites as well as the command is correct
https://docs.microsoft.com/en-us/azure/azure-resource-manager/management/move-resource-group-and-subscription

0 Votes 0 ·
Show more comments
RodrigoMoro-1796 avatar image
0 Votes"
RodrigoMoro-1796 answered

The action meets all requirements.

The goal is to remove the Azure VM Image.
So far we have tried:

  • removing it directly

  • removing the resource group where the Image is located

  • creating a new VM or VMSS based on that Image just to test if that can become again to live and remove it

  • moving to another resource group

All those action failed from Azure Portal, Azure CLI and PowerShell show the above errors (I'm the owner of the sub and global admin).
I would say it is a bug in Azure, somehow. And that happened, as I said, to some of my colleagues too.

Is there any possibility from Microsoft Azure to review this case and take part?

Thank you so much!

5 |1600 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.

ManuPhilip avatar image
0 Votes"
ManuPhilip answered

Even though you says that the VMSS has been deleted, the reason for unable to delete the image says that the VMSS exists and the image is used by the VM.
So, check if the VMSS is still there

 Get-AzVmss -ResourceGroupName "Group001"


5 |1600 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.

RodrigoMoro-1796 avatar image
0 Votes"
RodrigoMoro-1796 answered

Here you have the list of resources:

158343-image.png



image.png (30.3 KiB)
5 |1600 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.

RodrigoMoro-1796 avatar image
0 Votes"
RodrigoMoro-1796 answered

All these accounts, from differents subscriptions, are impacted by the same bug too:

  • /subscriptions/739933XXXXXXe99/resourceGroups/CICE-VMSS-LB/providers/Microsoft.Compute/images/VM1-image-20211116202518

  • /subscriptions/dc2834XXXXXXb7e/resourceGroups/CICE-VMSS-LB/providers/Microsoft.Compute/images/VM1-image-20211116202614

  • /subscriptions/aa52f0XXXXXX0b0/resourceGroups/CICE/providers/Microsoft.Compute/images/OS-image-20211210140020

  • /subscriptions/c2084XXXXXX4fe5/resourceGroups/CICE-VMSS-LB/providers/Microsoft.Compute/images/VM1-image-20211116202538

  • /subscriptions/cdd0XXXXXX3a5/resourceGroups/CICE-VMSS-LB/providers/Microsoft.Compute/images/vm1-image-20211116202218

  • /subscriptions/5890XXXXXXf66/resourceGroups/CICE-VMSS-LB/providers/Microsoft.Compute/images/VM1-image-20211118203957

  • /subscriptions/062feXXXXXX93d/resourceGroups/CICE-VMSS-LB/providers/Microsoft.Compute/images/VM1-image-20211116202900

I would appreciate any help on this.
Thanks,

5 |1600 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.

ManuPhilip avatar image
0 Votes"
ManuPhilip answered

Extending the support on fixing your issue in a different approach: The new info provided gives a direction to try it by sending REST API DELETE calls

Reference- How to start REST Calls: https://docs.microsoft.com/en-us/azure/governance/resource-graph/first-query-rest-api#rest-api-and-powershell
Delete image reference: https://docs.microsoft.com/en-us/previous-versions/azure/reference/dn499769(v=azure.100)?redirectedfrom=MSDN

An example below (using the first image name)

 # Invoke the REST API
 $restUri = https://management.core.windows.net/739933XXXXXXe99/services/vmimages/VM1-image-20211116202518
 $response = Invoke-RestMethod -Uri $restUri -Method DELETE -Headers $authHeader

Hope, these steps will help you finally

5 |1600 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.

RodrigoMoro-1796 avatar image
0 Votes"
RodrigoMoro-1796 answered

1st try: The Azure REST API does not find the resource:

160194-image.png

2nd try: If I search for VMImages names, I'm getting the list, filtering them out by my resource name I'm also getting nothing:

160108-image.png

3rd try: If I try with the other REST API, I can see the VMImage but nothing else:

160163-image.png




image.png (130.1 KiB)
image.png (93.2 KiB)
image.png (59.0 KiB)
5 |1600 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.