feat: add configurable deploy timeout via --timeout flag and azure.yaml#7045
feat: add configurable deploy timeout via --timeout flag and azure.yaml#7045
Conversation
Add a --timeout flag to azd deploy and a deployTimeout field in azure.yaml service configuration. Users can now control how long azd waits for a deployment to complete, addressing the 20-minute hardcoded default that was too long for simple pipeline deployments. Timeout resolution order: CLI flag > azure.yaml service config > default (1200s). Invalid values (zero or negative) return a clear error. Fixes #6555 Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
There was a problem hiding this comment.
Pull request overview
Adds a user-configurable deployment timeout to azd deploy, allowing CI/pipelines to fail faster when Azure long-running deployments hang, using a CLI flag and per-service azure.yaml configuration.
Changes:
- Adds
--timeouttoazd deploywith precedence: flag >azure.yaml(deployTimeout) > default (1200s). - Wraps each service deploy operation in
context.WithTimeoutso Azure SDK polling honors the deadline. - Extends project config/schema/tests and updates CLI usage/completions snapshots.
Reviewed changes
Copilot reviewed 8 out of 8 changed files in this pull request and generated 5 comments.
Show a summary per file
| File | Description |
|---|---|
| cli/azd/internal/cmd/deploy.go | Adds --timeout, resolves precedence, and applies context.WithTimeout around deploy. |
| cli/azd/internal/cmd/deploy_test.go | Adds tests for flag parsing, timeout resolution, and ensuring deploy uses a deadline. |
| cli/azd/pkg/project/service_config.go | Adds DeployTimeout *int to service config model. |
| cli/azd/pkg/project/service_config_test.go | Adds YAML parsing tests for deployTimeout. |
| cli/azd/pkg/project/project_config_test.go | Adds project-level parsing test for deployTimeout. |
| schemas/v1.0/azure.yaml.json | Adds deployTimeout schema property for services. |
| cli/azd/cmd/testdata/TestFigSpec.ts | Updates Fig completion spec snapshot to include --timeout. |
| cli/azd/cmd/testdata/TestUsage-azd-deploy.snap | Updates deploy usage snapshot to include --timeout. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Addresses review feedback from Ratt: - Wrap context.DeadlineExceeded with user-friendly timeout message - Add minimum: 1 to deployTimeout JSON schema Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
|
How can we communicate to folks that the timeout is only to stop azd but not the actual deployment? For AppService, for example, azd can be stopped, during zip deployment, before sending the zip file and starting the service deployment. That would be a valid cancellation in both sides. |
What I am going to change here is a global timeout setting for deployments instead of per service |
Remove deployTimeout from azure.yaml ServiceConfig and schema per owner direction. The --timeout flag on azd deploy is the only way to configure the deploy timeout. This keeps operational concerns out of project config. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
- Timeout error now explains azd stopped waiting but deployment may continue server-side, with Portal check guidance (Victor's feedback) - Defer cancel() immediately after WithTimeout (standard Go pattern) - Remove reflection-based t.Skip — access flags.Timeout directly - Fix flaky deadline assertion by capturing start time before Run() Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Resolution order: CLI --timeout flag > AZD_DEPLOY_TIMEOUT env var > default (1200s). This lets CI/CD pipelines configure deploy timeout without modifying command args. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
- Remove .squad/agents/ files that were accidentally committed - Break long lines in deploy.go warning message and deploy_test.go assertions to stay within 125-char lll limit - All review threads from automated reviewer are resolved Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
|
Regarding hemarina's feedback about per-service vs total timeout: the current implementation applies |
weikanglim
left a comment
There was a problem hiding this comment.
Overall looks good -- have some comments
cli/azd/internal/cmd/deploy.go
Outdated
|
|
||
| if err != nil { | ||
| da.console.StopSpinner(ctx, stepMessage, input.StepFailed) | ||
| if errors.Is(err, context.DeadlineExceeded) { |
There was a problem hiding this comment.
This error check is ambiguous and may fire if timeout happens inside the deploy operation.
Suggestion: should check deployCtx.Error() directly.
cli/azd/internal/cmd/deploy.go
Outdated
| return da.serviceManager.Deploy(ctx, svc, serviceContext, progress) | ||
| }, | ||
| ) | ||
| deployTimeout, err := da.resolveDeployTimeout() |
There was a problem hiding this comment.
The timeout resolution (flag → env → default) is identical for every service, yet it runs once per service iteration. Move it before the projectConfig.Invoke() loop so we fail fast parsing instead of during the deployment.
I vote for timeout per-service.
cli/azd/internal/cmd/deploy.go
Outdated
| }) | ||
|
|
||
| return fmt.Errorf( | ||
| "deployment of service '%s' timed out after %d seconds. Note: azd has stopped waiting, "+ |
There was a problem hiding this comment.
It could be worth mentioning how to suggest timeout (flag or env var)
- Remove .squad/ files from PR (hemarina) - Defer context cancel immediately after WithTimeout (Copilot) - Move timeout resolution before service loop (weikanglim) - Check deployCtx.Err() directly for unambiguous timeout detection (weikanglim) - Include --timeout/AZD_DEPLOY_TIMEOUT/azure.yaml in timeout error msg (weikanglim) - Fix flaky test timing by capturing start time before Run() (Copilot) - Remove reflection/t.Skip from tests, use direct field access (Copilot) - Add minimum:1 to deployTimeout in JSON schema (Copilot) Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Azure Dev CLI Install InstructionsInstall scriptsMacOS/Linux
bash: pwsh: WindowsPowerShell install MSI install Standalone Binary
MSI
Documentationlearn.microsoft.com documentationtitle: Azure Developer CLI reference
|
Problem
azd deployhas no user-configurable timeout. The Azure SDK default timeout is effectively unbounded for App Service and Container Apps deployments, making pipeline feedback loops slow when deployments hang (#6555).Solution
Add a
--timeoutflag toazd deployand adeployTimeoutfield inazure.yamlservice configuration:Timeout resolution order: CLI flag > azure.yaml service config > default (1200s / 20 min)
The timeout wraps the deploy context with
context.WithTimeout, which propagates through all Azure SDKPollUntilDonecalls naturally.Changes
cli/azd/internal/cmd/deploy.go--timeoutflag,resolveDeployTimeout(), apply viacontext.WithTimeoutcli/azd/internal/cmd/deploy_test.gocli/azd/pkg/project/service_config.goDeployTimeout *intfieldcli/azd/pkg/project/service_config_test.gocli/azd/pkg/project/project_config_test.goschemas/v1.0/azure.yaml.jsondeployTimeoutinteger propertycli/azd/cmd/testdata/TestFigSpec.tscli/azd/cmd/testdata/TestUsage-azd-deploy.snapTesting
go build ./...✅Fixes #6555