What NSG rules can be applied for Hub/Spoke/AppGw scenario? - azure

I have an AppService deployed in a Spoke Vnet (with a Private Endpoint). In front of this is an AppGw (in the Hub Vnet).
It seems that it's not possible to control the AppGw outbound traffic with the Azure Firewall. I would therefore like to control it with an NSG in the Spoke Vnet directly where I have my private endpoint. (I want to only allow the green line)
However, I cannot figure out what rules I should put in place. As soon as I disable VNET to VNET traffic in the NSG, my AppGw cannot talk to the private link anymore even if I put an explicit rule from the AppGw to the private endpoint.
How can I secure the access to my private endpoint?

I tried to understand your setup and collected following points:
Connection from AppGw to App Service go through linked service
Guessing that App Service has not been integrated with VNet(1)
It seems that it's not possible to control the AppGw outbound traffic with the Azure Firewall.
If you are not using VNet integration with appservice then all outgoing traffic will be using (shared) public IPs and the app service does not have any outgoing access to Hub or Spoke VNets. This requires more clarifications about your setup.
If you use VNet integration then you will get features like When regional virtual network integration is enabled, your app makes outbound calls through your virtual network.
Then you should be able to do following:
Separate linked service subnet and App Service VNet Integration subnet
Send all outgoing traffic from App Service VNet Integration subnet to Firewall
(1) https://learn.microsoft.com/en-us/azure/app-service/overview-vnet-integration

Related

Do I require vnet integration for private outbount traffic - Azure API management

I'm trying to have good understanding of Azure vnet integration.
I want to deploy an API management service in Azure and I have to choose a SKU. I'm wondering if vnet integration is require for private outbount trafic ?
For instance, I have a backend vm in a vnet. Does the traffic have to go through internet if I do not use vnet integration ?
I deployed basic api management service, I can create private endpoint but this is only for inbound trafic right ?
Thanks,
I can create private endpoint but this is only for inbound traffic right?
Yes, a private endpoint will give a private IP address for inbound traffic only. Use private endpoints and regional VNet integrations in two separate subnets if you need both inbound and outbound traffic.
Currently, Private Endpoints are not supported for the Outbound traffic as the Networking model "Private endpoint" is in preview stage.
You can see the below table for the supported networking models for the types of networking traffic based on usage scenarios given by Microsoft in this Doc:
Refer to this MS Doc regarding the VNet Integration & Private Endpoint for different types of Networking Traffic types.

Connecting two App Services within the same VNet

I have two NodeJS App Services.
They can connect to each other with no problem using the URL which is created for App Services by default. (That is through the public internet.)
Then I successfully enabled VNet Integration for both App Services, and assigned the same VNet and also subnet two both of them.
How should I modify the connection URL now to connect to appservice2 from appservice1 (without using the URLs which are publicly available on the internet)?
I could not find any host name or IP address information in Azure Portal using which I could have successfully established the connection.
Thanks for any suggestions!
When you want two app services to connect to each other over a private network, there are generally two steps you have to take to set this up correctly. Note that the app service URL will always stay the same, it is only the networking part that changes.
Both app services should have vnet integration enabled, which allows the app service to route its traffic through the vnet.
If you want others (e.g. another app service) to connect to an app service via a vnet you can choose between:
a) Service endpoints
b) Private endpoints
Reading your question, I assume you completed the first step correctly. But you have to complete either step 2a or 2b to get this to work properly. I would recommend you choose service endpoints because they are more straightforward than working with private endpoints. Below you'll find a detailed description and considerations for every step.
1. Vnet Integration
The subnet you use as an integration subnet has to be a dedicated subnet. This means it is only used for vnet integration.
Only one app service plan can be used with this dedicated subnet, this one app service plan may include multiple app services.
If there is a network security group attached to that subnet, it needs to allow outbound traffic.
If there is an azure firewall attached to your vnet and you want to make a call to a public endpoint, it should allow outbound traffic.
Vnet route all should be enabled if you want all the outbound traffic to travel over the vnet.
If you want to read more, I would recommend reading this documentation.
Here is a simple example of how you would create vnet integration by selecting the dedicated subnet:
Service Endpoints
Service endpoints allow you to lock down inbound access to your app so that the source address must come from a set of subnets that you select.
Service endpoints are automatically provisioned by azure when you enable access restrictions to the app service.
This is a much simpler alternative to private endpoints.
Does not work in large-scale networks where you want to connect from an on-prem network to an azure vnet.
You may turn to this documentation to read about all the features and limitations of service endpoints.
Here is an example of how you would enable services endpoints for your app service by creating an access restriction:
Private Endpoints
Private endpoints also need a subnet, but you can connect as many private endpoints to the subnet as there are IP addresses available.
When you use private endpoints, you also need to have a private DNS zone. Otherwise, the app service URL does not resolve correctly to an IP address.
Private endpoints are more complex than service endpoints because of the extra subnet and DNS requirements.
Here is a nice tutorial that let's you set up an app service with private endpoint.
The following example shows you how to create a private endpoint for your app service. You have the option to let azure create a private DNS zone automatically, or you can do this manually:
If you want to access app services without public internet, then enabling VNET integration in those services alone won't be enough. You need to create a private endpoint that provides the IP from the virtual network to access the app service internally within the VNET and it also disables public access to the app service over the internet. Also please be aware that the private endpoint implementation will have some cost implications as well.
If your requirement is just to establish a secure connection between your virtual network & app service and to avoid access over the public internet, a service endpoint is the simplest solution. If you also need to access the app service from on-premises through an express route or Azure Gateway, a regionally peered virtual network, or a globally peered virtual network, Private Endpoint is the solution.
Steps to set up a service endpoint are detailed in the provisioning service endpoint link
Steps to set up a private endpoint are detailed in the connect to the web app using private endpoint link
Also if you want to deep dive into private endpoint configuration for app service, I would recommend you to read through the following tutorial

Access on-premise server from app service

We have set up a VPN gateway and used it to connect an on-premise network with an Azure VNet. We have successfully tested a number of scenarios
communication from VMs to on-premise DBs
communication from on-premise computers (desktops and servers) to VMs (SSH etc.)
communication from on-premise computers (desktops and servers) to services with Private Link endpoints (App Serivces, DBs etc.).
The use-case we are now attempting is to access an on-premise DB from an app-service. I have integrated the app-service to the routed VNet and also added a service endpoint to this VNet. I have seen infos that this should work but it is not getting though.
A second question is what is the actual source ip of the app-service when it connects to the on-premise server. Surely not the outbound IPs? These are non-exclusive public IPs. Opening these on our VPN firewall would be a risk. In this case is the solution to also give the app service in question a private link endpoint. Will it's source IP then be the private IP of the PL?
Private Endpoint is only used for incoming flows to your Web App. Outgoing flows will not use this Private Endpoint, but you can inject outgoing flows to your network in a different subnet through the VNet integration feature. When you enable Private Endpoint to your Web App, the access restrictions configuration of the Web App is not evaluated. So in this case, I don't think you need to set the service endpoint Microsoft.Web for your web app if you have set it. Reference from using Azure private endpoint for Azure web app.
When regional VNet Integration is enabled, your app makes outbound calls to the internet through the outbound addresses that are listed in the app properties portal. Regional VNet Integration works by mounting virtual interfaces with addresses in the delegated subnet. If WEBSITE_VNET_ROUTE_ALL is set to 1, all outbound traffic can be sent into your VNet. So the source IP address will be from the integrated subnet when app service comes to the on-premise server as the #silent's comment. Reference from how regional VNet Integration works. Please note that the feature supports only one regional VNet Integration per App Service plan.

Denylist client IP in Azure Application Gateway

We are using Azure Application Gateway for our site, and we are getting few people scraping our site. We want to block their IP at gateway level, as we don't want to configure the same blocks in every web service.
We can not find the way of blocking IPs using only the gateway or its virtual network. Had anybody the same problem and can illuminate our path?
You could deploy Application Gateway in a virtual network. If so, you will have a dedicated subnet for this Application Gateway. This subnet can only contain Application Gateways. You could associate an NSG to this subnet. If so, you could restrict inbound and outbound traffic from this Application Gateway subnet via inbound or outbound security rules in NSG. In this case, you could add an inbound security rule to backlist your clients' IP.
Refer to DOC, Note:
Network Security Groups (NSGs) are supported on the application
gateway subnet with the following restrictions:
Exceptions must be put in for incoming traffic on ports 65503-65534
for the Application Gateway v1 SKU and ports 65200 - 65535 for the v2
SKU. This port-range is required for Azure infrastructure
communication. They are protected (locked down) by Azure certificates.
Without proper certificates, external entities, including the
customers of those gateways, will not be able to initiate any changes
on those endpoints.
Outbound internet connectivity can't be blocked.
Traffic from the AzureLoadBalancer tag must be allowed.
Hope this helps.

Associate Azure AppService to a Subnet

Ive created an Azure app service in my VPN. My VPN has a few subnets, but I need my AppService to use just a specific subnet. Unfortunately, I can't seem to find any way of linking the AppService to a subnet. I need the traffic on that subnet to pass through a special NSG.
Any advice?
Thanks
The multi-tenant App Service connects to your VNET over Point-to-site VPN, it will use the Point-to-site address space as source IP address. Conversely, App Service Isolated (ASE/ASEv2) is deployed in a subnet inside the VNET.
Assuming multi-tenant App Service, this is how traffic flows —
There is no way to initiate traffic from the VM through the Point-to-site VPN and reach the Web App over the private channel. Only the other way around works. This limitation does not exist in App Service Isolated.
App Service Isolated —

Resources