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

使用Azure Functions Core Tools本地运行Python函数遇代理407错误求助

本地运行Azure Python函数时代理407认证失败问题

在使用.pac代理的环境下,通过Visual Studio Code执行func host start启动本地Azure Python函数时,出现以下错误:

Microsoft.Azure.WebJobs.Script: Error creating configuration in an external startup class. System.Net.Http: Proxy tunnel request to proxy 'http://{myProxy}:{portProxy}/' failed with status code '407'.

版本信息

  • Python:3.8.1
  • Azure Functions Core Tools:4.0.5382(64位),运行时版本4.25.3.21264

已尝试操作

在local.settings.json中添加代理配置,但问题未解决,配置内容如下:

{
    "IsEncrypted": false,
    "Values": {
        "AzureWebJobsStorage": "",
        "FUNCTIONS_WORKER_RUNTIME": "python",
        "AzureWebJobsFeatureFlags": "EnableWorkerIndexing",
        "HTTP_PROXY": "http://{user}:{pass}@{myProxy}:{portProxy}/",
        "HTTPS_PROXY": "http://{user}:{pass}@{myProxy}:{portProxy}/",
        "NO_PROXY": "localhost,0.0.0.0,127.0.0.1"
    }
}

可能的解决方向

  1. 调整代理认证格式
    部分代理服务器不支持URL直接嵌入用户名密码的格式,可尝试:
  • 在系统环境变量中单独设置HTTP_PROXY/HTTPS_PROXY为http://{myProxy}:{portProxy}/,再添加PROXY_USER和PROXY_PASSWORD变量存储认证信息;
  • 改用http://{user}@{myProxy}:{portProxy}/格式,在系统弹出认证窗口时输入密码。
  1. 手动解析PAC代理地址
    Azure Functions Core Tools可能无法自动解析PAC文件,需手动提取PAC中返回的代理服务器地址和端口,确保配置的代理信息与PAC规则一致。

  2. 终端临时设置环境变量启动
    在启动命令前直接在终端设置代理环境变量(Windows用set,Linux/macOS用export):

# Windows
set HTTP_PROXY=http://{user}:{pass}@{myProxy}:{portProxy}/
set HTTPS_PROXY=http://{user}:{pass}@{myProxy}:{portProxy}/
func host start

# Linux/macOS
export HTTP_PROXY=http://{user}:{pass}@{myProxy}:{portProxy}/
export HTTPS_PROXY=http://{user}:{pass}@{myProxy}:{portProxy}/
func host start
  1. 排查代理认证细节
  • 确认用户名密码是否正确,若密码含特殊字符(@、&等)需进行URL编码;
  • 检查代理服务器是否限制了该账号的IP访问范围,或是否需要特定的认证方式。
  1. 更新Core Tools版本
    当前使用的Core Tools版本存在代理相关bug的可能性,尝试更新至最新稳定版再测试。

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

相关产品推荐
方舟 Agent Plan

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

最近更新时间:2026.07.04 00:42:10