How to add user route to Azure App Services - azure

I have an Azure VM with inside custom vpn to 172.254.254.0/24 route.
I am able to reach that VM from another azure VM adding an "user route" to a "route table" in that VM. It works perfectly.
Now I have an Azure App Services web application.
I need to add the route above too.
But I am stuck I am not able to do it.

Integrate your app with an Azure Virtual Network
The VNet Integration feature has two variations.
Regional VNet Integration - When connecting to Resource Manager VNets in the same region, you must have a dedicated subnet in the VNet you are integrating with.
Gateway required VNet Integration - When connecting to VNets in other regions or to a Classic VNet in the same region you need a Virtual Network gateway provisioned in the target VNet.
Gateway required VNet Integration only provides access to resources in the target VNet or in networks connected to the target VNet with peering or VPNs. Gateway required VNet Integration doesn't enable access to resources available across ExpressRoute connections or works with service endpoints.
Refer: https://learn.microsoft.com/en-us/azure/app-service/web-sites-integrate-with-vnet#enable-vnet-integration

Related

Firewall access from Azure app service to blob storage using Virtual Network

Originally I tried to restrict access from an app service to blob storage using IP addresses, however it turned out that you can only do this using a Virtual Network: Firewall access from Azure app service to blob storage
I want to be able to achieve this without setting up a point-to-site VPN. The steps I have taken to set up a virtual network in Azure are as follows:
Created Network security group "securitygroup-frontend", add custom
inbound rule called Web with Source: Service Tag, Source service tag:
Internet, Source port ranges: *, Destination : Any, Destination port
ranges: 80, 443, Protocol: Any, Action: Allow, Priority: 100
Created Virtual Network with address space 192.168.0.0/23 and subnet called frontend address range 192.168.0.0/26 with network security group: securitygroup-frontend and subnet delegation to Microsoft.Web/serverFarms and service endpoints Microsoft.Storage
Went to app service -> Networking -> Configure VNet integration ->
Add VNet preview and select the subnet you created
Went to Storage -> Firewalls and virtual Networking -> Configure VNet integration -> Select 'Selected networks' and add in the virtual network and subnet just created.
I have had to move Azure diagnostics and logs such as for key vault, service bus and sql azure to its own blob storage as these require blob storage outside of a virtual network and can't be made to work inside. The app service is in the Standard plan. The app service, blob storage and virtual network are all in the same region.
This question and answer does not provide any insights: https://social.msdn.microsoft.com/Forums/azure/en-US/9f4d8aeb-68a6-4ec1-9e11-bee2d1301792/allow-access-to-azure-storage-account-only-from-an-app-service?forum=windowsazurewebsitespreview
The above steps though block off access from the app service to blob storage and any assets within return an error: (403) Forbidden. If I remove the Virtual network from blob storage it works fine. What am I doing wrong?
Yes, you can do this using a VNet but you need to deploy the web app in a VNet with App Service Environments. You can not do this with VNet integration. Integrating Azure services to an Azure virtual network enables private access to the service from virtual machines or compute resources in the virtual network. However, web app service in a regular app service plan is multi-tenant. With ASE, you could deploy it into your VNet.
You could get more details and explanation from this similar thread. According to a comment from silent, you could also consider deploying your web app inside a container which could be deployed in a VNet with some restriction.
Update
Sometimes, the deployment order for networking is important. In your case, you enable service endpoint before VNet integration. I suggest removing NSG restriction in integrated app subnet VNet for a test. Then you could check the following steps.
Firstly, you could deploy new VNet integration with an unused subnet. After the VNet Integration is completed and the web app is restarted, you could enable service endpoint and subnet delegation for this subnet. In the end, you could add the subnet in the firewall of the storage account.
The new version is in Preview and not GA currently. It might be not all functions available. you could also check the following characteristics.
No gateway is required to use the new VNet Integration feature。
You can access resources across ExpressRoute connections without any additional configuration beyond integrating with the ExpressRoute connected VNet.
The app and the VNet must be in the same region.
The new feature requires an unused subnet in your Resource Manager VNet.
Your app must be in an Azure App Service deployment that is capable of scaling up to Premium v2.
Your App Service plan must be a Standard, Premium, or PremiumV2 plan Production workloads are not supported on the new feature while
it is in Preview
The new VNet Integration feature doesn't work for apps in an App Service Environment.
You cannot delete a VNet with an integrated app.
Route tables and global peering are not yet available with the new VNet Integration.
One address is used for each App Service plan instance. Since subnet size cannot be changed after assignment, use a subnet that can
more than cover your maximum scale size. A /27 with 32 addresses is
the recommended size as that would accommodate an App Service plan
that is scaled to 20 instances.
You can consume Service Endpoint secured resources using the new VNet Integration capability. To do so, enable service endpoints on the
subnet used for VNet Integration.

How to integrate Azure Web App with a VNet with gateway transit

I have two VNets: A and B.
VNet B has a VPN gateway and connected to an on-premise network. VNet A is peered with VNet B with transit gateway enabled. This works perfectly for virtual machines. I deploy VMs to VNet A and can access on-premise resources from there VMs.
Now I want to deploy a Web App and connect it to VNet A, so the web app will have access to on-premise resources. But to do so, I need to add a VPN gateway into the network A, which is impossible when the network is peered with another network with Use remote gateway option on. But I need this option to be on to have access to on-premise resources.
What should I do? How I can give access from Web App to on-premise resources without using App Service Environment? Is it possible?
Basically, I need the combination of these two schemes
In this case, you should integrate with VNet B from the Azure web app. Also, It will be integrated with a point-to-site VPN enabled VNet. There is a new version of the VNet Integration feature that is in preview. It doesn't depend on point-to-site VPN. From your scenario, the web app is working like " VPN clients" in a P2S connection on the second picture.
Here are some things to keep in mind before connecting your web app to a virtual network:
A target virtual network must have point-to-site VPN enabled with a
route-based gateway before it can be connected to app. The VNet must
be in the same subscription as your App Service Plan(ASP). The apps
that integrate with a VNet use the DNS that is specified for that
VNet.
Ref: https://learn.microsoft.com/en-us/azure/app-service/web-sites-integrate-with-vnet

How can I connect an azure app service plan to a vnet which is also connected through peering to another vnet

I am trying to seup this hub-spoke toplogy where I have a hub vnet connected to an expressroute circuit https://learn.microsoft.com/en-us/azure/architecture/reference-architectures/hybrid-networking/hub-spoke
I have another VNET (lets call it the app vnet) set up with peering to this hub VNET where I can create a virtual machine and ping resources on the other end of just fine using the remote gateway setting on the peering.
The problem is by using remote gateway, my app vnet cannot have its own gateway, and so I cannot integrate an app service plan with the vnet.
Is there another way I could accomplish this?
I would like to suggest setting up a VNet-to-VNet VPN gateway connection instead of Vnet peering between hub vNet and app vNet. If so, Each of vNet will have their own gateway. The App vNet will be integrated with your web app. You need to ensure that the address prefixes don’t overlap among all the connected networks.
Update
Perhaps you can use the new preview VNet Integration.
There is a new version of the VNet Integration capability that doesn't
depend on Point-to-Site VPN technology. Unlike the pre-existing
feature, the new Preview feature will work with ExpressRoute and
Service Endpoints.
The new version is in Preview and has the following characteristics.
No gateway is required to use the new VNet Integration feature You can
access resources across ExpressRoute connections without any
additional configuration beyond integrating with the ExpressRoute
connected VNet. The app and the VNet must be in the same region
...
Ref: https://learn.microsoft.com/en-us/azure/app-service/web-sites-integrate-with-vnet#new-vnet-integration
The limitation that you are encountering is from the Vnet gateway perspective. Using remote gateway over peering handicaps one from deploying the Gateway in that Vnet.
The alternative as suggested by #nancy should do the trick. But, you will have to incur the cost of having the gateway. Secondly, this will require a co-existence set-up.
That is you will have to deploy another VPN gateway:
Change of reference:
VNET-HUB (Your hub VNET with ExR)
VNET-SPOKE1 (Current peered as referred to as your Application VNet)
Your VNET-HUB has an ExR gateway, it needs to have another VPN gateway.
Your VNET-SPOKE1 needs to have a VPN gateway deployed as well.
Allowing for the VNET-HUB to talk to the App Service Environment that you would integrate via point-to-site.
Note: The On-premise will not be able to access the App VNet as we can't have a Point-to-site co-exist with Express Route.
I hope this has provided an insight into the limitations.
References/good reads:
https://learn.microsoft.com/en-us/azure/expressroute/expressroute-routing
https://learn.microsoft.com/en-us/azure/expressroute/expressroute-howto-coexist-classic
https://learn.microsoft.com/en-us/azure/expressroute/expressroute-faqs
https://learn.microsoft.com/en-us/azure/app-service/environment/app-service-app-service-environment-network-configuration-expressroute

Cannot integrate Azure Web App to Vnet

I have Web App and SQL Server VM on Vnet running on Azure.  I would like to integrate Web App to virtual network.
I'm followings https://learn.microsoft.com/en-us/azure/app-service-web/web-sites-integrate-with-vnet#managing-the-vnet-integrations
1) I created gateway subnet and gateway.
2) I opened "App Service->Networking->VNet integration->Setup->Virtual network is visible but it is gray!
What I need to do that I can connect Web App to Vnet?
There are multiple reasons that a VNet can be grayed out including:
• the VNet is in another subscription that your account has access to
• the VNet does not have Point to Site enabled
• the VNet does not have a dynamic routing gateway
According to your steps, This issue may caused by that you might not configure a P2S address pool of your VPN gateway .
I did a test in my lab, and finally I can integrate my Web App to the Vnet.
You should to check these two point as following images:
Your VPN ponit-to-site configuration:
Your VNet connected devices:
How to Enabling Point to Site in a Resource Manager VNet:
To configure a Resource Manager VNet with a gateway and Point to Site, you can use either PowerShell as documented here, Configure a Point-to-Site connection to a virtual network using PowerShell or use the Azure portal as documented here, Configure a Point-to-Site connection to a VNet using the Azure portal. The UI to perform this capability is not yet available. Note that you need to create certificates for the Point to Site configuration. This is automatically configured when you connect your WebApp to the VNet.

How to Connect Azure Web App/ API App to Classic portals networks?

I have a Azure Web app and API App which are accessing some services from network which is connected to Client's network via old (classic) portal.This networks is already connected to client and Created in Classic portal.
While Creating Web/API App in new portal i am not able to connect to this existing network. Is there any way i can connect these apps to classic portals network?
Is there any way i can connect these apps to classic portals network?
Yes, but VNet Integration only works with apps in a Standard, Premium, or Isolated pricing plan. If your WebApp service plan is not in the Standard+ service plan, please have try to scale your App Service Plan to support it. We could get the details steps about how to enable VNet Integration from the Azure official document. The following is the snippet from the document.
Note:
If your target virtual network already exists, it must have point-to-site VPN enabled with a Dynamic routing gateway before it can be connected to an app. If your gateway is configured with Static routing, you cannot enable point-to-site Virtual Private Network (VPN).
The VNet must be in the same subscription as your App Service Plan(ASP).
The apps that integrate with a VNet use the DNS that is specified for that VNet.
By default your integrating apps only route traffic into your VNet based on the routes that are defined in your VNet.
Enabling VNet Integration with a pre-existing VNet
The VNet Integration UI allows you to select from a list of your VNets. The Classic VNets indicate that they are such with the word "Classic" in parentheses next to the VNet name. The list is sorted such that the Resource Manager VNets are listed first. In the image shown below you can see that only one VNet can be selected. There are multiple reasons that a VNet can be grayed out including:
the VNet is in another subscription that your account has access to
the VNet does not have Point to Site enabled
the VNet does not have a
dynamic routing gateway
Related link:
Create a virtual network (classic) by using the Azure portal
Connect virtual networks from different deployment models using the portal

Resources