1

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!

  • 1
    Yes please that would be great. Ive been trying to change it using the command line but it does not persist over to Visual Studio. – Andrew Smith Nov 14 '22 at 19:55
  • The subscription which you are looking for is in same Azure account? And we can configure tenant ID instead of subscription ID. – Jahnavi Nov 16 '22 at 05:36
  • For me, the different subscriptions are within the same tenant. Changing tenant does nothing to change subscription. I cannot seem to change my default subscription within visual studio (not vs code). – Ryan Mar 09 '23 at 04:04

1 Answers1

0

To change default subscriptions in Visual Studio, I could be able to achieve it using AzureCloudBash in Vs code terminal.

az account subscription enable --subscription-id "<subscriptionID>"

Or

 az account set --subscription "<subscriptionID>"

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:

enter image description here

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.

az login --tenant "<TenantID>"

enter image description here

You can obtain the active tenant list by using the below command: (if needed)

enter image description here

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) enter image description here

Jahnavi
  • 3,076
  • 1
  • 3
  • 10
  • This doesn't seem to do anything for me in Visual Studio. The alternative suggestions is also obviously for VS Code, so not applicable. – Ryan Mar 09 '23 at 04:05