Azure Functions 的 IP 地址超出了 VNet 的范围
Azure Function has IP address out of VNet's range
我有一个使用高级计划的 Azure Functions - 我需要它才能将它与 Azure 上的虚拟网络集成。我已将我的应用程序与地址范围为 172.24.2.0/26
.
的 VNet 子网集成
当我通过 SSH 连接到我的 Azure Functions 和 运行 ip a
命令时,我看到:
root@2a5f00591f61:~# ip a
1: lo: <LOOPBACK,UP,LOWER_UP> mtu 65536 qdisc noqueue state UNKNOWN group default qlen 1000
link/loopback 00:00:00:00:00:00 brd 00:00:00:00:00:00
inet 127.0.0.1/8 scope host lo
valid_lft forever preferred_lft forever
3: eth0@if36: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc noqueue state UP group default
link/ether 82:4d:fd:69:94:37 brd ff:ff:ff:ff:ff:ff link-netnsid 0
inet 169.254.129.3/24 brd 169.254.129.255 scope global eth0
valid_lft forever preferred_lft forever
5: vnet009kd8d60@if8: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc noqueue state UP group default
link/ether 62:6b:44:d9:b5:11 brd ff:ff:ff:ff:ff:ff link-netnsid 1
inet 169.254.254.3/24 brd 169.254.254.255 scope global vnet009kd8d60
valid_lft forever preferred_lft forever
我不明白为什么列出的 IP 中有 none 个在我的子网范围内。我在高级计划中创建函数的原因是为了在 VNet 中拥有它。我的用例是我有一项服务只接受来自选定 VNet 的请求——包括我的函数使用的请求。
如何使我的函数的 IP 在子网的范围内?
//编辑
我的函数在其配置中有 WEBSITE_VNET_ROUTE_ALL
= 1
。
这是设计行为,当您在 VNet 集成后从 Azure 功能访问 SSH 工具时,我也得到了相同的结果。如我所见,在 VNet 中集成 Azure 函数后,Azure 将 Dynamic Configuration of IPv4 Link-Local Addresses 分配给 SSH 主机。
事实上,我们可以从 Kudu 控制台 UI 通过环境变量 WEBSITE_PRIVATE_IP 检查分配给实例的私有 IP。阅读 manage-vnet-integration 了解更多详情。
The private IP assigned to the instance is exposed via the environment
variable, WEBSITE_PRIVATE_IP. Kudu console UI also shows the list of
environment variables available to the Web App. This IP is assigned
from the address range of the integrated subnet. For Regional VNet
Integration, the value of WEBSITE_PRIVATE_IP is an IP from the address
range of the delegated subnet, and for Gateway-required VNet
Integration, the value is an IP from the address range of the
Point-to-site address pool configured on the Virtual Network Gateway.
This is the IP that will be used by the Web App to connect to the
resources through the Virtual Network.
对于 Linux 应用服务计划,
对于 Windows 应用服务计划,
在这种情况下,如果您的服务仅接受来自选定 VNet 的请求,则可以通过添加应用程序设置强制将所有出站流量发送到您的 VNet
WEBSITE_VNET_ROUTE_ALL=1
并且您可以使用网络安全组规则来限制该 VNet 中的流量。
我有一个使用高级计划的 Azure Functions - 我需要它才能将它与 Azure 上的虚拟网络集成。我已将我的应用程序与地址范围为 172.24.2.0/26
.
当我通过 SSH 连接到我的 Azure Functions 和 运行 ip a
命令时,我看到:
root@2a5f00591f61:~# ip a
1: lo: <LOOPBACK,UP,LOWER_UP> mtu 65536 qdisc noqueue state UNKNOWN group default qlen 1000
link/loopback 00:00:00:00:00:00 brd 00:00:00:00:00:00
inet 127.0.0.1/8 scope host lo
valid_lft forever preferred_lft forever
3: eth0@if36: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc noqueue state UP group default
link/ether 82:4d:fd:69:94:37 brd ff:ff:ff:ff:ff:ff link-netnsid 0
inet 169.254.129.3/24 brd 169.254.129.255 scope global eth0
valid_lft forever preferred_lft forever
5: vnet009kd8d60@if8: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc noqueue state UP group default
link/ether 62:6b:44:d9:b5:11 brd ff:ff:ff:ff:ff:ff link-netnsid 1
inet 169.254.254.3/24 brd 169.254.254.255 scope global vnet009kd8d60
valid_lft forever preferred_lft forever
我不明白为什么列出的 IP 中有 none 个在我的子网范围内。我在高级计划中创建函数的原因是为了在 VNet 中拥有它。我的用例是我有一项服务只接受来自选定 VNet 的请求——包括我的函数使用的请求。 如何使我的函数的 IP 在子网的范围内?
//编辑
我的函数在其配置中有 WEBSITE_VNET_ROUTE_ALL
= 1
。
这是设计行为,当您在 VNet 集成后从 Azure 功能访问 SSH 工具时,我也得到了相同的结果。如我所见,在 VNet 中集成 Azure 函数后,Azure 将 Dynamic Configuration of IPv4 Link-Local Addresses 分配给 SSH 主机。
事实上,我们可以从 Kudu 控制台 UI 通过环境变量 WEBSITE_PRIVATE_IP 检查分配给实例的私有 IP。阅读 manage-vnet-integration 了解更多详情。
The private IP assigned to the instance is exposed via the environment variable, WEBSITE_PRIVATE_IP. Kudu console UI also shows the list of environment variables available to the Web App. This IP is assigned from the address range of the integrated subnet. For Regional VNet Integration, the value of WEBSITE_PRIVATE_IP is an IP from the address range of the delegated subnet, and for Gateway-required VNet Integration, the value is an IP from the address range of the Point-to-site address pool configured on the Virtual Network Gateway. This is the IP that will be used by the Web App to connect to the resources through the Virtual Network.
对于 Linux 应用服务计划,
对于 Windows 应用服务计划,
在这种情况下,如果您的服务仅接受来自选定 VNet 的请求,则可以通过添加应用程序设置强制将所有出站流量发送到您的 VNet
WEBSITE_VNET_ROUTE_ALL=1
并且您可以使用网络安全组规则来限制该 VNet 中的流量。