@@ -881,6 +881,9 @@ def enable_zip_deploy(cmd, resource_group_name, name, src, timeout=None, slot=No
881881 app_is_linux_webapp = is_linux_webapp(app)
882882 app_is_function_app = is_functionapp(app)
883883
884+ # Should we enrich deployment errors with context? (webapp only, not functionapp)
885+ _should_enrich_errors = not app_is_function_app
886+
884887 # Read file content
885888 with open(os.path.realpath(os.path.expanduser(src)), 'rb') as fs:
886889 zip_content = fs.read()
@@ -913,13 +916,26 @@ def enable_zip_deploy(cmd, resource_group_name, name, src, timeout=None, slot=No
913916 # check the status of async deployment
914917 if res.status_code == 202:
915918 response_body = None
916- if track_status:
917- response_body = _check_runtimestatus_with_deploymentstatusapi(cmd, resource_group_name, name, slot,
918- deployment_status_url, is_async=True,
919- timeout=timeout)
920- else:
921- response_body = _check_zip_deployment_status(cmd, resource_group_name, name, deployment_status_url,
922- slot, timeout)
919+ try:
920+ if track_status:
921+ response_body = _check_runtimestatus_with_deploymentstatusapi(cmd, resource_group_name, name, slot,
922+ deployment_status_url, is_async=True,
923+ timeout=timeout)
924+ else:
925+ response_body = _check_zip_deployment_status(cmd, resource_group_name, name, deployment_status_url,
926+ slot, timeout)
927+ except CLIError as deploy_err:
928+ if _should_enrich_errors:
929+ raise_enriched_deployment_error(
930+ cmd=cmd,
931+ resource_group_name=resource_group_name,
932+ webapp_name=name,
933+ slot=slot,
934+ artifact_type="zip",
935+ error_message=str(deploy_err),
936+ last_known_step="Zip deployment accepted (HTTP 202), tracking status"
937+ )
938+ raise
923939 return response_body
924940
925941 # check if there's an ongoing process
@@ -934,6 +950,18 @@ def enable_zip_deploy(cmd, resource_group_name, name, src, timeout=None, slot=No
934950
935951 # check if an error occured during deployment
936952 if res.status_code:
953+ if _should_enrich_errors:
954+ raise_enriched_deployment_error(
955+ cmd=cmd,
956+ resource_group_name=resource_group_name,
957+ webapp_name=name,
958+ slot=slot,
959+ artifact_type="zip",
960+ status_code=res.status_code,
961+ error_message=res.text if res.text else None,
962+ last_known_step="Zip deployment HTTP request",
963+ kudu_status=str(res.status_code)
964+ )
937965 raise AzureInternalError("An error occured during deployment. Status Code: {}, Details: {}"
938966 .format(res.status_code, res.text))
939967
@@ -9852,12 +9880,14 @@ def _make_onedeploy_request(params):
98529880 params.webapp_name,
98539881 deployment_status_url, params.slot, params.timeout)
98549882 except CLIError as deploy_err:
9855- # Enrich the downstream deployment-tracking error with context
9856- raise_enriched_deployment_error(
9857- params=params,
9858- error_message=str(deploy_err),
9859- last_known_step="Deployment accepted (HTTP 200/202), tracking status"
9860- )
9883+ if not params.is_functionapp:
9884+ # Enrich the downstream deployment-tracking error with context
9885+ raise_enriched_deployment_error(
9886+ params=params,
9887+ error_message=str(deploy_err),
9888+ last_known_step="Deployment accepted (HTTP 200/202), tracking status"
9889+ )
9890+ raise
98619891 logger.info('Server response: %s', response_body)
98629892 else:
98639893 if 'application/json' in response.headers.get('content-type', ""):
@@ -9880,15 +9910,22 @@ def _make_onedeploy_request(params):
98809910 "starting a new deployment. You can track the ongoing deployment at {}"
98819911 .format(deployment_status_url))
98829912
9883- # check if an error occurred during deployment — raise context-enriched error
9913+ # check if an error occurred during deployment
98849914 if response.status_code:
9885- raise_enriched_deployment_error(
9886- params=params,
9887- status_code=response.status_code,
9888- error_message=response.text if response.text else None,
9889- last_known_step="HTTP request sent to deployment API",
9890- kudu_status=str(response.status_code)
9891- )
9915+ if not params.is_functionapp:
9916+ raise_enriched_deployment_error(
9917+ params=params,
9918+ status_code=response.status_code,
9919+ error_message=response.text if response.text else None,
9920+ last_known_step="HTTP request sent to deployment API",
9921+ kudu_status=str(response.status_code)
9922+ )
9923+ scm_url = _get_scm_url(params.cmd, params.resource_group_name, params.webapp_name, params.slot)
9924+ latest_deploymentinfo_url = scm_url + "/api/deployments/latest"
9925+ raise CLIError("An error occurred during deployment. Status Code: {}, {} Please visit {}"
9926+ " to get more information about your deployment"
9927+ .format(response.status_code, f"Details: {response.text}," if response.text else "",
9928+ latest_deploymentinfo_url))
98929929
98939930
98949931# OneDeploy
@@ -9909,27 +9946,33 @@ def _perform_onedeploy_internal(params):
99099946 # Check if this is already an enriched error (from raise_enriched_deployment_error)
99109947 if "COPILOT CONTEXT" in str(ex):
99119948 raise
9912- # Raw CLIError from send_raw_request or other deployment calls — enrich it
9913- raise_enriched_deployment_error(
9914- params=params,
9915- error_message=str(ex),
9916- last_known_step="Deployment request"
9917- )
9949+ if not params.is_functionapp:
9950+ # Raw CLIError from send_raw_request or other deployment calls — enrich it
9951+ raise_enriched_deployment_error(
9952+ params=params,
9953+ error_message=str(ex),
9954+ last_known_step="Deployment request"
9955+ )
9956+ raise
99189957 except HttpResponseError as ex:
9919- # Azure SDK errors (e.g. Bad Request from ARM)
9920- raise_enriched_deployment_error(
9921- params=params,
9922- status_code=ex.status_code if hasattr(ex, 'status_code') else None,
9923- error_message=str(ex),
9924- last_known_step="ARM deployment request"
9925- )
9958+ if not params.is_functionapp:
9959+ # Azure SDK errors (e.g. Bad Request from ARM)
9960+ raise_enriched_deployment_error(
9961+ params=params,
9962+ status_code=ex.status_code if hasattr(ex, 'status_code') else None,
9963+ error_message=str(ex),
9964+ last_known_step="ARM deployment request"
9965+ )
9966+ raise
99269967 except Exception as ex: # pylint: disable=broad-except
9927- # Catch-all for unexpected errors (connection errors, timeouts, etc.)
9928- raise_enriched_deployment_error(
9929- params=params,
9930- error_message=str(ex),
9931- last_known_step="Deployment request"
9932- )
9968+ if not params.is_functionapp:
9969+ # Catch-all for unexpected errors (connection errors, timeouts, etc.)
9970+ raise_enriched_deployment_error(
9971+ params=params,
9972+ error_message=str(ex),
9973+ last_known_step="Deployment request"
9974+ )
9975+ raise
99339976
99349977
99359978def _wait_for_webapp(tunnel_server):
0 commit comments