Skip to content

Commit 956a54a

Browse files
seligj95Copilot
andcommitted
[App Service] Fix #29290: Improve error message for az webapp deploy --src-url Bad Request
When `az webapp deploy --src-url` receives an HTTP 400 response with an empty body, the CLI previously displayed just "Bad Request" with no actionable guidance. This was because `send_raw_request` raises `HTTPError` before the deploy-specific error handling code is reached. This change wraps the ARM deploy request in a helper that catches 400 responses and provides a clear error message with possible causes: - Source URL not accessible or SAS token expired - URL doesn't point to a valid deployment artifact - Artifact type mismatch If the response body contains details from ARM, those are included too. Fixes #29290 Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
1 parent dc9fdb3 commit 956a54a

1 file changed

Lines changed: 26 additions & 4 deletions

File tree

  • src/azure-cli/azure/cli/command_modules/appservice

src/azure-cli/azure/cli/command_modules/appservice/custom.py

Lines changed: 26 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -9781,6 +9781,28 @@ def _warmup_kudu_and_get_cookie_internal(params):
97819781
return None
97829782

97839783

9784+
def _send_deploy_request(cli_ctx, deploy_url, body):
9785+
"""Wrapper around send_raw_request for --src-url deployments that provides
9786+
actionable error messages instead of bare HTTP status codes."""
9787+
from azure.cli.core.azclierror import HTTPError
9788+
try:
9789+
return send_raw_request(cli_ctx, "PUT", deploy_url, body=body)
9790+
except HTTPError as ex:
9791+
status_code = ex.response.status_code if hasattr(ex, 'response') and ex.response is not None else None
9792+
response_text = ex.response.text if hasattr(ex, 'response') and ex.response is not None else ""
9793+
if status_code == 400:
9794+
error_detail = f" Details: {response_text}" if response_text else ""
9795+
raise CLIError(
9796+
f"Deployment from URL failed with status 400 (Bad Request).{error_detail}\n"
9797+
"Possible causes:\n"
9798+
" - The source URL is not publicly accessible or the SAS token has expired\n"
9799+
" - The URL does not point to a valid deployment artifact\n"
9800+
" - The artifact type does not match the file content (e.g., --type zip for a non-zip file)\n"
9801+
"Please verify the URL is accessible and the artifact type is correct."
9802+
) from ex
9803+
raise
9804+
9805+
97849806
def _make_onedeploy_request(params):
97859807
import requests
97869808
from azure.cli.core.util import should_disable_connection_verify
@@ -9828,16 +9850,16 @@ def _make_onedeploy_request(params):
98289850
if cookies is None:
98299851
logger.info("Failed to fetch affinity cookie for Kudu. "
98309852
"Deployment will proceed without pre-warming a Kudu instance.")
9831-
response = send_raw_request(params.cmd.cli_ctx, "PUT", deploy_url, body=body)
9853+
response = _send_deploy_request(params.cmd.cli_ctx, deploy_url, body)
98329854
else:
98339855
deploy_arm_url = _build_onedeploy_url(params, cookies.get("ARRAffinity"))
9834-
response = send_raw_request(params.cmd.cli_ctx, "PUT", deploy_arm_url, body=body)
9856+
response = _send_deploy_request(params.cmd.cli_ctx, deploy_arm_url, body)
98359857
except Exception as ex: # pylint: disable=broad-except
98369858
logger.info("Failed to deploy using instances endpoint. "
98379859
"Deployment will proceed without pre-warming a Kudu instance. Ex: %s", ex)
9838-
response = send_raw_request(params.cmd.cli_ctx, "PUT", deploy_url, body=body)
9860+
response = _send_deploy_request(params.cmd.cli_ctx, deploy_url, body)
98399861
else:
9840-
response = send_raw_request(params.cmd.cli_ctx, "PUT", deploy_url, body=body)
9862+
response = _send_deploy_request(params.cmd.cli_ctx, deploy_url, body)
98419863
poll_async_deployment_for_debugging = False
98429864

98439865
# check the status of deployment

0 commit comments

Comments
 (0)