Offboard Azure tenant with Entra ID only
How to offboard a Microsoft Azure tenant onboarded with the Entra ID only option from Cortex Cloud: A step-by-step technical guide to safely removing deployed resources.
Follow this procedure to offboard a Microsoft Azure tenant that was onboarded with the Entra ID-only option and cleanly decommission all deployed resources.
Important
This offboarding script is designed for environments onboarded with BASE template version 1.0.10 or later. If your onboarding was deployed with an older BASE template version, this script may not fully remove all provisioned resources and could leave orphaned artifacts. Please verify your onboarding template version before proceeding.
Prerequisites
Before you begin, ensure you meet the following requirements:
Tooling Requirements
Bash (version 4.0)
Azure CLI (version 2.61)
jq (JSON processor)
Working directory
You must run the offboarding script from the same directory where the files parameters.sh and graphAPIRoles.json are located. These files are packaged with the onboarding template:
parameters.sh: Contains configuration parameters (such asresource_suffix,tenant_id, andcustomer_object_id) which the script auto-loads at startup.graphAPIRoles.json: Defines the Microsoft Graph app role assignments to remove.
Required Azure permissions
The authenticated session must be run by a user or service principal with the following roles:
Global Administrator: Required for managing Entra ID diagnostic settings and service principal operations.
Owner: Required at the management group scope for deleting deployment stacks, role assignments, role definitions, and resource groups.
Authentication
Run the following command in your terminal to authenticate with the correct Azure tenant:
How to offboard Microsoft Azure with Entra ID only
Run the offboard_entra_id_only.sh script
Run the offboarding script to clean up all deployed infrastructure. For your reference, the following flags are used in the script:
Flag
Description
--management-group-id <mg-id>
Required. Management group ID. Typically this is the tenant-root MG.
--subscription-id <sub-id>
Required. The specific subscription hosting the onboarding resource group.
--resource-suffix <rs>
The resource suffix from onboarding. This is automatically loaded from ./parameters.sh if present in the working directory.
--no-dry-run
Action Flag. By default, the script runs in dry-run (read-only) mode. You must pass this flag to perform actual resource deletions.
--yes or -y
Automation Flag. Skips the interactive confirmation prompt before a destructive run.
--ext-resource-suffix <ext>
Override Flag. Overrides the automatic resolution of the extResourceSuffix. Required if the deployment stack has already been deleted and auto-resolution fails.
First run a dry-run to preview the planned deletions and ensure your permissions are correct:
After reviewing the dry-run output, run the script with
--no-dry-runto delete the resources:
Verification and troubleshooting
Review the script output and confirm that all targeted resources were removed:
Success: You will see a final confirmation message in your terminal indicating that cleanup is complete (Exit Code
0).Leftover Resources: If the script times out or detects that any policy-deployed resources still remain, it will log the specific failed resources in the console output and exit with code
30. This is usually due to transient Azure API replication delays. You can safely re-run the cleanup script with the--no-dry-runflag to trigger another verification and cleanup sweep. See Reference: Script exit codes for the exit code details.
Last updated
Was this helpful?
