从具有防火墙的数据库中使用 Rest api 从 Azure Functions 请求数据

Requesting data from Azure Functions with Rest api from database with firewall

我想使用 Python 构建一个 Azure 函数,它每分钟 (json) 从具有防火墙的数据库请求数据,并将该数据存储到 CosmosDB。如果我有虚拟机和 IP 地址,我可以允许该 IP 与数据库通信。但是,Azure Functions 是无服务器的,没有 IP,所以我不知道如何让它工作。

Azure 函数具有出站 IP 地址。只需将所有出站 IP 地址添加到防火墙即可。

请注意,如果您更改应用服务计划定价层,函数应用的可用出站 IP 地址集可能会发生变化。

此外,如果您的函数应用在消费计划中运行,即使您没有采取任何操作,出站 IP 地址也可能会发生变化。

所以完美的解决方案是将 outboundIpAddressespossibleOutboundIpAddresses 同时添加到数据库防火墙。 Here是查找出站IP地址的详细步骤。

注:

When a function app that runs on the Consumption plan is scaled, a new range of outbound IP addresses may be assigned. When running on the Consumption plan, you may need to whitelist the entire data center.

参考:

Outbound IP address changes