Search code examples
azure-functionsipazure-virtual-networknatazure-appservice

Azure function ip4 address


We have an Azure Function that needs to call a 3rd party web service that also happens to be hosted in Azure - at least for the time being.

They need to allowlist the IP address of our Azure based caller - an Azure function app.

I've added a NAT gateway and public static IP to the subnet that our Azure function app is attached.

When our function calls https://httpbin.org/ip then it returns the IPv4 address of the NAT gateway, as expected. However, the 3rd party noticed that requests were being presented with an IPv6 address.

It seems this is expected behaviour when using an App Service with VNet integration enabled.

How can the config be changed so that an IPv4 address is always presented to the 3rd party service?


Solution

  • To configure only IPv4 address is always presented to the 3rd party there is two possible way to check this below workaround:

    I created a function app with vnet integration like below:

    enter image description here

    Created virtual network:

    enter image description here

    Now, you can create a public IP and use a NAT gateway to modify this outbound IP address.

    created public ip IPV4 with static address and associated virtual network subnet with nat gateway like below:

    enter image description here

    enter image description here

    enter image description here

    In function app properties you can check the outbound ip address like below:

    enter image description here

    Now you can see outbound IP address of the value presented like below:

    enter image description here

    Reference:

    azure-docs/functions-how-to-use-nat-gateway.md at main · MicrosoftDocs/azure-docs · GitHub

    Additionally: In your function app -> configuration -> New application setting WEBSITE_PREJUDICE_IPV4 value is 1 or WEBSITE_IP_SECURITY_FEATURE_IP_RESTRICTION value is true this IPv6 traffic will be blocked and only IPv4 addresses will be presented to the 3rd party service like below.

    enter image description here