-
Notifications
You must be signed in to change notification settings - Fork 3.3k
Description
Describe the bug
az functionapp deploy (preview) crashes with an unhandled JSON parsing exception when deploying a zip package to a Linux Azure Function App on Flex Consumption.
The underlying deploy request is accepted (202) and returns JSON that includes a deployment id, but the response body appears to contain valid JSON followed by an appended HTML “Server Error in '/' Application” page. This causes Azure CLI to throw JSONDecodeError: Extra data and exit unexpectedly.
In the same scenario, querying the deployment record shows the deployment fails with:
RunFromExternalUrlException: The app setting WEBSITE_RUN_FROM_PACKAGE is set to a remote URL. Therefore, Deployment is not needed... set WEBSITE_RUN_FROM_PACKAGE ... and manually call synctriggers.
Even if this configuration is expected to block zip deployment, the CLI should not crash because the response contains mixed content (JSON + HTML). Instead it should surface the service error cleanly.
This looks related to existing reports about JSON responses having HTML appended (for Flex Consumption deployments), e.g. azure-cli #32443 and #30960.
Related command
PowerShell:
az functionapp deploy -g <resource-group> -n <functionapp-name> `
--type zip `
--src-url "<zip-package-url>" `
--verbose
Deployment status query that also returns JSON + appended HTML:
$sub="<subscription-id>"
$rg="<resource-group>"
$app="<functionapp-name>"
$dep="<deployment-guid-from-onedeploy-response>"
az rest --method get `
--url "https://management.azure.com/subscriptions/$sub/resourceGroups/$rg/providers/Microsoft.Web/sites/$app/deployments/$dep" `
--url-parameters api-version=2018-02-01 `
-o jsonc
Errors
From az functionapp deploy ... --verbose (truncated + redacted):
Response content:
{"id":"...","properties":{"deployment":{"id":"<deployment-guid>", ...}}}<!DOCTYPE html>
<html>
<head><title>Runtime Error</title></head>
<body>
<h1>Server Error in '/' Application.</h1>
<h2>Runtime Error</h2>
... suggests adding <customErrors> to web.config ...
</body>
</html>
Then Azure CLI throws:
The command failed with an unexpected error. Here is the traceback:
Extra data: line 1 column <N> (char <N>)
...
json.decoder.JSONDecodeError: Extra data: line 1 column <N> (char <N>)
...
requests.exceptions.JSONDecodeError: Extra data: line 1 column <N> (char <N>)
Deployment status call returns status=3 and the service error (and again has HTML appended after JSON):
"status": 3,
"status_text": "RunFromExternalUrlException: The app setting WEBSITE_RUN_FROM_PACKAGE is set to a remote URL. Therefore, Deployment is not needed in this case. For new deployment, just set the WEBSITE_RUN_FROM_PACKAGE to the remote URL of the latest zip package and manually call synctriggers."
Issue script & Debug output
Repro script (PowerShell). Please run with --debug and paste full output below (redact secrets):
$sub="<subscription-id>"
$rg="<resource-group>"
$app="<functionapp-name>"
$pkg="<https-zip-url>"
# 1) Deploy
az functionapp deploy -g $rg -n $app --type zip --src-url $pkg --verbose --debug
# 2) Extract the deployment GUID from the deploy output (deployment id)
$dep="<deployment-guid>"
# 3) Query deployment record (this also shows JSON + appended HTML in the response)
az rest --method get --debug `
--url "https://management.azure.com/subscriptions/$sub/resourceGroups/$rg/providers/Microsoft.Web/sites/$app/deployments/$dep" `
--url-parameters api-version=2018-02-01 `
-o jsonc
In the debug output, the key symptom is that the response body contains JSON followed by <!DOCTYPE html> and an ASP.NET-style runtime error page.
Expected behavior
-
CLI should not crash with an unhandled
JSONDecodeError. -
If the service returns non-JSON or mixed content, CLI should:
- fall back to raw-text handling (or parse the first JSON object only),
- and return a clear, actionable error message.
-
If
WEBSITE_RUN_FROM_PACKAGEblocks deployment, CLI should surface that message cleanly (and ideally provide guidance: updateWEBSITE_RUN_FROM_PACKAGE+ callsyncfunctiontriggers).
Environment Summary
azure-cli 2.77.0
core 2.77.0
telemetry 1.1.0
Extensions:
application-insights 1.2.3
log-analytics 1.0.0b1
resource-graph 2.1.1
Dependencies:
msal 1.34.0b1
azure-mgmt-resource 23.3.0
Python location 'C:\Program Files\Microsoft SDKs\Azure\CLI2\python.exe'
Config directory 'C:\Users\Jonas.azure'
Extensions directory 'C:\Users\Jonas.azure\cliextensions'
Python (Windows) 3.13.7 (tags/v3.13.7:bcee1c3, Aug 14 2025, 14:15:11) [MSC v.1944 64 bit (AMD64)]
Legal docs and information: aka.ms/AzureCliLegal
Additional context
- The Function App has
WEBSITE_RUN_FROM_PACKAGEset to a remote URL (external package). - The deployment record reports
RunFromExternalUrlExceptionsuggesting “deployment not needed” and to “set WEBSITE_RUN_FROM_PACKAGE to latest zip and manually call synctriggers”. - Regardless of the correct deployment approach, the CLI bug is that JSON responses appear to have HTML appended, causing JSON parsing to fail (observed both during
az functionapp deployand when querying deployment status). - Related issues:
ERROR: Extra data: line 1 column 1253 (char 1252)when running az functionapp deploy with --type zip #32443 and az rest deployment to flex function results in broken response #30960.