Make Azure credential process timeout configurable#16175
Make Azure credential process timeout configurable#16175eerhardt merged 9 commits intomicrosoft:mainfrom
Conversation
The Azure CLI credential validation during 'aspire deploy' had no configurable timeout. On machines where 'az' is slow to respond (antivirus scanning, network latency), the deploy would fail or hang unpredictably. Changes: - Add CredentialProcessTimeoutSeconds to AzureProvisionerOptions (default: 60s, range: 5-600s), configurable via Azure__CredentialProcessTimeoutSeconds env var or Azure:CredentialProcessTimeoutSeconds in appsettings - Apply ProcessTimeout consistently to all process-backed credential types (AzureCli, AzurePowerShell, VisualStudio, AzureDeveloperCli) in DefaultTokenCredentialProvider — publish-mode AzureCliCredential previously had no timeout at all - Leave DefaultAzureCredential's 15s per-subprocess timeout unchanged to avoid changing run-mode behavior - Wrap ValidateAzureLoginAsync with a linked CancellationTokenSource to distinguish timeout from auth failure, providing actionable error messages for each case - Update AspireAzureConfigurationSchema.json for appsettings discoverability - Add unit tests for option validation and defaults Fixes microsoft#15872 Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Verify that custom CredentialProcessTimeoutSeconds is applied correctly: - All process-backed credential types (AzureCli, AzurePowerShell, VisualStudio, AzureDeveloperCli) create successfully with custom timeout - InteractiveBrowser is not affected by ProcessTimeout (no process) - DefaultAzureCredential run-mode path is not affected - Min boundary (5s) creates credential successfully Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
There was a problem hiding this comment.
Pull request overview
Note
Copilot was unable to run its full agentic suite in this review.
Adds a configurable timeout for Azure process-based credential validation during aspire deploy, aiming to prevent hangs and allow users to extend timeouts on slow machines.
Changes:
- Introduces
CredentialProcessTimeoutSeconds(default 60s, range 5–600) onAzureProvisionerOptions. - Applies a consistent
ProcessTimeoutto process-backed Azure.Identity credentials (Azure CLI/PowerShell/VS/AZD). - Adds timeout-specific handling in
ValidateAzureLoginAsyncand updates configuration schema + unit tests.
Show a summary per file
| File | Description |
|---|---|
| tests/Aspire.Hosting.Azure.Tests/AzureProvisionerOptionsTests.cs | Adds validation and basic construction tests for the new timeout option. |
| src/Aspire.Hosting.Azure/Provisioning/Internal/DefaultTokenCredentialProvider.cs | Plumbs the configured timeout into process-backed credential options. |
| src/Aspire.Hosting.Azure/Provisioning/AzureProvisionerOptions.cs | Adds the new CredentialProcessTimeoutSeconds option with range validation + docs. |
| src/Aspire.Hosting.Azure/AzureEnvironmentResource.cs | Implements linked-CTS timeout for credential validation and a timeout-specific message. |
| src/Aspire.Hosting.Azure/AspireAzureConfigurationSchema.json | Exposes the new setting in the JSON schema (bounds + default). |
Copilot's findings
- Files reviewed: 5/5 changed files
- Comments generated: 3
Test the full pipeline behavior for three credential scenarios: - Slow credential (10s delay, 5s timeout) → verifies timeout-specific error message with CredentialProcessTimeoutSeconds guidance - Failing credential (CredentialUnavailableException) → verifies 'az login' error message - Valid credential (existing TestTokenCredentialProvider) → verifies success Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
|
🚀 Dogfood this PR with:
curl -fsSL https://raw.githubusercontent.com/microsoft/aspire/main/eng/scripts/get-aspire-cli-pr.sh | bash -s -- 16175Or
iex "& { $(irm https://raw.githubusercontent.com/microsoft/aspire/main/eng/scripts/get-aspire-cli-pr.ps1) } 16175" |
- Throw TimeoutException instead of rethrowing OperationCanceledException so callers can distinguish timeout from user-initiated cancellation - Include both config key path (Azure:CredentialProcessTimeoutSeconds) and env var form (Azure__CredentialProcessTimeoutSeconds) in error message Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Address review feedback: use processTimeout consistently across all credential paths including the DefaultAzureCredential fallback, replacing the hardcoded 15-second CredentialProcessTimeout. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
|
Filed #16205 to track the full Azure SDK configurable credential adoption that @eerhardt suggested. That will replace the manual credential switch statement entirely with the SDK's This PR remains scoped to the immediate timeout fix — making |
Per @eerhardt's review: - Make CredentialProcessTimeoutSeconds nullable (int?) so SDK defaults are used when not explicitly configured - Remove the linked CancellationTokenSource timeout wrapper from ValidateAzureLoginAsync — the credential handles its own timeout - Only apply ProcessTimeout to credential options when explicitly set - Extract credential creation into helper methods for cleaner code - Update JSON schema to remove default value - Remove slow-credential integration test (no longer applicable) Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
f1590cd to
e0503a7
Compare
eerhardt
left a comment
There was a problem hiding this comment.
Thanks for the contribution!
Remove duplicate 'using Azure.Core' from AzureDeployerTests.cs — it conflicts with the Aspire.Hosting.Azure namespace and is treated as error IDE0005/CS0105 in CI. Use fully qualified global::Azure.Core types for the test credential classes instead. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
|
Re-running the failed jobs in the CI workflow for this pull request because 1 job was identified as retry-safe transient failures in the CI run attempt.
|
Adds documentation for the new Azure:CredentialProcessTimeoutSeconds configuration option introduced in microsoft/aspire#16175. The option lets users override the credential subprocess timeout (range 5-600) when az login validation is slow due to antivirus, network latency, etc. - Adds the option to the Local Azure provisioning configuration table and a new 'Credential process timeout' section. - Adds a 'Configurable Azure credential timeout' section to the What's new in Aspire 13.3 doc. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Adds documentation for the new Azure:CredentialProcessTimeoutSeconds configuration option introduced in microsoft/aspire#16175. The option lets users override the credential subprocess timeout (range 5-600) when az login validation is slow due to antivirus, network latency, etc. - Adds the option to the Local Azure provisioning configuration table and a new 'Credential process timeout' section. - Adds a 'Configurable Azure credential timeout' section to the What's new in Aspire 13.3 doc. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Adds documentation for the new Azure:CredentialProcessTimeoutSeconds configuration option introduced in microsoft/aspire#16175. The option lets users override the credential subprocess timeout (range 5-600) when az login validation is slow due to antivirus, network latency, etc. - Adds the option to the Local Azure provisioning configuration table and a new 'Credential process timeout' section. - Adds a 'Configurable Azure credential timeout' section to the What's new in Aspire 13.3 doc. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Adds documentation for the new Azure:CredentialProcessTimeoutSeconds configuration option introduced in microsoft/aspire#16175. The option lets users override the credential subprocess timeout (range 5-600) when az login validation is slow due to antivirus, network latency, etc. - Adds the option to the Local Azure provisioning configuration table and a new 'Credential process timeout' section. - Adds a 'Configurable Azure credential timeout' section to the What's new in Aspire 13.3 doc. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
* Document Azure:CredentialProcessTimeoutSeconds option Adds documentation for the new Azure:CredentialProcessTimeoutSeconds configuration option introduced in microsoft/aspire#16175. The option lets users override the credential subprocess timeout (range 5-600) when az login validation is slow due to antivirus, network latency, etc. - Adds the option to the Local Azure provisioning configuration table and a new 'Credential process timeout' section. - Adds a 'Configurable Azure credential timeout' section to the What's new in Aspire 13.3 doc. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> * Mention CredentialProcessTimeoutSeconds in deployment env var asides Adds a follow-up note to each `Azure__SubscriptionId` env var list pointing at the new credential process timeout option for users hitting slow credential validation. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> --------- Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Description
Fixes #15872 —
aspire deployaz login check times out with no way to override.Problem
The Azure CLI credential validation during
aspire deployhad inconsistent timeout handling:AzureCliCredential): No timeout at all — would use SDK defaults or hangDefaultAzureCredential): Hard-coded 15sCredentialProcessTimeout— too short for some machinesazCLI is slow (antivirus scanning, network latency)Solution
CredentialProcessTimeoutSecondstoAzureProvisionerOptions(default: 60s, range: 5-600s)ProcessTimeoutconsistently to all process-backed credential types (AzureCli, AzurePowerShell, VisualStudio, AzureDeveloperCli)DefaultAzureCredentialunchanged at 15s per-subprocess timeout to avoid changing run-mode behaviorValidateAzureLoginAsyncwith a linkedCancellationTokenSourceto distinguish timeout from auth failure, providing specific error messages for eachConfiguration
Error Messages
Timeout:
Auth failure (unchanged):
Changes
AzureProvisionerOptions.csCredentialProcessTimeoutSecondsproperty with[Range(5, 600)]validationDefaultTokenCredentialProvider.csProcessTimeoutto AzureCli, AzurePowerShell, VisualStudio, AzureDeveloperCli credentialsAzureEnvironmentResource.csCancelAfterinValidateAzureLoginAsyncfor timeout-specific error messagingAspireAzureConfigurationSchema.jsonAzureProvisionerOptionsTests.csTesting