Azure / Azure/azure-cli

az rest deployment to flex function results in broken response

Open
#30,960 5 comments 3 reactions 5 assignees Claimed by @jiasli View on GitHub
act-observability-squad Auto-Assign bug customer-reported Functions Service Attention
Dominant language
Python
Stars
4.6k
Forks
3.5k
Avg merge
3d 2h
Merged PRs (30d)
60

Description

### Describe the bug

I'm trying to update a flex-consumption azure function using the az rest api. The command I am using is below (I've removed any sensitive information). The deployment succeeds, but the response from the API includes some HTML AFTER the JSON.

This causes the command to fail as it tries to pass the response as JSON.

### Related command

```
az rest --method PUT \
--uri "https://management.azure.com/subscriptions/xxxxx/resourceGroups/xxxxx/providers/Microsoft.Web/sites/func-xxxxxx/extensions/onedeploy?api-version=2024-04-01" \
--body "{
\"properties\": {
\"packageUri\": \"${APP_URL}\"
},
\"type\": \"zip\"
}"
```
### Errors

```
{"id":"/subscriptions/xxxxxxx/resourceGroups/xxxxx/providers/Microsoft.Web/sites/func-xxxx/extensions/onedeploy","name":"func-xxxx/onedeploy","type":"Microsoft.Web/sites/extensions","location":"East US","properties":{"deployment":{"id":"5cb9f1c4-887f-4419-9662-eb0c512107e8","sourcePackageUri":" https://xxxxx.blob.core.windows.net/deployments/xxxxx.zip?se=2025-03-07T01%3A28%3A03Z&sp=r&sv=2022-11-02&sr=b&sig=EhB%2FEIjVN3HVAx5SeV%2B3C8ffi4Scn129AeibvdzF12M%3D","sourcePackagePath":null,"resultPackagePath":null,"remoteBuild":false,"deployer":"AZURE_RESOURCE_MANAGER","correlationId":"d88675c4-5d3f-4022-9a44-d55eefc99b5d","createdBy":null,"createdDate":"0001-01-01T00:00:00"},"name":"5cb9f1c4-887f-4419-9662-eb0c512107e8"}}


Runtime Error


body {font-family:"Verdana";font-weight:normal;font-size: .7em;color:black;}
p {font-family:"Verdana";font-weight:normal;color:black;margin-top: -5px}
b {font-family:"Verdana";font-weight:bold;color:black;margin-top: -5px}
H1 { font-family:"Verdana";font-weight:normal;font-size:18pt;color:red }
H2 { font-family:"Verdana";font-weight:normal;font-size:14pt;color:maroon }
pre {font-family:"Consolas","Lucida Console",Monospace;font-size:11pt;margin:0;padding:0.5em;line-height:14pt}
.marker {font-weight: bold; color: black;text-decoration: none;}
.version {color: gray;}
.error {margin-bottom: 10px;}
.expandable { text-decoration:underline; font-weight:bold; color:navy; cursor:pointer; }
@media screen and (max-width: 639px) {
pre { width: 440px; overflow: auto; white-space: pre-wrap; word-wrap: break-word; }
}
@media screen and (max-width: 479px) {
pre { width: 280px; }
}

Server Error in '/' Application.

Runtime Error

Description: An application error occurred on the server. The current custom error settings for this application prevent the details of the application error from being viewed remotely (for security reasons). It could, however, be viewed by browsers running on the local server machine.


Details: To enable the details of this specific error message to be viewable on remote machines, please create a <customErrors> tag within a "web.config" configuration file located in the root directory of the current web application. This <customErrors> tag should then have its "mode" attribute set to "Off".





<!-- Web.Config Configuration File -->

<configuration>
<system.web>
<customErrors mode="Off"/>
</system.web>
</configuration>




Notes: The current error page you are seeing can be replaced by a custom error page by modifying the "defaultRedirect" attribute of the application's <customErrors> configuration tag to point to a custom error page URL.





<!-- Web.Config Configuration File -->

<configuration>
<system.web>
<customErrors mode="RemoteOnly" defaultRedirect="mycustompage.htm"/>
</system.web>
</configuration>




```

### Issue script & Debug output
```
cli.knack.cli: Command arguments: ['rest', '--method', 'PUT', '--uri', 'https://management.azure.com/subscriptions/xxxxxxxx/resourceGroups/xxxxxxxx/providers/Microsoft.Web/sites/func-xxxxxxxx/extensions/onedeploy?api-version=2024-04-01', '--body', '{\n "properties": {\n "packageUri": " https://xxxxxxxx.blob.core.windows.net/deployments/xxxxxxxx-3b82d1d8a770c5ef78866f3d00f67d34b4fa181d.zip?se=2025-03-07T01%3A28%3A03Z&sp=r&sv=2022-11-02&sr=b&sig=EhB%2FEIjVN3HVAx5SeV%2B3C8ffi4Scn129AeibvdzF12M%3D"\n },\n "type": "zip"\n }', '--debug']
cli.knack.cli: __init__ debug log:
Enable color in terminal.
cli.knack.cli: Event: Cli.PreExecute []
cli.knack.cli: Event: CommandParser.OnGlobalArgumentsCreate [, , ]
cli.knack.cli: Event: CommandInvoker.OnPreCommandTableCreate []
cli.azure.cli.core: Modules found from index for 'rest': ['azure.cli.command_modules.util']
cli.azure.cli.core: Loading command modules:
cli.azure.cli.core: Name Load Time Groups Commands
cli.azure.cli.core: util 0.006 3 7
cli.azure.cli.core: Total (1) 0.006 3 7
cli.azure.cli.core: Loaded 3 groups, 7 commands.
cli.azure.cli.core: Found a match in the command table.
cli.azure.cli.core: Raw command : rest
cli.azure.cli.core: Command table: rest
cli.knack.cli: Event: CommandInvoker.OnPreCommandTableTruncate []
cli.azure.cli.core.azlogging: metadata file logging enabled - writing logs to '/Users/me/.azure/commands/2025-03-06.13-09-32.rest.66598.log'.
az_command_data_logger: command args: rest --method {} --uri {} --body {} --output {} --debug
cli.knack.cli: Event: CommandInvoker.OnPreArgumentLoad [.add_subscription_parameter at 0x1025639c0>]
cli.knack.cli: Event: CommandInvoker.OnPostArgumentLoad []
cli.knack.cli: Event: CommandInvoker.OnPostCommandTableCreate [.add_ids_arguments at 0x10259dd00>, .add_cache_arguments at 0x10259de40>, .update_breaking_change_info at 0x10259dee0>]
cli.knack.cli: Event: CommandInvoker.OnCommandTableLoaded []
cli.knack.cli: Event: CommandInvoker.OnPreParseArgs []
cli.knack.cli: Event: CommandInvoker.OnPostParseArgs [, , .parse_ids_arguments at 0x10259dda0>]
cli.azure.cli.core.util: Found subscription ID xxxxxxxx in the URL https://management.azure.com/subscriptions/xxxxxxxx/resourceGroups/xxxxxxxx/providers/Microsoft.Web/sites/func-xxxxxxxx/extensions/onedeploy?api-version=2024-04-01
cli.azure.cli.core.util: Retrieving token for resource https://management.core.windows.net/, subscription xxxxxxxx
cli.azure.cli.core.auth.persistence: build_persistence: location='/Users/me/.azure/msal_token_cache.json', encrypt=False
cli.azure.cli.core.auth.binary_cache: load: /Users/me/.azure/msal_http_cache.bin
urllib3.util.retry: Converted retries value: 1 -> Retry(total=1, connect=None, read=None, redirect=None, status=None)
msal.authority: Initializing with Entra authority: https://login.microsoftonline.com/e3b9a49f-14e5-477c-80d8-cf06bd250d7e
msal.authority: openid_config("https://login.microsoftonline.com/e3b9a49f-14e5-477c-80d8-cf06bd250d7e/v2.0/.well-known/openid-configuration") = {'token_endpoint': 'https://login.microsoftonline.com/e3b9a49f-14e5-477c-80d8-cf06bd250d7e/oauth2/v2.0/token', 'token_endpoint_auth_methods_supported': ['client_secret_post', 'private_key_jwt', 'client_secret_basic'], 'jwks_uri': 'https://login.microsoftonline.com/e3b9a49f-14e5-477c-80d8-cf06bd250d7e/discovery/v2.0/keys', 'response_modes_supported': ['query', 'fragment', 'form_post'], 'subject_types_supported': ['pairwise'], 'id_token_signing_alg_values_supported': ['RS256'], 'response_types_supported': ['code', 'id_token', 'code id_token', 'id_token token'], 'scopes_supported': ['openid', 'profile', 'email', 'offline_access'], 'issuer': 'https://login.microsoftonline.com/e3b9a49f-14e5-477c-80d8-cf06bd250d7e/v2.0', 'request_uri_parameter_supported': False, 'userinfo_endpoint': 'https://graph.microsoft.com/oidc/userinfo', 'authorization_endpoint': 'https://login.microsoftonline.com/e3b9a49f-14e5-477c-80d8-cf06bd250d7e/oauth2/v2.0/authorize', 'device_authorization_endpoint': 'https://login.microsoftonline.com/e3b9a49f-14e5-477c-80d8-cf06bd250d7e/oauth2/v2.0/devicecode', 'http_logout_supported': True, 'frontchannel_logout_supported': True, 'end_session_endpoint': 'https://login.microsoftonline.com/e3b9a49f-14e5-477c-80d8-cf06bd250d7e/oauth2/v2.0/logout', 'claims_supported': ['sub', 'iss', 'cloud_instance_name', 'cloud_instance_host_name', 'cloud_graph_host_name', 'msgraph_host', 'aud', 'exp', 'iat', 'auth_time', 'acr', 'nonce', 'preferred_username', 'name', 'tid', 'ver', 'at_hash', 'c_hash', 'email'], 'kerberos_endpoint': 'https://login.microsoftonline.com/e3b9a49f-14e5-477c-80d8-cf06bd250d7e/kerberos', 'tenant_region_scope': 'OC', 'cloud_instance_name': 'microsoftonline.com', 'cloud_graph_host_name': 'graph.windows.net', 'msgraph_host': 'graph.microsoft.com', 'rbac_url': 'https://pas.windows.net'}
msal.application: Broker enabled? None
cli.azure.cli.core.auth.msal_credentials: UserCredential.get_token: scopes=('https://management.core.windows.net//.default',), claims=None, kwargs={}
msal.application: Cache hit an AT
msal.telemetry: Generate or reuse correlation_id: 56f3bc27-9095-4d0b-83cf-0447b4917dea
cli.azure.cli.core.util: Request URL: 'https://management.azure.com/subscriptions/xxxxxxxx/resourceGroups/xxxxxxxx/providers/Microsoft.Web/sites/func-xxxxxxxx/extensions/onedeploy?api-version=2024-04-01'
cli.azure.cli.core.util: Request method: 'PUT'
cli.azure.cli.core.util: Request headers:
cli.azure.cli.core.util: 'User-Agent': 'python/3.12.9 (macOS-14.7.2-arm64-arm-64bit) AZURECLI/2.70.0 (HOMEBREW)'
cli.azure.cli.core.util: 'Accept-Encoding': 'gzip, deflate'
cli.azure.cli.core.util: 'Accept': '*/*'
cli.azure.cli.core.util: 'Connection': 'keep-alive'
cli.azure.cli.core.util: 'x-ms-client-request-id': '167126a0-5eda-4471-8b6a-e20543b390f3'
cli.azure.cli.core.util: 'Content-Type': 'application/json'
cli.azure.cli.core.util: 'CommandName': 'rest'
cli.azure.cli.core.util: 'ParameterSetName': '--method --uri --body --output --debug'
cli.azure.cli.core.util: 'Authorization': 'Bearer eyJ0eXAiOiJKV...'
cli.azure.cli.core.util: 'Content-Length': '282'
cli.azure.cli.core.util: Request body:
cli.azure.cli.core.util: {"properties": {"packageUri": " https://xxxxxxxx.blob.core.windows.net/deployments/xxxxxxxx-3b82d1d8a770c5ef78866f3d00f67d34b4fa181d.zip?se=2025-03-07T01%3A28%3A03Z&sp=r&sv=2022-11-02&sr=b&sig=EhB%2FEIjVN3HVAx5SeV%2B3C8ffi4Scn129AeibvdzF12M%3D"}, "type": "zip"}
urllib3.connectionpool: Starting new HTTPS connection (1): management.azure.com:443
urllib3.connectionpool: https://management.azure.com:443 "PUT /subscriptions/xxxxxxxx/resourceGroups/xxxxxxxx/providers/Microsoft.Web/sites/func-xxxxxxxx/extensions/onedeploy?api-version=2024-04-01 HTTP/1.1" 202 4369
cli.azure.cli.core.util: Response status: 202
cli.azure.cli.core.util: Response headers:
cli.azure.cli.core.util: 'Cache-Control': 'no-cache'
cli.azure.cli.core.util: 'Pragma': 'no-cache'
cli.azure.cli.core.util: 'Content-Length': '4369'
cli.azure.cli.core.util: 'Content-Type': 'application/json; charset=utf-8'
cli.azure.cli.core.util: 'Expires': '-1'
cli.azure.cli.core.util: 'Location': 'https://management.azure.com/subscriptions/xxxxxxxx/resourceGroups/xxxxxxxx/providers/Microsoft.Web/sites/func-xxxxxxxx/deployments/d5cf3d3b-eb97-4132-876a-1da5ff18ef67?api-version=2018-02-01&deployer=python/3.12.9%20(macOS-14.7.2-arm64-arm-64bit)%20AZURECLI/2.70.0%20(HOMEBREW)&time=2025-03-06_02-09-33Z'
cli.azure.cli.core.util: 'Set-Cookie': 'ARRAffinity=fb33675fda5f1351be2e56fe3e9c501961f22a6aab1f1465dc01498a0de99cfb;Path=/;HttpOnly;Secure;Domain=func-xxxxxxxx.scm.azurewebsites.net, ARRAffinitySameSite=fb33675fda5f1351be2e56fe3e9c501961f22a6aab1f1465dc01498a0de99cfb;Path=/;HttpOnly;SameSite=None;Secure;Domain=func-xxxxxxxx.scm.azurewebsites.net'
cli.azure.cli.core.util: 'x-ms-ratelimit-remaining-subscription-writes': '199'
cli.azure.cli.core.util: 'Strict-Transport-Security': 'max-age=31536000; includeSubDomains'
cli.azure.cli.core.util: 'Request-Context': 'appId=cid-v1:00a67dc0-8f45-4402-bcd3-0ecb1b9a898c'
cli.azure.cli.core.util: 'x-ms-correlation-id': 'e08a8443-f100-4527-9b0a-146f29fca1de'
cli.azure.cli.core.util: 'X-AspNet-Version': '4.0.30319'
cli.azure.cli.core.util: 'X-Powered-By': 'ASP.NET'
cli.azure.cli.core.util: 'x-ms-ratelimit-remaining-subscription-global-writes': '2999'
cli.azure.cli.core.util: 'x-ms-request-id': '73ae6777-d7d6-43d4-809b-71b855ba5b69'
cli.azure.cli.core.util: 'x-ms-correlation-request-id': '73ae6777-d7d6-43d4-809b-71b855ba5b69'
cli.azure.cli.core.util: 'x-ms-routing-request-id': 'AUSTRALIAEAST:20250306T020934Z:73ae6777-d7d6-43d4-809b-71b855ba5b69'
cli.azure.cli.core.util: 'X-Content-Type-Options': 'nosniff'
cli.azure.cli.core.util: 'X-Cache': 'CONFIG_NOCACHE'
cli.azure.cli.core.util: 'X-MSEdge-Ref': 'Ref A: CCFDE3958BA3474F8C0F7370AA81ED01 Ref B: SYD03EDGE1711 Ref C: 2025-03-06T02:09:33Z'
cli.azure.cli.core.util: 'Date': 'Thu, 06 Mar 2025 02:09:33 GMT'
cli.azure.cli.core.util: Response content:
cli.azure.cli.core.util: {"id":"/subscriptions/xxxxxxxx/resourceGroups/xxxxxxxx/providers/Microsoft.Web/sites/func-xxxxxxxx/extensions/onedeploy","name":"func-xxxxxxxx/onedeploy","type":"Microsoft.Web/sites/extensions","location":"East US","properties":{"deployment":{"id":"d5cf3d3b-eb97-4132-876a-1da5ff18ef67","sourcePackageUri":" https://xxxxxxxx.blob.core.windows.net/deployments/xxxxxxxx-3b82d1d8a770c5ef78866f3d00f67d34b4fa181d.zip?se=2025-03-07T01%3A28%3A03Z&sp=r&sv=2022-11-02&sr=b&sig=EhB%2FEIjVN3HVAx5SeV%2B3C8ffi4Scn129AeibvdzF12M%3D","sourcePackagePath":null,"resultPackagePath":null,"remoteBuild":false,"deployer":"AZURE_RESOURCE_MANAGER","correlationId":"e08a8443-f100-4527-9b0a-146f29fca1de","createdBy":null,"createdDate":"0001-01-01T00:00:00"},"name":"d5cf3d3b-eb97-4132-876a-1da5ff18ef67"}}


Runtime Error


body {font-family:"Verdana";font-weight:normal;font-size: .7em;color:black;}
p {font-family:"Verdana";font-weight:normal;color:black;margin-top: -5px}
b {font-family:"Verdana";font-weight:bold;color:black;margin-top: -5px}
H1 { font-family:"Verdana";font-weight:normal;font-size:18pt;color:red }
H2 { font-family:"Verdana";font-weight:normal;font-size:14pt;color:maroon }
pre {font-family:"Consolas","Lucida Console",Monospace;font-size:11pt;margin:0;padding:0.5em;line-height:14pt}
.marker {font-weight: bold; color: black;text-decoration: none;}
.version {color: gray;}
.error {margin-bottom: 10px;}
.expandable { text-decoration:underline; font-weight:bold; color:navy; cursor:pointer; }
@media screen and (max-width: 639px) {
pre { width: 440px; overflow: auto; white-space: pre-wrap; word-wrap: break-word; }
}
@media screen and (max-width: 479px) {
pre { width: 280px; }
}

Server Error in '/' Application.

Runtime Error

Description: An application error occurred on the server. The current custom error settings for this application prevent the details of the application error from being viewed remotely (for security reasons). It could, however, be viewed by browsers running on the local server machine.


Details: To enable the details of this specific error message to be viewable on remote machines, please create a <customErrors> tag within a "web.config" configuration file located in the root directory of the current web application. This <customErrors> tag should then have its "mode" attribute set to "Off".





<!-- Web.Config Configuration File -->

<configuration>
<system.web>
<customErrors mode="Off"/>
</system.web>
</configuration>




Notes: The current error page you are seeing can be replaced by a custom error page by modifying the "defaultRedirect" attribute of the application's <customErrors> configuration tag to point to a custom error page URL.





<!-- Web.Config Configuration File -->

<configuration>
<system.web>
<customErrors mode="RemoteOnly" defaultRedirect="mycustompage.htm"/>
</system.web>
</configuration>




cli.azure.cli.command_modules.util.custom: Not a json response, outputting to stdout. For binary data suggest use "--output-file" to write to a file
{"id":"/subscriptions/xxxxxxxx/resourceGroups/xxxxxxxx/providers/Microsoft.Web/sites/func-xxxxxxxx/extensions/onedeploy","name":"func-xxxxxxxx/onedeploy","type":"Microsoft.Web/sites/extensions","location":"East US","properties":{"deployment":{"id":"d5cf3d3b-eb97-4132-876a-1da5ff18ef67","sourcePackageUri":" https://xxxxxxxx.blob.core.windows.net/deployments/xxxxxxxx-3b82d1d8a770c5ef78866f3d00f67d34b4fa181d.zip?se=2025-03-07T01%3A28%3A03Z&sp=r&sv=2022-11-02&sr=b&sig=EhB%2FEIjVN3HVAx5SeV%2B3C8ffi4Scn129AeibvdzF12M%3D","sourcePackagePath":null,"resultPackagePath":null,"remoteBuild":false,"deployer":"AZURE_RESOURCE_MANAGER","correlationId":"e08a8443-f100-4527-9b0a-146f29fca1de","createdBy":null,"createdDate":"0001-01-01T00:00:00"},"name":"d5cf3d3b-eb97-4132-876a-1da5ff18ef67"}}


Runtime Error


body {font-family:"Verdana";font-weight:normal;font-size: .7em;color:black;}
p {font-family:"Verdana";font-weight:normal;color:black;margin-top: -5px}
b {font-family:"Verdana";font-weight:bold;color:black;margin-top: -5px}
H1 { font-family:"Verdana";font-weight:normal;font-size:18pt;color:red }
H2 { font-family:"Verdana";font-weight:normal;font-size:14pt;color:maroon }
pre {font-family:"Consolas","Lucida Console",Monospace;font-size:11pt;margin:0;padding:0.5em;line-height:14pt}
.marker {font-weight: bold; color: black;text-decoration: none;}
.version {color: gray;}
.error {margin-bottom: 10px;}
.expandable { text-decoration:underline; font-weight:bold; color:navy; cursor:pointer; }
@media screen and (max-width: 639px) {
pre { width: 440px; overflow: auto; white-space: pre-wrap; word-wrap: break-word; }
}
@media screen and (max-width: 479px) {
pre { width: 280px; }
}

Server Error in '/' Application.

Runtime Error

Description: An application error occurred on the server. The current custom error settings for this application prevent the details of the application error from being viewed remotely (for security reasons). It could, however, be viewed by browsers running on the local server machine.


Details: To enable the details of this specific error message to be viewable on remote machines, please create a <customErrors> tag within a "web.config" configuration file located in the root directory of the current web application. This <customErrors> tag should then have its "mode" attribute set to "Off".





<!-- Web.Config Configuration File -->

<configuration>
<system.web>
<customErrors mode="Off"/>
</system.web>
</configuration>




Notes: The current error page you are seeing can be replaced by a custom error page by modifying the "defaultRedirect" attribute of the application's <customErrors> configuration tag to point to a custom error page URL.





<!-- Web.Config Configuration File -->

<configuration>
<system.web>
<customErrors mode="RemoteOnly" defaultRedirect="mycustompage.htm"/>
</system.web>
</configuration>




cli.knack.cli: Event: CommandInvoker.OnTransformResult []
cli.knack.cli: Event: CommandInvoker.OnFilterResult []
cli.knack.cli: Event: Cli.SuccessfulExecute []
cli.knack.cli: Event: Cli.PostExecute []
az_command_data_logger: exit code: 0
cli.__main__: Command ran in 1.531 seconds (init: 0.136, invoke: 1.394)
telemetry.main: Begin splitting cli events and extra events, total events: 1
telemetry.client: Accumulated 0 events. Flush the clients.
telemetry.main: Finish splitting cli events and extra events, cli events: 1
telemetry.save: Save telemetry record of length 3888 in cache file under /Users/me/.azure/telemetry/20250306130934095
telemetry.main: Begin creating telemetry upload process.
telemetry.process: Creating upload process: "/opt/homebrew/Cellar/azure-cli/2.70.0/libexec/bin/python /opt/homebrew/Cellar/azure-cli/2.70.0/libexec/lib/python3.12/site-packages/azure/cli/telemetry/__init__.py /Users/me/.azure /Users/me/.azure/telemetry/20250306130934095"
telemetry.process: Return from creating process 66603
telemetry.main: Finish creating telemetry upload process.
```
### Expected behavior

I expect the resulting JSON to not have a whole bunch of HTML in it

### Environment Summary

azure-cli 2.70.0

core 2.70.0
telemetry 1.1.0

Dependencies:
msal 1.31.2b1
azure-mgmt-resource 23.1.1

Python location '/opt/homebrew/Cellar/azure-cli/2.70.0/libexec/bin/python'
Config directory '/Users/me/.azure'
Extensions directory '/Users/me/.azure/cliextensions'**

### Additional context

This also happens if I run the equivalent az functionapp deploy command

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.