Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

getSubscriptions() throws if user has signed in to two accounts #1809

Open
StephenWeatherford opened this issue Oct 31, 2024 · 0 comments
Open

Comments

@StephenWeatherford
Copy link
Contributor

  1. run the script from Use vscode authentication instead of Azure Account extension Azure/bicep#15403 (comment) to install a version of the Bicep extension that uses the new @microsoft/vscode-azext-azureauth functionality
  2. Using azureResourceGroups.login, log in to two different accounts in Azure. (Note: I did this because I was testing a different Azure account, but it wasn't obvious how to sign out of the first one, I assumed this would do it.)
  3. Create a new main.bicep file and save it with:
resource storageaccount 'Microsoft.Storage/storageAccounts@2021-02-01' = {
  name: 'name'
  location: 'westus3'
  kind: 'StorageV2'
  sku: {
    name: 'Premium_LRS'
  }
}
  1. in the editor's context menu for main.bicep, click "Deploy Bicep File..."
  2. Click enter for default deployment name
    !) Next you should see a picklist of subscriptions, but you will instead see ,in the Output window, under "Bicep Operations", this error:

1:57:16 PM: Deployment failed for c:\Users\stephwe\Downloads\main.bicep. You are not signed in to an Azure account. Please sign in.
EXPECTED: should work

More details:
Image
We call isSignedIn(), which finds that there's a session open for the first account and returns true. So then we call getSubscriptions(), which calls getTenants() on each account. The second getTenants() call throws because the second account doesn't have an open session:

Image

getSubscriptionClient (vscode-bicep\node_modules\@microsoft\vscode-azext-azureauth\out\src\VSCodeAzureSubscriptionProvider.js:297)
getTenants (vscode-bicep\node_modules\@microsoft\vscode-azext-azureauth\out\src\VSCodeAzureSubscriptionProvider.js:80)
getSubscriptions (vscode-bicep\node_modules\@microsoft\vscode-azext-azureauth\out\src\VSCodeAzureSubscriptionProvider.js:138)
@StephenWeatherford StephenWeatherford changed the title @microsoft/vscode-azext-azureauth getSubscriptions() throws if user has signed in to two accounts Oct 31, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant