Skip to content

[functionapp] az functionapp deploy crashes (JSONDecodeError) because OneDeploy responses contain JSON + appended HTML (Flex Consumption). Also blocks with RunFromExternalUrlException when WEBSITE_RUN_FROM_PACKAGE is set. #9962

Description

Source: Azure/azure-cli#32655 (by Jonas Kamsker (@JKamsker))
Affected extension: functionapp (src/functionapp/)


<<UNTRUSTED:issue-32655>>

Issue #32655 (by Jonas Kamsker (@JKamsker))

Title

az functionapp deploy crashes (JSONDecodeError) because OneDeploy responses contain JSON + appended HTML (Flex Consumption). Also blocks with RunFromExternalUrlException when WEBSITE_RUN_FROM_PACKAGE is set.

Body

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 -n --type zip
--src-url "" `
--verbose
'''

Deployment status query that also returns JSON + appended HTML:

'''
$sub=""
$rg=""
$app=""
$dep=""

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":"", ...}}}

<title>Runtime Error</title>

Server Error in '/' Application.

Runtime Error

... suggests adding to web.config ... '''

Then Azure CLI throws:

'''
The command failed with an unexpected error. Here is the traceback:
Extra data: line 1 column (char )
...
json.decoder.JSONDecodeError: Extra data: line 1 column (char )
...
requests.exceptions.JSONDecodeError: Extra data: line 1 column (char )
'''

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=""
$rg=""
$app=""
$pkg=""

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=""

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_PACKAGE blocks deployment, CLI should surface that message cleanly (and ideally provide guidance: update WEBSITE_RUN_FROM_PACKAGE + call syncfunctiontriggers).

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_PACKAGE set to a remote URL (external package).
  • The deployment record reports RunFromExternalUrlException suggesting “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 deploy and when querying deployment status).
  • Related issues: #32443 and #30960.

Comments

Comment by @azure-client-tools-bot-prd[bot]

Hi Jonas Kamsker (@JKamsker),

2.77.0 is not the latest Azure CLI(2.82.0).

If you haven't already attempted to do so, please upgrade to the latest Azure CLI version by following https://learn.microsoft.com/en-us/cli/azure/update-azure-cli.

Comment by Yong Zhang (@yonzhan)

Thank you for opening this issue, we will look into it.

Comment by @microsoft-github-policy-service[bot]

Thanks for the feedback! We are routing this to the appropriate team for follow-up. cc Kirstyn Amperiadis (@kamperiadis), Ahmed El Sayed (@amamounelsayed), Khuram Khan (@khkh-ms).

Comment by @github-actions[bot]

Here are some similar issues that might help you. Please check if they can solve your problem.


Possible solution (Extracted from existing issue, might be incorrect; please verify carefully)

Solution 1:

This issue might be caused by extra HTML being delivered along with the JSON payload from the deploy REST endpoint. I suspect that is the bug that is triggering this CLI error. The CLI tool should handle such cases gracefully by either parsing only the JSON part or providing a clear error message.

Reference:

Solution 2:

Another issue which causes this is when Firewall/Access Restriction rules are enabled for the scm site and the machine deploying does not have IP allowed. Ensure that the machine deploying has the correct IP allowed in the Access Restriction rules.

Reference:

Powered by issue-sentinel

Comment by @microsoft-github-policy-service[bot]

Thanks for the feedback! We are routing this to the appropriate team for follow-up. cc Kirstyn Amperiadis (@kamperiadis), Ahmed El Sayed (@amamounelsayed), Khuram Khan (@khkh-ms).

Comment by Adam Tibbing (@tibbing)

This breaks usage from the Terraform provider as well, i.e.

''' hcl
resource "azapi_resource" "symbolicname" {
type = "Microsoft.Web/sites/extensions@2022-09-01"
name = "onedeploy"
parent_id = "string"
}
'''

Error: Failed to create/update resource
│
│ with azapi_resource.function_package_deploy,
│ on deployment.tf line 86, in resource "azapi_resource" "function_package_deploy":
│ 86: resource "azapi_resource" "function_package_deploy" {
│
│ creating/updating Resource: (ResourceId
│ "/subscriptions//resourceGroups//providers/Microsoft.Web/sites/<[~]function>/extensions/OneDeploy" / Api
│ Version "2022-09-01"): invalid character '<' after top-level value
<<END:issue-32655>>

Activity

yonzhan commented on Jun 21, 2026

@yonzhan
Collaborator

Thank you for opening this issue, we will look into it.

azclibot commented on Jun 21, 2026

@azclibot
CollaboratorAuthor

Hi Copilot! Please investigate and fix the following bug in the az functionapp deploy command.

Summary: az functionapp deploy crashes with JSONDecodeError: Extra data when deploying to a Linux Azure Function App on Flex Consumption. The OneDeploy API returns a response body that contains valid JSON followed by appended HTML (an ASP.NET "Server Error in '/' Application" page), which causes JSON parsing to fail with Extra data.

Failing command:

az functionapp deploy -g <resource-group> -n <functionapp-name> --type zip --src-url "<zip-package-url>" --verbose

Error:

json.decoder.JSONDecodeError: Extra data: line 1 column <N> (char <N>)

Root cause: The response body from the OneDeploy API contains JSON followed by <!DOCTYPE html>... HTML content. The CLI attempts to parse the full response as JSON which fails.

Expected behavior:

  • CLI should not crash with an unhandled JSONDecodeError
  • Should gracefully handle mixed JSON+HTML responses (e.g., parse only the leading JSON object)
  • Should surface actionable error messages (e.g., if WEBSITE_RUN_FROM_PACKAGE blocks deployment, tell the user to update the app setting and call syncfunctiontriggers)

Fix guidance: Look in the functionapp extension for the deploy command's response handling. Add error handling around the JSON parsing step so that if the response contains trailing non-JSON content (HTML), the CLI:

  1. Tries to extract and parse the JSON prefix
  2. Falls back to a clear error message instead of crashing

Related core issues: Azure/azure-cli#32443, Azure/azure-cli#30960
Original report: Azure/azure-cli#32655


Posted by agent-assist (autonomous bug-fix pipeline).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Labels

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions