-
Notifications
You must be signed in to change notification settings - Fork 3.4k
[App Service] az webapp deploy, az webapp up, az webapp deployment source config-zip - Added enriched deployment failure prompt
#32940
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: dev
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change | ||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| @@ -0,0 +1,314 @@ | ||||||||||||||||
| # -------------------------------------------------------------------------------------------- | ||||||||||||||||
| # Copyright (c) Microsoft Corporation. All rights reserved. | ||||||||||||||||
| # Licensed under the MIT License. See License.txt in the project root for license information. | ||||||||||||||||
| # -------------------------------------------------------------------------------------------- | ||||||||||||||||
|
|
||||||||||||||||
| """ | ||||||||||||||||
| Context-enriched error builder for az webapp deploy / az functionapp deploy. | ||||||||||||||||
|
|
||||||||||||||||
| Instead of raising a bare "Status Code: 504" error, this module builds a structured | ||||||||||||||||
| diagnostic context block that includes the error code, deployment stage, runtime info, | ||||||||||||||||
| common causes, suggested fixes, and a ready-to-use Copilot prompt. | ||||||||||||||||
| """ | ||||||||||||||||
|
|
||||||||||||||||
| import yaml | ||||||||||||||||
| from knack.log import get_logger | ||||||||||||||||
| from knack.util import CLIError | ||||||||||||||||
|
|
||||||||||||||||
| from ._deployment_failure_patterns import match_failure_pattern | ||||||||||||||||
|
|
||||||||||||||||
| logger = get_logger(__name__) | ||||||||||||||||
|
|
||||||||||||||||
|
|
||||||||||||||||
| def _safe_yaml_dump(data): | ||||||||||||||||
| """Dump dict to YAML string, falling back to repr on error.""" | ||||||||||||||||
| try: | ||||||||||||||||
| return yaml.dump(data, default_flow_style=False, sort_keys=False, allow_unicode=True).rstrip() | ||||||||||||||||
|
||||||||||||||||
| return yaml.dump(data, default_flow_style=False, sort_keys=False, allow_unicode=True).rstrip() | |
| return yaml.safe_dump(data, default_flow_style=False, sort_keys=False, allow_unicode=True).rstrip() |
Copilot
AI
Mar 9, 2026
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.
The instance count parsing does int(val) as long as the key exists. If the deployment status API ever returns non-numeric strings (e.g., "", "unknown") this will raise and the enrichment path will fail, potentially masking the original deployment error. Consider guarding the conversion with a try/except (or str(val).isdigit() style check) and only include fields that can be safely parsed.
| context.setdefault("instanceStatus", {})[key] = int(val) | |
| try: | |
| parsed_val = int(val) | |
| except (TypeError, ValueError): | |
| # Ignore non-numeric values to avoid masking the original error | |
| continue | |
| context.setdefault("instanceStatus", {})[key] = parsed_val |
Copilot
AI
Mar 9, 2026
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.
raise_enriched_deployment_error logs the full context at INFO. Since the context can include rawError (response bodies / error text) and potentially URLs/log links, this may leak sensitive data into CLI logs. Consider logging only at DEBUG, or logging a redacted/minimal subset (e.g., errorCode/stage) and excluding raw error content from logs.
| logger.info("Deployment failure context: %s", context) | |
| logger.debug("Deployment failure context: %s", context) |
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.
The module docstring says this is for "az webapp deploy / az functionapp deploy", but the current callers in
custom.pyexplicitly skip enrichment for function apps (not params.is_functionapp). Either update the docstring to reflect the current scope (webapps only), or extend the integration to functionapp deploy so the docs match behavior.