Transfer an Azure subscription to a different Microsoft Entra directory
Artikkeli
Organizations might have several Azure subscriptions. Each subscription is associated with a particular Microsoft Entra directory. To make management easier, you might want to transfer a subscription to a different Microsoft Entra directory. When you transfer a subscription to a different Microsoft Entra directory, some resources aren't transferred to the target directory. For example, all role assignments and custom roles in Azure role-based access control (Azure RBAC) are permanently deleted from the source directory and aren't transferred to the target directory.
This article describes the basic steps you can follow to transfer a subscription to a different Microsoft Entra directory and re-create some of the resources after the transfer.
Huomautus
For Azure Cloud Solution Providers (CSP) subscriptions, changing the Microsoft Entra directory for the subscription isn't supported.
Overview
Transferring an Azure subscription to a different Microsoft Entra directory is a complex process that must be carefully planned and executed. Many Azure services require security principals (identities) to operate normally or even manage other Azure resources. This article tries to cover most of the Azure services that depend heavily on security principals, but isn't comprehensive.
Tärkeä
In some scenarios, transferring a subscription might require downtime to complete the process. Careful planning is required to assess whether downtime will be required for your transfer.
The following diagram shows the basic steps you must follow when you transfer a subscription to a different directory.
Prepare for the transfer
Transfer the Azure subscription to a different directory
Re-create resources in the target directory such as role assignments, custom roles, and managed identities
Deciding whether to transfer a subscription to a different directory
The following are some reasons why you might want to transfer a subscription:
Because of a company merger or acquisition, you want to manage an acquired subscription in your primary Microsoft Entra directory.
Someone in your organization created a subscription and you want to consolidate management to a particular Microsoft Entra directory.
You have applications that depend on a particular subscription ID or URL and it isn't easy to modify the application configuration or code.
A portion of your business has been split into a separate company and you need to move some of your resources into a different Microsoft Entra directory.
You want to manage some of your resources in a different Microsoft Entra directory for security isolation purposes.
Alternate approaches
Transferring a subscription requires downtime to complete the process. Depending on your scenario, you can consider the following alternate approaches:
Re-create the resources and copy data to the target directory and subscription.
Adopt a multi-directory architecture and leave the subscription in the source directory. Use Azure Lighthouse to delegate resources so that users in the target directory can access the subscription in the source directory. For more information, see Azure Lighthouse in enterprise scenarios.
How to block subscription transfers
Depending on your organization, you might want to block the transfer of subscriptions to different directories in your organization. If you want to instead block the transfer of subscriptions, you can configure a subscription policy. For more information, see Manage Azure subscription policies.
Understand the impact of transferring a subscription
Several Azure resources have a dependency on a subscription or a directory. Depending on your situation, the following table lists the known impact of transferring a subscription. By performing the steps in this article, you can re-create some of the resources that existed prior to the subscription transfer.
Tärkeä
This section lists the known Azure services or resources that depend on your subscription. Because resource types in Azure are constantly evolving, there might be additional dependencies not listed here that can cause a breaking change to your environment.
All role assignments are permanently deleted. You must map users, groups, and service principals to corresponding objects in the target directory. You must re-create the role assignments.
You cannot transfer an Azure SQL database with Microsoft Entra authentication enabled to a different directory. For more information, see Use Microsoft Entra authentication.
Azure Database for MySQL with Microsoft Entra authentication integration enabled
Yes
No
You cannot transfer an Azure database for MySQL (Single and Flexible server) with Microsoft Entra authentication enabled to a different directory.
Azure Database for PostgreSQL Flexible Server with Microsoft Entra authentication integration enabled or with Customer Managed Key enabled
Yes
No
You cannot transfer an Azure Database for PostgreSQL with Microsoft Entra authentication or with Customer Managed Key enabled to a different directory. You have to disable these features first, transfer the server, and then re-enable these features.
Azure Storage and Azure Data Lake Storage Gen2
Yes
Yes
You must re-create any ACLs.
Azure Files
Yes
In most scenarios
You must re-create any ACLs. For storage accounts with Microsoft Entra Kerberos authentication enabled, you must disable and re-enable Microsoft Entra Kerberos authentication after the transfer. For Microsoft Entra Domain Services, transferring to another Microsoft Entra directory where Microsoft Entra Domain Services is not enabled is not supported.
If you're using Disk Encryption Sets to encrypt Managed Disks with customer-managed keys, you must disable and re-enable the system-assigned identities associated with Disk Encryption Sets. And you must re-create the role assignments to again grant required permissions to Disk Encryption Sets in the Key Vaults.
You cannot transfer a dev box and its associated resources to a different directory. Once a subscription moves to another tenant, you will not be able to perform any actions on your dev box
Azure Deployment Environments
Yes
No
You cannot transfer an environment and its associated resources to a different directory. Once a subscription moves to another tenant, you will not be able to perform any actions on your environment
Export Azure resource locks manually using the Azure portal or Azure CLI.
Varoitus
If you're using encryption at rest for a resource, such as a storage account or SQL database, that has a dependency on a key vault that is being transferred, it can lead to an unrecoverable scenario. If you have this situation, you should take steps to use a different key vault or temporarily disable customer-managed keys to avoid this unrecoverable scenario.
Billing account owner of the subscription you want to transfer in the source directory
A user account in both the source and target directory for the user making the directory change
Step 1: Prepare for the transfer
Sign in to source directory
Sign in to Azure as an administrator.
Get a list of your subscriptions with the az account list command.
Azure CLI
az account list --output table
Use az account set to set the active subscription you want to transfer.
Azure CLI
az account set --subscription"Marketing"
Install the Azure Resource Graph extension
The Azure CLI extension for Azure Resource Graph, resource-graph, enables you to use the az graph command to query resources managed by Azure Resource Manager. You'll use this command in later steps.
Use az extension list to see if you have the resource-graph extension installed.
Azure CLI
az extension list
If you're using a preview version or an older version of the resource-graph extension, use az extension update to update the extension.
Azure CLI
az extension update --name resource-graph
If the resource-graph extension isn't installed, use az extension add to install the extension.
Azure CLI
az extension add --name resource-graph
Save all role assignments
Use az role assignment list to list all the role assignments (including inherited role assignments).
az role assignment list --all--include-inherited--output json > roleassignments.json
az role assignment list --all--include-inherited--output tsv > roleassignments.tsv
az role assignment list --all--include-inherited--output table > roleassignments.txt
Save the list of role assignments.
When you transfer a subscription, all of the role assignments are permanently deleted so it's important to save a copy.
Review the list of role assignments. There might be role assignments you won't need in the target directory.
Determine user, group, and service principal mappings
Based on your list of role assignments, determine the users, groups, and service principals you will map to in the target directory.
You can identify the type of principal by looking at the principalType property in each role assignment.
If necessary, in the target directory, create any users, groups, or service principals you will need.
List role assignments for managed identities
Managed identities don't get updated when a subscription is transferred to another directory. As a result, any existing system-assigned or user-assigned managed identities will be broken. After the transfer, you can re-enable any system-assigned managed identities. For user-assigned managed identities, you will have to re-create and attach them in the target directory.
Use az ad sp list to list your system-assigned and user-assigned managed identities.
Azure CLI
az ad sp list --all--filter"servicePrincipalType eq 'ManagedIdentity'"
In the list of managed identities, determine which are system-assigned and which are user-assigned. You can use the following criteria to determine the type.
Criteria
Managed identity type
alternativeNames property includes isExplicit=False
System-assigned
alternativeNames property does not include isExplicit
System-assigned
alternativeNames property includes isExplicit=True
Get a list of the objectId values for your managed identities.
Search your list of role assignments to see if there are any role assignments for your managed identities.
List key vaults
When you create a key vault, it is automatically tied to the default Microsoft Entra tenant ID for the subscription in which it is created. All access policy entries are also tied to this tenant ID. For more information, see Moving an Azure Key Vault to another subscription.
Varoitus
If you are using encryption at rest for a resource, such as a storage account or SQL database, that has a dependency on a key vault that is being transferred, it can lead to an unrecoverable scenario. If you have this situation, you should take steps to use a different key vault or temporarily disable customer-managed keys to avoid this unrecoverable scenario.
subscriptionId=$(az account show --output tsv --query id)
Use the az graph extension to list other Azure resources with known Microsoft Entra directory dependencies (in bash).
Azure CLI
az graph query -q'resources
| where type != "microsoft.azureactivedirectory/b2cdirectories"
| where identity <> "" or properties.tenantId <> "" or properties.encryptionSettingsCollection.enabled == true
| project name, type, kind, identity, tenantId, properties.tenantId'--subscriptions$subscriptionId--output yaml
Step 2: Transfer the subscription
In this step, you transfer the subscription from the source directory to the target directory. The steps will be different depending on whether you want to also transfer the billing ownership.
Varoitus
When you transfer the subscription, all role assignments in the source directory are permanently deleted and cannot be restored. You cannot go back once you transfer the subscription. Be sure you complete the previous steps before performing this step.
Determine whether you want to also transfer the billing ownership to another account.
Transfer the subscription to a different directory.
If you are using Azure Files, assign the appropriate ACLs.
Review other security methods
Even though role assignments are removed during the transfer, users in the original owner account might continue to have access to the subscription through other security methods, including:
Remote Access credentials for services like Azure Virtual Machines.
If your intent is to remove access from users in the source directory so that they don't have access in the target directory, you should consider rotating any credentials. Until the credentials are updated, users will continue to have access after the transfer.
Explore how to use built-in Azure roles, managed identities, and RBAC-policy to control access to Azure resources. Identity is the key to secure solutions.
Esittele Microsoft Entra ID:n ominaisuuksia, joilla nykyaikaistat käyttäjätietoratkaisuja, otat käyttöön hybridiratkaisuja ja toteutat käyttäjätietojen hallinnan.