I work at a company that has plenty of Azure subscriptions. In Visual Studio, it appears that my 'DefaultAzureSubscription' will not change (or I just dont know how to do it).
For example, I use the below method to initialize my subscription that I want to work in:
public async Task CreateCommonClient()
{
ArmClient = GetArmClient();
Subscription = await ArmClient.GetDefaultSubscriptionAsync();
}
It always defaults to subscription that I do not want to work in.
Does anyone know how to change VS default subscriptions? Please and thank you!
To change default subscriptions in Visual Studio, I could be able to achieve it using
AzureCloudBash
in Vs code terminal.Or
Note: The
az account set
command does not allow you to switch your active subscription to a subscription in a different tenant. To continue, you must first log in as a user within the desired tenant. You will get the following problem if you attempt to set your subscription to a subscription in a different tenant:Refer MSDoc
When I tried in my environment before logging in, I got the same result:
A tenant must have complete control over all active subscriptions in order to change an active subscription. I would suggest you to use the following command and execute it by changing tenant.
You can obtain the active tenant list by using the below command: (if needed)
Reference:
az account
As an alternative, we can choose subscriptions using the command palette, as I suggested in a comment:
Path: "view -> commandPalette -> Azure: Select Subscriptions" (
ctrl+shift+p
)