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

Add listSubscriptions to resourceApi #829

Merged
merged 6 commits into from
Apr 10, 2024
Merged

Add listSubscriptions to resourceApi #829

merged 6 commits into from
Apr 10, 2024

Conversation

nturinski
Copy link
Member

Relies on microsoft/vscode-azuretools#1703

I was trying to add a getSubscription function on the provider itself, but for some reason, getAzureSubscriptionProvider kept throwing an error, saying that it wasn't a function. 🤷

I'm okay with my current solution, but was really confused as to why it wasn't working.

@nturinski nturinski requested a review from a team as a code owner March 7, 2024 19:24
@alexweininger
Copy link
Member

Which provider did you try to add it to?

@nturinski
Copy link
Member Author

Which provider did you try to add it to?

I added it to src/tree/azure/AzureResourceTreeDataProviderBase.ts

@bwateratmsft
Copy link
Contributor

Why do we need this vs. using the auth package?

@nturinski
Copy link
Member Author

I need a way to list the filtered subscriptions to create my own SubscriptionListStep for a user to select their sub in the Functions and Storage extension. Since I don't think we'd want the client extensions to directly consume the auth package, I was planning on having Resources handle listing the subs out to the clients.

Resources also controls the tenant/subscription filter settings, so I thought it made more sense for it to deliver the list to the clients.

@bwateratmsft
Copy link
Contributor

bwateratmsft commented Mar 8, 2024

I'd still lean toward using the auth package since it internally handles the subscription filters. Also, at a minimum we should designate this API as meant for internal use; I don't want Azure Resources becoming a de facto Azure Account extension.

Perhaps we could implement it on the on the extension's API but not declare it in utils.

@nturinski
Copy link
Member Author

I'd still lean toward using the auth package since it internally handles the subscription filters.

So I was exploring this-- it seems like I could create a VSCodeAzureSubscriptionProvider within Functions. The issue seems that each extension requires permissions to use the Microsoft Authenticator, so unless I'm getting the session from Resources, the user will have to sign in again.

Do you know if there's a way around this? I think for usability, having the user sign in again is a no-go. I'm cool with not exposing it in the API.

@bwateratmsft
Copy link
Contributor

There is not a way around that, it's very intentional on the part of VSCode's auth model that each extension has to explicitly get permission to use an account. That degraded UX makes sense though, I think it's OK to expose this listSubscriptions method in the Azure Resources extension, I just wouldn't put it on the API or docs. Or do, but mark it deprecated with an "for internal use only" message or something like that.

@nturinski
Copy link
Member Author

Do you mean like this?
microsoft/vscode-azuretools#1704

@bwateratmsft
Copy link
Contributor

Do you mean like this? microsoft/vscode-azuretools#1704

Spot on!

@nturinski nturinski merged commit c2ce048 into main Apr 10, 2024
3 checks passed
@nturinski nturinski deleted the nat/listSubs branch April 10, 2024 18:53
@microsoft microsoft locked and limited conversation to collaborators May 26, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants