แก้ไข

แชร์ผ่าน


Use multiple Azure subscriptions

Most Azure users only have a single subscription. However, if you are part of more than one organization or your organization has divided up access to certain resources across groupings, you may have multiple subscriptions within Azure.

For detailed information on subscriptions, billing, and cost management, see the billing and cost management documentation.

Tenants, users, and subscriptions

You might have some confusion over the difference between tenants, users, and subscriptions within Azure. A tenant is the Microsoft Entra entity that encompasses a whole organization. This tenant has at least one subscription and user. A user is an individual and is associated with only one tenant, the organization that they belong to. Users are those accounts that sign in to Azure to create, manage, and use resources. A user may have access to multiple subscriptions, which are the agreements with Microsoft to use cloud services, including Azure. Every resource is associated with a subscription.

To learn more about the differences between tenants, users, and subscriptions, see the Azure cloud terminology dictionary. To learn how to add a new subscription to your Microsoft Entra tenant, see Associate or add an Azure subscription to your Microsoft Entra tenant. To learn how to sign in to a specific tenant, see Sign in with Azure PowerShell.

Change the active subscription

In Azure PowerShell, accessing the resources for a subscription requires changing the subscription associated with your current Azure session. This is done by modifying the active session context, the information about which tenant, subscription, and user cmdlets should be run against. In order to change subscriptions, you use the Set-AzContext cmdlet to change the current context.

The following example shows how to change the context in your current Azure session:

Set-AzContext -Subscription <subscription name or id>

You can use the Get-AzSubscription cmdlet to retrieve a list of your Azure subscriptions.

To learn more about Azure PowerShell contexts, including how to save them and switch between them for working with multiple subscriptions, see Persist credentials with Azure PowerShell contexts.