Context
- Azure Function accessible from the Internet (think public API).
- The Function app is hosted in a
Elastic Premium
plan. - Azure-managed PostgreSQL instance (
GP
plan).
Goal
Make PostgreSQL instance accessible to the Function app only while keeping the Function app accessible from the Internet.
What I've tried
- Create a VNet and a service endpoint-enabled subnet.
- Add a VNet rule to the PostgreSQL instance securing access from that subnet only.
- Integrate the Function app with the VNet.
That should be enough to restrict access to the database but it has a side effect of the Function App not being accessible from the Internet anymore. I believe AppInsights cannot reach the Function App either (getting Unable to open a connection to your app. This may be due to any network security groups or IP restriction rules that you have placed on your app.
in the Monitor).
In AWS world, I'd put Lambda and database instance in private subnets and add a NAT Gateway for the Internet access for Lambda. After extensive research I can't figure out how to achieve this with Azure.
If there's an alternative approach please let me know!