Thanks for posting your question in the Microsoft Q&A forum.
Ensure that the container_group_name
is correctly constructed and matches the exact name of the container group you want to delete. Verify the name by checking the Azure portal or using Azure CLI commands like az container show
, and make sure that the API version used in the request is compatible with the ContainerInstanceManagementClient
.
The begin_delete
method is asynchronous, meaning the deletion request starts but doesn't wait for it to complete. You should handle this by checking the status of the operation or periodically polling the status.
def delete_aci(task_id, logger):
try:
subscription_id = Config.LOGTUNNEL_SUBSCRIPTION_ID
resource_group_name = Config.LOGTUNNEL_RESOURCE_GROUP_NAME
credential = generate_credentials(logger)
container_group_name = task_id + 'ACIGROUP'
container_client = ContainerInstanceManagementClient(credential, subscription_id)
poller = container_client.container_groups.begin_delete(
resource_group_name,
container_group_name
)
# Wait for the deletion to complete
poller.wait()
logger.log(ST_LOG, f"Container group '{container_group_name}' deletion completed.")
return 0
except Exception as e:
logger.log(ST_ERROR, f'{e}')
return -1
Please don't forget to close up the thread here by upvoting and accept it as an answer if it is helpful