Task 01 - Delete Azure resources created during the exercises
Introduction
As part of this training, you created multiple Azure resources (e.g., Resource Group, App Service Plan, App Service, Container Registry, Application Insights, Log Analytics, Microsoft Foundry items). To avoid incurring unnecessary costs, you must remove them now that you’ve completed the exercises.
Description
This task outlines the steps to clean up the Azure resources you created during this lab.
It is preferable to use automated teardown with the Azure Developer CLI to ensure parity with infrastructure definitions. You will use the command azd down as the PRIMARY method to delete all provisioned resources and purge the resource group.
Manual deletion should be treated as an exception path. Only if azd down fails or was not used to provision resources, you can fall back to manually deleting the resource group via Azure CLI or Portal.
Success Criteria
- All provisioned resources for this training lab have been deleted using
azd down --purge --force. - Or, after verifying
azd downwas unsuccessful, as a fallback, the resource group associated created with this training lab has been deleted manually. - You have, at the end of this exercise, verified no lab resources remain.
Learning Resources
Key Tasks
01: Preferred Method – Use azd down
Use the azd down command to clean up all resources if the environment was provisioned using Azure Developer CLI.
WARNING Purging is irreversible. Ensure you are targeting the correct subscription and environment.
Expand this section for detailed steps
-
Open the Terminal window in Visual Studio Code and make sure you are in the root of the repository.
-
To ensure you are working in the correct subscription before executing the
azd downcommand, typeaz account showto view the current context for your Azure Developer CLI connection. The output will look similar to this:{ "environmentName": "AzureCloud", "homeTenantId": "<guid>", "id": "<guid>", "isDefault": true, "managedByTenants": [], "name": "<name-of-your-subscription>", "state": "Enabled", "tenantDefaultDomain": "<tenant-domain>", "tenantDisplayName": "<tenant-name>", "tenantId": "<guid>", "user": { "name": "<your-email>", "type": "user" } } -
Run the following command to delete all resources:
azd down --purge --force - Review the key flags:
--purgepermanently deletes the resource group.--forceskips interactive confirmation.
- Verify what this removes:
- All resources defined in your Bicep templates (App Service, ACR, App Insights, Log Analytics, etc.)
- The resource group (with
--purge)
- If this completes successfully, no manual action is required.
Expand this section for troubleshooting steps
Try following these steps if azd down fails:
-
From Terminal, verify you are in the correct folder containing the
.azureenvironment files. -
Run
azd env listto confirm the environment name. -
Ensure your Azure CLI session is authenticated:
az account show. -
Retry with increased verbosity:
azd down --purge --force --debug. -
If partial deletion occurred, manually delete remaining resources or the resource group (Fallback above).
02: Fallback – Manual Resource Group Deletion
Manually delete the resource group if the environment was not provisioned with azd or if azd down failed after troubleshooting.
Expand this section for detailed steps
Perform the steps in this task ONLY if:
- The environment was not provisioned with
azd, OR azd downfailed after troubleshooting.
Using Azure CLI (fallback)
-
From the Terminal window in Visual Studio Code, run the following command:
az group delete --name <your-resource-group-name> --yes --no-wait -
Replace
<your-resource-group-name>with the name of the resource group you created for this training.
Using Azure Portal (fallback)
- Open the Azure portal
- Navigate to Resource groups.
- Select the training resource group.
- Click Delete resource group.
- Type the name to confirm and select Delete.
03: Verification
Verify that no lab resources remain after cleanup.
Expand this section for detailed steps
-
Run the following verification commands:
# List resource groups in the current subscription az group list --output table # List resources with the name "zava" or "<your-env-name>" according to the naming used during the exercises az resource list --query "[?contains(name, 'zava') || contains(name, '<your-env-name>')]" --output table # List web apps az webapp list --output table # List container registries az acr list --output table -
Verify that the resource group and associated resources used for this lab no longer appear if the cleanup is complete.
Summary
You’ve completed this task. All provisioned resources for this training lab have been deleted using azd down --purge --force, or the resource group has been deleted manually as a fallback.