Search code examples
azureflaskweb-hostingchunksurllib3

Error with urllib3 when launching azure webapp


I am trying to host my Flask application on azure. To do this I followed this tutorial on hosting flask app on azure (I also used the sample application given in the tutorial). I then run the command:

az webapp up --runtime PYTHON:3.9 --sku B1 --logs

but get the following message:

`The webapp 'witty-coast-99cdf44e87c541d492a413bb27936a7c' doesn't exist
Creating AppServicePlan 'eivindkjosbakken_asp_1275' ...
Creating webapp 'witty-coast-99cdf44e87c541d492a413bb27936a7c' ...
Configuring default logging for the app, if not already enabled
Creating zip with contents of dir C:\Users\eivin\Documents\Programming\msdocs-python-flask-webapp-quickstart ...
Getting scm site credentials for zip deployment
Starting zip deployment. This operation can take a while to complete ...
Deployment endpoint responded with status code 202
You can launch the app at http://witty-coast-99cdf44e87c541d492a413bb27936a7c.azurewebsites.net
Configuring default logging for the app, if not already enabled
2023-09-05T13:39:46  Welcome, you are now connected to log-streaming service.
Exception in thread Thread-1 (_get_log):
Traceback (most recent call last):
  File "D:\a\_work\1\s\build_scripts\windows\artifacts\cli\Lib\site-packages\urllib3/response.py", line 761, in _update_chunk_length
ValueError: invalid literal for int() with base 16: b''

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "D:\a\_work\1\s\build_scripts\windows\artifacts\cli\Lib\site-packages\urllib3/response.py", line 444, in _error_catcher
  File "D:\a\_work\1\s\build_scripts\windows\artifacts\cli\Lib\site-packages\urllib3/response.py", line 828, in read_chunked
  File "D:\a\_work\1\s\build_scripts\windows\artifacts\cli\Lib\site-packages\urllib3/response.py", line 765, in _update_chunk_length
urllib3.exceptions.InvalidChunkLength: InvalidChunkLength(got length b'', 0 bytes read)

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "threading.py", line 1016, in _bootstrap_inner
  File "threading.py", line 953, in run
  File "D:\a\_work\1\s\build_scripts\windows\artifacts\cli\Lib\site-packages\azure/cli/command_modules/appservice/custom.py", line 2852, in _get_log
  File "D:\a\_work\1\s\build_scripts\windows\artifacts\cli\Lib\site-packages\urllib3/response.py", line 624, in stream
  File "D:\a\_work\1\s\build_scripts\windows\artifacts\cli\Lib\site-packages\urllib3/response.py", line 816, in read_chunked
  File "contextlib.py", line 153, in __exit__
  File "D:\a\_work\1\s\build_scripts\windows\artifacts\cli\Lib\site-packages\urllib3/response.py", line 461, in _error_catcher
urllib3.exceptions.ProtocolError: ("Connection broken: InvalidChunkLength(got length b'', 0 bytes read)", InvalidChunkLength(got length b'', 0 bytes read))`

I see that this is an issue mentioned in this GitHub issue, but they had no solution there and nothing else has been mentioned.

My question is then, does anyone know how to fix this (even a temporary solution would be highly appreciated).

Azure CLI version: 2.52.0.

Running pip list after installing the packages from requirements.txt: click 8.1.7 colorama 0.4.6 Flask 2.0.2 gunicorn 21.2.0 itsdangerous 2.1.2 Jinja2 3.1.2 MarkupSafe 2.1.3 packaging 23.1 pip 23.1.2 setuptools 65.5.0 Werkzeug 2.3.7

I have tried several things: Not specifying Python version in the az webapp up command (does not help). I have also tried clearing the cache with az cache purge". I am thinking that if I could change the code in the urllib3 package that azure is using, then I could potentially find a temporary solution, but I am unsure how to change this package (as it is a package azure uses automatically when running az webapp up)


Solution

  • I have followed the same MS Doc which you have provided.

    Initially even I got the same error.

    enter image description here

    Run az cache purge in the root directory of the App which you have cloned from GitHub.

    enter image description here

    • Now the Web App has been created and uploaded the files successfully.

    • You can see the Log Stream of the running app.

    enter image description here

    enter image description here

    Az CLI Version

    enter image description here

    Output:

    enter image description here