Can't Access Azure Application Gateway through peered VNET - azure

I have two peered VNETs in Azure and I also have an Application Gateway in one of them. I have a couple VMs inside both VNETs and I want to access the Application Gateway from the VMs by its private IP (which is set up). This works from the VNET that the gateway resides in but I can't access it from the other peered network. I can access all the VMs between the networks by their private IPs no problem. What can I be missing? (I am not really that familiar with networking, so it can be something basic...).
Thank you for any suggestion!

You can check if the two peered virtual networks are located in a different region.
If you are using a Global Vnet peering(Vnet to Vnet region is different), there are some limitations that you can not use Global Vnet peering to communicate with VIPs of load balancers in another region. Application Gateway is actually a layer-7 load balancer.
Resources in one virtual network cannot communicate with the IP
address of an Azure internal load balancer in the peered virtual
network. The load balancer and the resources that communicate with it
must be in the same virtual network.
References: How to setup Global VNet peering in Azure

APIM is a service based on Azure Load balancer. For Stv1 APIM Azure uses Basic Load balancer which does not allow traffic via global peering.
[Refer this][1]
In order to facilitate traffic via global peering need to use stv2 APIM.[Refer this][2]
[1]: https://learn.microsoft.com/en-us/azure/virtual-network/virtual-network-manage-peering?tabs=peering-portal#requirements-and-constraints
[2]: https://learn.microsoft.com/en-us/azure/api-management/virtual-network-concepts?tabs=stv1#network-resource-requirements

Related

why Extra subnet for VNET integration for app services

Why do we have to create a new subnet or add the app service to an empty subnet in our vnet?
I don't understand the reasoning since I'm trying to use my app service (function app) as a reverse proxy to access the resources in the vnet.
By default, the Azure function is a PaaS as the other Azure Platform-as-a-Services that have inbound and outbound traffic over the Internet. We can host our applications without the need to worry about the maintenance of the servers and their operating systems.
To use Azure Functions to connect to resources in an Azure virtual network, we can use the VNet integration feature. To use this feature, we need to create a subnet in the virtual network for your function app to use. VNet Integration must be configured to use an empty subnet. It doesn't matter that your functions use a different subnet than your VM. The virtual network automatically routes traffic between the two subnets. Read Connect your function app to the virtual network
The extra empty subnet is used to hosting your app instance. To let the app instance outbound traffic work like from a VNet, Azure mounts NICs with assigned private IP addresses in that subnet. With VNet integration, your function app is connected to both the internet and your virtual network.
For more information, you may read How regional VNet Integration works and How gateway-required VNet Integration works
For an app to access resources in a Virtual Network, it needs to be either part of that network, or use a VPN gateway, which in turn can be used access resources inside the Virtual Network.
App Services provides 2 methods to communicate with resources in the Virtual Network:
Regional VNet Integration
Gateway-Required VNet Integration
With Regional VNet Integration, the infrastructure allocates a private IP interface on the VM that is hosting your Web App. This interface is allocated an IP address from the integrated subnets address prefix. This interface is later used to communicate with the VNet hosted resources. This is in a way similar to how IaaS VM work, however the limitation of this interface is that it can be only used for making outbound connections.
This way, if the ASP is configured to scale out to multiple VM's then each VM is allocated a corresponding private IP interface. However, the allocation of these IP address is limited to the subnets Address prefix. Nancy has already included this in her post. App Services have overlapped recycling so during scale up/maintenance, the App Service Plan may run on twice the number of VM's to ensure minimal downtime. However this also means, that the Integrated Subnet should have sufficient addresses available, so that these allocations can happen.
The IP Address of this interface is exposed via the environment variable WEBSITE_PRIVATE_IP. Here is a screenshot of my Kudu Console
If your site is running on multiple instances, then you can use the Instance menu to toggle through the instances.
With Gateway-required VNet Integration, there is a pre-requisite of provisioning a Virtual Network route-based gateway configured with an SSTP point-to-site VPN. In this case, the VM's hosting the Web App download the VPN package on the respective VM's to setup a VPN, and this is used to connect to the resources in the Virtual Network.
Even here, you can use the WEBSITE_PRIVATE_IP environment variable to see the IP Address used by the VPN client on the App Service VM.
HTH,
Kaushal

Azure AKS vnet to another vnet communication

We have managed AKS Cluster and it has a few applications PODS. In the same subscription, we have a few servers in the different Resource Group and different VNET. We have a requirement to happen a communication between these two VNET's. I have configured vnet peering between two VNET's but we can see that the communication is not happening.
When I add a rule like "Allow port 443 from all networks" on to the NSG of Virtual machines then everything works fine.
Troubleshooting steps are done.
VNET Peering
Got an API Server IP Address from the "kubeconfig" file and added in the NSG of VM's in a diff RG.
But did not resolve an issue. Could you please help me to fix the issue.
AKS Resources are behind the Internal Load Balancer, so peering did not help. I had to use the Public IP Address provisioned during the AKS Creation process in the NSG. After adding PIP(Available in MC_rg-*** resource group) everything started working.
I would suggest to try connecting the VNET's through VPN gateways .
From an Azure virtual network, connecting to another virtual network is essentially the same as connecting to an on premises network via site-to-site (S2S) VPN.
You will need to go through the below listed steps :
Create VNetA and VNetB and the Corresponding Local Networks.
Create the Dynamic Routing VPN Gateways for each virtual network.
Connect the VPN Gateways.
Please find the referred document for implementing the same solution I have mentioned above .
For more information on difference of vnet peering and vnet gateway you can refer this document.

Connecting App Service to Load Balanced cluster in different Resource Groups

I have 2 separate resource groups in Azure:
Contains some Services including a Linux App Service hosting Python Django
Contains an ElasticSearch cluster which I created using the ARM template from here
I want to connect from the App service in (1) to the ElasticSearch service load balancer in (2)
I tried to create a virtual network peering using
az network vnet peering create -g $webResourceGroup -n web2es --vnet-name vnet --remote-vnet $remote_vnet --allow-vnet-access
where $webResourceGroup => (1) and $remote_vnet => (2)
However, when I try to do an HTTP request to the ElasticSearch Service, it just does not work.
How do I fix or troubleshoot this?
There are some requirements and constraints for virtual network peering.
Resources in one virtual network cannot communicate with the front-end
IP address of a Basic internal load balancer in a globally peered
virtual network. Support for Basic Load Balancer only exists within
the same region. Support for Standard Load Balancer exists for both,
VNet Peering and Global VNet Peering. Services that use a Basic load
balancer which will not work over Global VNet Peering are documented
here.
So, if the peered VNets are in a different region, you cannot connect to resources that are behind a Basic Load Balancer through the Front End IP of the Load Balancer. This restriction does not exist for a Standard Load Balancer. From the parameters, you will see that loadBalancerInternalSku or loadBalancerExternalSku is by default basic, you should use a standard load balancer.
Also, you should have integrated your app with an Azure Virtual Network. Please note that you cannot reach resources across global peering connections(VNets are located in different regions) when you are using Regional VNet Integration which requires the app and the VNet must be in the same region. If so, you need to use Gateway required VNet Integration and VNet peering with gateway transit.
If possible, you could create all resources like VNet, app service, cluster in the same region. Then you do not need a VPN gateway for your VNet Integration. This may have fewer limitations and easier to deploy in your scenario.
Hope this could help you.

Azure Virtual Network Gateway - Access resources in other resource groups

Let's take the following scenario:
I have a resource group in the East Region with 1 VM
I have a resource group in the West Region with 1 VM
Both of these VMs are only accessible via Private IP addresses. RDP via Public IP address is not an option. One would assume that in order for me to RDP to these machines, I would have to VPN into Azure's gateway first. However, I don't want to create a virtual gateway in every single resource group.
Is it possible for me to vpn into one resource (in one resource group), and access all of the machines in all other resource groups?
Yes, It's possible to do this with VNet peering(connecting VNets within the same Azure region). You could follow this to implement a hub-spoke network topology in Azure. In this case, the hub VNet is a peering VNet with allow gateway transit enabled and the spoke VNet is a peering VNet with use remote gateways enabled.
please note that you cannot use remote gateways or allow gateway transit with global peering(connecting VNets across Azure regions). Refer to requirements and constraints about global peering.
To use remote gateways or allow gateway transit, peered virtual
networks in must be in the same region.
so you have to move the peering VNets in the same region if the two VNets in each resource group are not in the same region.
Another option will create a separate VPN gateway in another resource group but this is not your expectation. Note that
A Point-to-Site client can only connect to resources in the VNet in
which the virtual network gateway resides.
Refer to VPN gateway FAQ.
You can use vnet peering with Use remote gateways checkbox enabled. You need to peer the vnets together and check use remote gateways on the second vnet (one without gateway).
Reading:
https://learn.microsoft.com/en-us/azure/architecture/reference-architectures/hybrid-networking/hub-spoke
https://learn.microsoft.com/en-us/azure/virtual-network/virtual-network-peering-overview

Azure load balancer inside a subnet

I have a VNET with a subnet, there are 3 VMs in the subnet, the VNET is connected via a VPN connection to an on-premises server. The on-premises server will send requests to an internal IP of the subnet.
What I'd like to do is host a load balancer with no public IP, but has an IP in the subnet range. The on-premises app would then talk to the single load balancer, which would in turn forward the request on to any of the servers hosting my app in the subnet.
Can anyone tell me if this is possible, or an alternative if possible.
I believe you are looking for an internal load balancer.
You can find documentation for that here: https://learn.microsoft.com/en-us/azure/load-balancer/load-balancer-get-started-ilb-arm-portal.
Azure Internal Load Balancer (ILB) provides network load balancing between virtual machines that reside inside a cloud service or a virtual network with a regional scope.
Create a Load Balancer as usual, but specify Type: Internal.
Probably best to make it use a static IP address as well so it won't change.
Then you'll need to configure its back-end pool and health probe so it knows where to route traffic.

Resources