cannot delete container group/instance

Stephen Emm 0 Reputation points
2025-03-09T10:15:35.3766667+00:00

portal gives "Failed to delete the container instances in container group 'cg-dbsak-argent'. Error: Encountered an internal server error."

also unable to delete via az cli.

Azure Container Instances
Azure Container Instances
An Azure service that provides customers with a serverless container experience.
742 questions
0 comments No comments
{count} votes

3 answers

Sort by: Most helpful
  1. Geethasri.V 30 Reputation points Microsoft External Staff
    2025-03-10T17:44:10.9566667+00:00

    Hi Stephen Emm,
    Welcome to the Microsoft Q&A Platform! Thank you for asking your question here.

    Sometimes, resource locks are applied to prevent accidental deletion. Ensure that there are no locks preventing the deletion of the container group or associated resources.

    az lock list --resource-group <ResourceGroupName>
    
    az lock delete --name <lock-name> --resource-group <ResourceGroupName>
    

    Verify that all the associated resources (like networking resources, load balancers, storage accounts, etc.) are correctly deleted. Sometimes, the container instances are attached to a load balancer, and if it's still active or improperly configured, it can block the deletion.

    az network lb list --resource-group <ResourceGroupName>
    az network public-ip list --resource-group <ResourceGroupName>
    

    could you please try forcefully delete the container instance group and see if it clears the error

    az container delete --name cg-dbsak-argent --resource-group <ResourceGroupName> --yes --no-wait
    

    Sometimes the container group might be in an intermediate state (e.g., stopping or restarting). Check if there are ongoing operations

    az container show --name cg-dbsak-argent --resource-group <ResourceGroupName>
    

    If there are pending operations or the status is not "Succeeded" or "Stopped," it might be stuck. You can try to stop it before attempting to delete again.

    library(AzureContainers)

    ## Not run:
    rg <- AzureRMR::get_azure_login()$     get_subscription("subscription_id")$     get_resource_group("rgname")
     
    rg$delete_aci("mycontainer")
     
    ## End(Not run)
    

    please refer this document
    https://learn.microsoft.com/en-us/rest/api/container-instances/container-groups/delete?view=rest-container-instances-2023-05-01&tabs=HTTP

    If it was helpful, please click "Upvote" on this post to let us know.

    Thank You.

    Thank you.

    0 comments No comments

  2. Stephen Emm 0 Reputation points
    2025-03-10T18:12:24.2566667+00:00

    hi,

    Thanks for the update, I did manage to remove the container group/instance in the end. The issue was with mounting an Azure File Share - specifically the mount location in the linux container, this seemed to cause the container group to always be in a "transitioning" (literally, the error was "the container group is still transitioning") state that prevented my bicep scripts from making any adjustments to the resources, and also wouldn't let me delete them. Restarting, then stopping the container group seemed to get it into a state where it could be deleted. Mounting the Azure file share in a different location within the container was the ultimate solution - though i'm not sure why it couldn't be mounted where originally specified i.e. under /mnt/maron


  3. Geethasri.V 30 Reputation points Microsoft External Staff
    2025-03-11T18:29:51.7766667+00:00

    Hi Stephen Emm,

    Thanks for the update! I'm glad you were able to delete the container group. The issue with mounting the Azure File Share likely caused the container group to be stuck in a "transitioning" state due to the following possible reasons:

    Permission Issues: Some container images restrict access to certain system directories, including /mnt, which may have caused the mount failure.

    Conflict with System Processes: Some Linux distributions reserve /mnt for temporary mounts, which could interfere with Azure’s mounting process.

    Container Runtime Restrictions: Depending on the base image, certain paths may be read-only or restricted, preventing the mount from functioning correctly.

    Azure Container Instances (ACI) Specific Behavior: Azure may impose internal constraints on mounting file shares under /mnt, though this is not explicitly documented.

    Since mounting the file share to a different location resolved the issue, it's recommended to use paths like /mnt/data, /azurefiles, or /app/data, which may be more suitable for persistent storage in containers.

    For more details, refer to the documentation: https://learn.microsoft.com/en-us/azure/container-instances/container-instances-volume-azure-files

    If this answer is helpful do click Accept AnswerAnd, if you have any further query do let us know.

    Thank You.

    0 comments No comments

Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.