Delete Virtual Machine Extension: The resource operation completed with terminal provisioning state 'Failed'

Daniel Sotreanu 85 Reputation points
2023-06-15T11:58:23.9366667+00:00

Hello,

I am trying to remove an extension from a VM which was created/cloned from backup.

Operation is failing from Azure Portal like:

"statusMessage": "{\"status\":\"Failed\",\"error\":{\"code\":\"ResourceOperationFailure\",\"message\":\"The resource operation completed with terminal provisioning state 'Failed'.\",\"details\":[{\"code\":\"VMExtensionHandlerNonTransientError\",\"message\":\"The handler for VM extension type 'Microsoft.OSTCExtensions.VMAccessForLinux' has reported terminal failure for VM extension 'VMAccessForLinux' with error message: '[ExtensionError] Non-zero exit code: 1, extension_shim.sh -c ./vmaccess.py -d'.\\r\\n    \\r\\n'Disable handler for the extension failed. More information on troubleshooting is available at https://aka.ms/vmextensionlinuxtroubleshoot'\"}]}}",

The Extension status is:

Code : ProvisioningState/transitioning

Level : Info

DisplayStatus : Transitioning

Message : [ExtensionError] Non-zero exit code: 1, extension_shim.sh -c ./vmaccess.py -d

Any advice? Thank you.

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

1 answer

Sort by: Most helpful
  1. Jackson Martins 10,136 Reputation points MVP
    2023-06-15T13:10:57.2666667+00:00

    Hi @Daniel Sotreanu

    you can use the PowerShell Remove-AzVMExtension cmdlet to forcefully remove the extension. This command would look something like this:

    Remove-AzVMExtension -ResourceGroupName "ResourceGroup11" -VMName "VirtualMachine07" -Name "VMAccessForLinux" -Force
    

    After running this command, Azure should forcefully remove the extension from your VM. If the operation is successful, it won't return any output. If there's an error, it should return an error message that can help you diagnose the issue.

    Use -Force parameter, This parameter will force the removal of the extension without asking for user confirmation.

    Please replace "ResourceGroup11", "VirtualMachine07", and "VMAccessForLinux" with the actual names of your resource group, virtual machine, and extension, respectively.

    Reference: https://learn.microsoft.com/en-us/powershell/module/az.compute/remove-azvmextension?view=azps-10.0.0#examples

    Get in touch if you need more help with this issue.

    --please don't forget to "[Accept the answer]" if the reply is helpful--