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

VSCodeAzureSubscriptionProvider.getSubscriptions return empty #1815

Closed
jianyexi opened this issue Nov 11, 2024 · 6 comments
Closed

VSCodeAzureSubscriptionProvider.getSubscriptions return empty #1815

jianyexi opened this issue Nov 11, 2024 · 6 comments
Labels

Comments

@jianyexi
Copy link

jianyexi commented Nov 11, 2024

When sign in with below code , the VSCodeAzureSubscriptionProvider.isSignedIn() return true,

vscode.authentication.getSession("microsoft", scopes, { createIfNone: true });

But the VSCodeAzureSubscriptionProvider.getSubscriptions() return empty, as below code will always return false. I think we need to improve the
VSCodeAzureSubscriptionProvider.isSignedIn method to handle the current signed tenantId in this case as well

if (!(await this.isSignedIn(tenantId))) {

@alexweininger
Copy link
Member

Hi @jianyexi, yes this seems like an issue we need to fix. Have you found a workaround yet or do you need me to investigate and unblock you? If you need, reach out to me on Teams.

@jianyexi
Copy link
Author

jianyexi commented Nov 18, 2024

Hi @jianyexi, yes this seems like an issue we need to fix. Have you found a workaround yet or do you need me to investigate and unblock you? If you need, reach out to me on Teams.

@alexweininger No, I can't find a workaround, I am considering to implement the function of listing subscriptions through the ARM Management SDK, but I will appreciate if it could be fixed in short time.

@alexweininger
Copy link
Member

@jianyexi
Copy link
Author

jianyexi commented Nov 21, 2024

@alexweininger no, The getSessionFromVSCode method returns null in my case because my extension logs in without specifying a tenantId. I propose the following fallback logic:

  1. Retrieve the tenantId from the account.Id.

  2. If the tenantId matches the subscription's tenantId, and no session with a specified tenantId is available,

  3. Fallback to obtaining a session without a tenantId.

@alexweininger
Copy link
Member

Retrieve the tenantId from the account.Id

I don't think this is possible, account.id doesn't always contain the default tenant id.

If the user needs to sign in to a specific tenant in order to list subscriptions, we're going to need you to handle that in your extension. We can work together for a better solution in the long term, but until then we need you to handle that on your own.

There are some methods in the auth package that can help you do this, for example getUnauthenticatedTenants lists the tenants we don't have sessions for. You can call that method if getSubscriptions returns empty and ask the user to sign into one of those tenants.

@alexweininger
Copy link
Member

This issue is fixed by #1827

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants