gpt4 book ai didi

python - Python Azure 函数的出站 IP - 请求 IP 与函数出站 IP 列表不匹配

转载 作者:行者123 更新时间:2023-12-03 00:21:43 28 4
gpt4 key购买 nike

我在 Azure 上创建了 Python 函数,该函数调用外部 API 服务,该服务仅允许访问白名单 IP。

根据 Microsoft 文档 ( https://learn.microsoft.com/en-us/azure/azure-functions/ip-addresses ),我找到了所有 OutboundIPAddresses 和 MaybeOutboundAddresses 并将它们全部列入白名单。尽管 IP 已列入白名单,我仍然收到来自服务的 403 Forrbiden 错误。

我还通过向函数添加以下代码来验证请求的 IP 地址:

ip = requests.request('GET','https://api.ipify.org').text
logging.info('请求从IP发送:{}'.format(ip))

实际出站 IP 地址似乎与 OutboundIPAddress 和 MaybeOutboundAddresses 列表中指定的不同。

非常感谢您的帮助。

最佳答案

根据我们的文档

When a function app that runs on the Consumption plan or the Premiumplan is scaled, a new range of outbound IP addresses may be assigned.When running on either of these plans, you may need to add the entiredata center to an allowlist.

如果需要将函数应用使用的出站 IP 地址添加到允许列表,另一个选项是将函数应用的数据中心(Azure 区域)添加到允许列表。您可以download a JSON file that lists IP addresses for all Azure data centers 。然后找到适用于函数应用运行所在区域的 JSON 片段。

关于python - Python Azure 函数的出站 IP - 请求 IP 与函数出站 IP 列表不匹配,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/67622966/

28 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com