question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Failed to Download Logs for Azure App Service

See original GitHub issue

This is autogenerated. Please review and update as needed.

Describe the bug

My attempts to download logs using az web app log show are consistently failing. The is a new error. I performed az upgrade and continue to have the issue.

Command Name az webapp log download

Errors:

The command failed with an unexpected error. Here is the traceback:
('Connection broken: IncompleteRead(350 bytes read)', IncompleteRead(350 bytes read))
Traceback (most recent call last):
  File "/usr/local/Cellar/python@3.10/3.10.6_1/Frameworks/Python.framework/Versions/3.10/lib/python3.10/http/client.py", line 565, in _get_chunk_left
    chunk_left = self._read_next_chunk_size()
  File "/usr/local/Cellar/python@3.10/3.10.6_1/Frameworks/Python.framework/Versions/3.10/lib/python3.10/http/client.py", line 532, in _read_next_chunk_size
    return int(line, 16)
ValueError: invalid literal for int() with base 16: b''

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/usr/local/Cellar/python@3.10/3.10.6_1/Frameworks/Python.framework/Versions/3.10/lib/python3.10/http/client.py", line 582, in _read_chunked
    chunk_left = self._get_chunk_left()
  File "/usr/local/Cellar/python@3.10/3.10.6_1/Frameworks/Python.framework/Versions/3.10/lib/python3.10/http/client.py", line 567, in _get_chunk_left
    raise IncompleteRead(b'')
http.client.IncompleteRead: IncompleteRead(0 bytes read)

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/usr/local/Cellar/azure-cli/2.39.0/libexec/lib/python3.10/site-packages/urllib3/response.py", line 438, in _error_catcher
    yield
  File "/usr/local/Cellar/azure-cli/2.39.0/libexec/lib/python3.10/site-packages/urllib3/response.py", line 519, in read
    data = self._fp.read(amt) if not fp_closed else b""
  File "/usr/local/Cellar/python@3.10/3.10.6_1/Frameworks/Python.framework/Versions/3.10/lib/python3.10/http/client.py", line 459, in read
    return self._read_chunked(amt)
  File "/usr/local/Cellar/python@3.10/3.10.6_1/Frameworks/Python.framework/Versions/3.10/lib/python3.10/http/client.py", line 597, in _read_chunked
    raise IncompleteRead(b''.join(value))
http.client.IncompleteRead: IncompleteRead(350 bytes read)

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/usr/local/Cellar/azure-cli/2.39.0/libexec/lib/python3.10/site-packages/knack/cli.py", line 231, in invoke
    cmd_result = self.invocation.execute(args)
  File "/usr/local/Cellar/azure-cli/2.39.0/libexec/lib/python3.10/site-packages/azure/cli/core/commands/__init__.py", line 663, in execute
    raise ex
  File "/usr/local/Cellar/azure-cli/2.39.0/libexec/lib/python3.10/site-packages/azure/cli/core/commands/__init__.py", line 726, in _run_jobs_serially
    results.append(self._run_job(expanded_arg, cmd_copy))
  File "/usr/local/Cellar/azure-cli/2.39.0/libexec/lib/python3.10/site-packages/azure/cli/core/commands/__init__.py", line 697, in _run_job
    result = cmd_copy(params)
  File "/usr/local/Cellar/azure-cli/2.39.0/libexec/lib/python3.10/site-packages/azure/cli/core/commands/__init__.py", line 333, in __call__
    return self.handler(*args, **kwargs)
  File "/usr/local/Cellar/azure-cli/2.39.0/libexec/lib/python3.10/site-packages/azure/cli/core/commands/command_operation.py", line 121, in handler
    return op(**command_args)
  File "/usr/local/Cellar/azure-cli/2.39.0/libexec/lib/python3.10/site-packages/azure/cli/command_modules/appservice/custom.py", line 2575, in download_historical_logs
    _get_log(url, user_name, password, log_file)
  File "/usr/local/Cellar/azure-cli/2.39.0/libexec/lib/python3.10/site-packages/azure/cli/command_modules/appservice/custom.py", line 2607, in _get_log
    data = r.read(1024)
  File "/usr/local/Cellar/azure-cli/2.39.0/libexec/lib/python3.10/site-packages/urllib3/response.py", line 512, in read
    with self._error_catcher():
  File "/usr/local/Cellar/python@3.10/3.10.6_1/Frameworks/Python.framework/Versions/3.10/lib/python3.10/contextlib.py", line 153, in __exit__
    self.gen.throw(typ, value, traceback)
  File "/usr/local/Cellar/azure-cli/2.39.0/libexec/lib/python3.10/site-packages/urllib3/response.py", line 455, in _error_catcher
    raise ProtocolError("Connection broken: %r" % e, e)
urllib3.exceptions.ProtocolError: ('Connection broken: IncompleteRead(350 bytes read)', IncompleteRead(350 bytes read))

To Reproduce:

Steps to reproduce the behavior. Note that argument values have been redacted, as they may contain sensitive information.

  • Put any pre-requisite steps here…
  • az webapp log download --resource-group {} --name {} --log-file {}

Expected Behavior

Environment Summary

macOS-11.6.8-x86_64-i386-64bit, Darwin 20.6.0
Python 3.10.6
Installer: HOMEBREW

azure-cli 2.39.0

Additional Context

Issue Analytics

  • State:closed
  • Created a year ago
  • Comments:8 (4 by maintainers)

github_iconTop GitHub Comments

1reaction
resqrobertcommented, Sep 2, 2022

Okay, thank you for the info @SaurabhSharma-MSFT. I was unaware of this and have not run into trouble until now. How then does Microsoft recommend I access my server logs for Linux based web apps?

0reactions
SaurabhSharma-MSFTcommented, Sep 12, 2022

@resqrobert Our Product Group team has identified the cause and shared the below RCA:

The Microsoft Azure Team has investigated the issue you reported regarding log download not working for your app.

Upon investigation, engineers determined that this was due to a code bug in the Kudu site, which creates the zip archive containing all logs. We identified a race condition which could cause the zip archive to be malformed. The CLI could not parse the malformed zip and threw the error you were seeing.

We have identified the fix for the issue and will be releasing it as part of our next platform upgrade.

As workaround, you may download logs directly using Kudu REST API /api/zip or using the File Manager on Kudu NewUI /newui.

We are continuously taking steps to improve the Azure Web App service and our processes to ensure such incidents do not occur in the future, and in this case it includes (but is not limited to):

Bug fix for Kudu CLI changes to handle such errors more gracefully We apologize for any inconvenience.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Enable diagnostics logging - Azure App Service
To save the error page or failed request tracing for Windows apps in the Azure portal, navigate to your app and select App...
Read more >
Failed to download files when deployed to Azure App Service
But it stops at Azure AppService. The file will download well and then stop when it reaches 1 GB. Is there a problem...
Read more >
Azure Logging Tutorial for Azure App Services - App logs, IIS ...
Types of Azure Logs · Web server logging. Information about the HTTP requests that are processed by the webserver. · Detailed error messages....
Read more >
Integrate OneAgent on Azure App Service | Dynatrace Docs
This error message appears if Kudu hasn't been restarted after the site extension was installed. You must restart the application. There are three...
Read more >
How to download Azure App Service web server and ...
If there are no logs in the log folders you might not have logging turned on or might not be logging to the...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found