We have followed the instuctions in https://learn.microsoft.com/en-us/azure/azure-functions/functions-how-to-use-nat-gateway several times without getting it to work (it changes outbound IP-address).
We have:
- Created vnet with address 10.10.0.0/16 with subnet delegated to Microsoft.Web/serverFarms (10.10.3.0/24)
- Created static IP address
- Created NAT Gateway and attached it to the static IP Address and the subnet
- Deployed a Azure Premium Function attached to the subnet
- Set WEBSITE_VNET_ROUTE_ALL=1 on function
- Invoked test-endpoint looking up functions outbound IP using GET whatsmyip.org
- Recreating Subnet and reattached the function several times
All resources are setup in region "West Europe". Does anyone have a clue or insights on why this should not work?
Kind of embarrassing - but it turned out that one should not use whatsmyip.org from scripts/bots - since it then returns bogus ip-addresses. Using https://ifconfig.me showed that this worked all the time.
Thanks to Matt Douhan for pointing me in the right direction by verifing that the NAT Gateway actually got the traffic