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

Closed
StephenWeatherford opened this issue Oct 31, 2024 · 4 comments · Fixed by #1819 or #1822
Closed

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

StephenWeatherford opened this issue Oct 31, 2024 · 4 comments · Fixed by #1819 or #1822

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
@StephenWeatherford
Copy link
Contributor Author

@alexweininger What are the plans for this bug? I need to know if I should do a work-around for our next release, which has the change to the new API. Thanks.

@alexweininger
Copy link
Member

@StephenWeatherford I will try to have an answer by tomorrow morning 😄. When are you hoping to release?

@alexweininger
Copy link
Member

@StephenWeatherford what version of the auth package are you using? v3.0.0 included #1789 and I think that should prevent this issue.

@StephenWeatherford
Copy link
Contributor Author

Unfortunately not.

@azuretools-vscode-bot azuretools-vscode-bot bot locked and limited conversation to collaborators Jan 22, 2025
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
2 participants