As continuation of the blog about creating Azure container instance in Typescript with dynamic environment variables, in this blog I’ll show the way we can delete multiple container instances at once.

The command is simple

1
az container list --resource-group test-project --query=[0:50].id | sed 's/\[//' | sed 's/\]//' | sed 's/,/ /' | xargs az container delete --yes --id

In above command, I just use simple query condition that selects first 50 container instances in the account. You can customize the query parameter to filter the container instances will be deleted by using https://jmespath.org/.