-
Notifications
You must be signed in to change notification settings - Fork 757
Detect and surface Azure credential provider selection for local provisioning #13538
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
base: main
Are you sure you want to change the base?
Conversation
Co-authored-by: davidfowl <95136+davidfowl@users.noreply.github.com>
Co-authored-by: davidfowl <95136+davidfowl@users.noreply.github.com>
| /// <summary> | ||
| /// Detects available Azure credential providers in the user's environment. | ||
| /// </summary> | ||
| internal sealed class CredentialProviderDetector(ILogger<CredentialProviderDetector> logger) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Simplify this logic and just use the TokenCredential and don't check for stuff on the PATH or by running commands. Just delegate.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Simplified credential detection to use TokenCredential directly. Now creates credential instances and attempts GetTokenAsync with a 5-second timeout instead of checking PATH or running commands. Fixed in 2f9b506.
|
|
||
| await using (task.ConfigureAwait(false)) | ||
| { | ||
| var loggerFactory = Microsoft.Extensions.Logging.Abstractions.NullLoggerFactory.Instance; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Don't do this for the logger. There's one injected.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Fixed to use the injected logger. Changed CredentialProviderDetector to accept non-generic ILogger so both providers can pass their loggers directly. Fixed in 2f9b506.
|
@copilot Implement the PR feedback, make sure the DefaultTokenCredentialProvider does appropriately update |
… logger injection Co-authored-by: davidfowl <95136+davidfowl@users.noreply.github.com>
Implemented all feedback in 2f9b506:
|
|
@copilot We never want to use DefaultAzureCredential anymore |
Co-authored-by: davidfowl <95136+davidfowl@users.noreply.github.com>
|
🚀 Dogfood this PR with:
curl -fsSL https://raw.githubusercontent.com/dotnet/aspire/main/eng/scripts/get-aspire-cli-pr.sh | bash -s -- 13538Or
iex "& { $(irm https://raw.githubusercontent.com/dotnet/aspire/main/eng/scripts/get-aspire-cli-pr.ps1) } 13538" |
|
@copilot When the credential changes, it should also cause the tenants and subscriptions to change. It should cascade. |
Co-authored-by: davidfowl <95136+davidfowl@users.noreply.github.com>
Added cascade behavior in f0776bb. In RunMode, tenant input now depends on CredentialSource and updates the credential before fetching tenants. In PublishMode, sequential prompts ensure credential is set before fetching tenants. DefaultTokenCredentialProvider already tracks CredentialSource changes and recreates the credential automatically, so tenants and subscriptions will use the new credential when fetched. |
Description
Azure local provisioning previously required users to manually configure credential sources without detecting what's available or providing guidance. This adds automatic detection of Azure CLI, Visual Studio, VS Code, Azure PowerShell, and Azure Developer CLI credentials, presenting only available options to users during provisioning setup.
Implementation
CredentialProviderDetector: Detects available credential providers by attempting token acquisition
Provisioning Context Providers: Added credential selection prompt before tenant/subscription selection
CredentialSourceis unsetDefaultTokenCredentialProvider: Enhanced to track credential source changes
Localization: Added strings for credential provider names, selection dialogs, and first-time user guidance
User Experience
When no credential providers are detected:
Selected credential source is persisted to configuration (
Azure:CredentialSource) and not prompted again. WhenCredentialSourceis not configured or set to "Default", AzureCli is used as the default credential provider.When users change their credential provider, the tenant and subscription dropdowns automatically refresh with the appropriate options for the new credential, creating a seamless cascading experience.
Checklist
Original prompt
✨ Let Copilot coding agent set things up for you — coding agent works faster and does higher quality work when set up for your repo.