azuredevops

How to reduce your outbound ip address list for azure web app to add ip address to Flexible PostregSQL server firewall


I have created a web app in azure for hosting strapi. I have also created a postregsql database to connect to for it. However, in order for strapi to be able to access the db its ip address must be added to the firewall exceptions. The issue is there are over 30 outbound ip addresses and this doesnt seem realistic to add. Is there a way to reduce the number of outbound ip addresses?

What I have tried so far. Instead of deploying these separately I created a test of deploying a web app + database and it configures a vnet in azure. I am not a network guru so I am struggling to understand how I can use this to reduce the outbound ip addresses as that is what i read in a few spots could be the solution. However, in the web app it still lists a ton of outbound ip addresses. So what should I be doing here?


Solution

  • Reduce your outbound IP address list for azure web app to add Ip address to Flexible PostgreSQL server firewall.

    Whitelisting every IP manually is a time-consuming task. To overcome this issue, we need to create a VNet-integrated NAT gateway, which helps by allowing a single static IP to establish the connection instead of multiple IPs

    This can be achieved with by following steps

    Create a NAT gateway with existing App vnet and subnet

    enter image description here

    Integration of Vnet and Snet in NAT gateway

    enter image description here

    Once this created the outbound traffic will go through the NAT gateway's IP address.

    enter image description here

    Now open SQL Server of the dB and click on firewall configuration from overview page and set this fire wall rule

    enter image description here

    this approach will help you on your requirement of whitelisting the IPs by making them use a NAT gateway.

    Refer:

    Azure Function Running in VNet Unable to Connect to Whitelisted Azure Redis Cache - Stack Overflow answered by
    Venkat V

    https://learn.microsoft.com/en-us/answers/questions/1614119/restrict-web-app-outbound-ip-addresses answered by Byron Coetzee