You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

部署Flask应用至Azure时出现urllib3协议错误,求解决方案

Flask应用部署Azure时遇到urllib3协议错误,求解决方案

我尝试将Flask应用部署到Azure平台,遵循Azure官方的Flask应用部署教程(使用教程提供的示例应用),执行命令:

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

但执行过程中出现以下错误:

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))

我注意到这个问题在GitHub相关讨论中被提及,但未找到可行的解决方案。

我的环境信息:

  • Azure CLI版本:2.52.0
  • 安装requirements.txt依赖后,pip list结果:
    • 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

已尝试的解决方法:

  • 不在az webapp up命令中指定Python版本,无效
  • 执行az cache purge清除缓存,无效

我考虑过修改Azure CLI自带的urllib3包代码来寻找临时方案,但不知道具体操作方法。

求问有没有人知道如何解决这个问题,临时方案也可以,万分感谢。

内容的提问来源于stack exchange,提问作者Kjosbakken

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.07.11 10:55:59