LAN connection between Azure App Service and Azure VM-hosted SQL? - sql-server

We've been experimenting with hosting our ASP.NET + SQL Server application in Azure. We've tried two ways so far:
App Service for ASP.NET, VM for SQL Server, both in the same data-centre, so I imagine a LAN connection is possible, but currently the connection string lists the public IP
A single VM for both IIS ASP.NET and SQL Server (an interim solution - we will eventually move SQL behind a firewall)
We'd prefer the first option because of costs and manageability. But it seems slower (I guess because of the public IP in the connection string).
Question
Can the App Service - SQL connection be LAN rather than WAN/internet? Are there any specific tricks during setup to achieve this?
What I've tried
The SQL VM is in a VNet. I've tried adding the App Service into the VNet (based on the guess that it'll then be able to see the SQL VM's internal IP), but the existing VNet is not selectable in the App Service's VNet configuration options.

Can the App Service - SQL connection be LAN rather than WAN/internet?
According to your description, maybe we can use VPN to integrate your app with an Azure Virtual Network.
When we want to select one Vnet for Azure app service, we should setup a point-to-site VPN with a Dynamic routing gateway.
Getting started
Here are some things to keep in mind before connecting your web app to
a virtual network:
•VNet Integration only works with apps in a
Standard, Premium, or Isolated pricing plan. If you enable the
feature, and then scale your App Service Plan to an unsupported
pricing plan your apps lose their connections to the VNets they are
using.
•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.
More information about integrate App with an Azure virtual network, please refer to this link.

Related

How to security access onprem database from Azure AppService

Is there a way to securely access a on-prem Sql Server, from an AppService?
The IT guys are nervious about letting an App Service which needs access to our on-premise database.
I am not a networking guy, and am trying to come up with a solution.
The only thing I have thought of is creating a new database (CDS_API). The AppService is then given a connection string to this database. This database would then have access to the primary database (CDS).
If the AppService has only execute permissions to CDS_API, this seems secure to me. Am I missing something?
Is there a better way to do this?
The simple solution is to use an App Service Hybrid Connection
Hybrid Connections can be used to access application resources in any
network that can make outbound calls to Azure over port 443. Hybrid
Connections provides access from your app to a TCP endpoint and does
not enable a new way to access your app. As used in App Service, each
Hybrid Connection correlates to a single TCP host and port
combination. This enables your apps to access resources on any OS,
provided it is a TCP endpoint. The Hybrid Connections feature does not
know or care what the application protocol is, or what you are
accessing. It simply provides network access.
Alternatively, you can Integrate your app with an Azure virtual network which is connected securely to your on-prem networks either with a Site-to-Site VPN or over ExpressRoute.

Connect VM or web app in one region to SQL server in another region across globally peered vnet in azure

I have an azure web app in UK South and an azure SQL server in UK West. At the moment they can communicate because I have the option enabled on the server to allow access to azure services.
I want to secure the SQL server behind a vnet, so I have created a vnet in each region and setup peering between them.
I have added vnet rule to the SQL server and enabled the service endpoint for sql on the subnet so that the SQL server is now secured behind the vnet in the same region, and disabled the option to allow access to azure services.
I have then added the vnet in UK South to the web app (using the preview option in the portal), which I assumed would allow the web app to access the SQL server via the peered vnet. However the connection keeps getting refused.
Am I correct in my assumption that this should just work? Or am i missing something?
I have also tried setting up a VM on each vnet and while I can ping each VM from the other and can get the vm in the same region as the SQL server to connect. I cant get the VM in the other region to connect to the SQL server.
Can anyone help with how I get this setup correctly?
According to my research, if we use regional VNet Integration (using the preview option in the portal), we cannot reach resources across global peering connections(Connecting virtual networks across Azure regions). For more details, please refer to the docuemnt
According to the situation, I suggest you add your web app and sql in the same region VNet.

Give Azure web service access to existing remote SQL Server?

I am trying to make a web page that is going to make an API call to query data in our existing remote SQL Server. When I am testing it now, my code can access the database using windows authentication, but when I deploy this web page on Azure, will my code be able to still access the remote SQL Server using windows authentication? If not, what do I need to do in order for my web page to query the data in the existing remote SQL Server?
Hybrid Connections is both a service in Azure and a feature in Azure App Service. As a service, it has uses and capabilities beyond those that are used in App Service. To learn more about Hybrid Connections and their usage outside App Service, see Azure Relay Hybrid Connections.
Within App Service, Hybrid Connections can be used to access application resources in other networks. It provides access from your app to an application endpoint. It does not enable an alternate capability to access your application. As used in App Service, each Hybrid Connection correlates to a single TCP host and port combination. This means that the Hybrid Connection endpoint can be on any operating system and any application, provided you are accessing a TCP listening port. The Hybrid Connections feature does not know or care what the application protocol is, or what you are accessing. It is simply providing network access.
https://learn.microsoft.com/en-us/azure/app-service/app-service-hybrid-connections

Connect Azure webapp to sqlserver in rackspace

I have hosted a webapp in azure cloud.
My MS sql database is in rackspace which only allows a selected ip to access.
I can add more IPs to allow access to the rackspace database.
Which IP address of the Azure webapp should I add in rackspace?
Is it the customDomain's IP address or something else.
There isn't just one - check out this doc - basically Azure Web Apps run in a server farm that's managed by Microsoft. Unless you use an ASE (app service environment) you can't change this. There are a couple of ways you can do what you're trying to do - either
1 - connect over the internet by opening up the ports on your rackspace VM - this will work, but opens you up to the possibility of a network layer attack from any app that someone hosts in Azure. (so you're relying on authentication rather than network level protection).
2 - use a hybrid connection - this is an app service feature that allows you to download a gateway exe app that runs in your VM in rackspace, and then connects to the app service and creates a secure tunnel to it. Hence, its outbound from your rackspace DC, you don't need to change firewall settings. You can read about it and download the app from the azure portal (in app services). You then configure the connection in your azure web app just as if the rackspace VM was on the same network. (eg. you can use "localhost" if the gateway exe is running on the sql server). This is the approach I'd recommend if you can't move your SQL estate to Azure SQL and hence locate it alongside your web apps.

Connect azure web site to on-premise database over site-to-site vpn

my goal is to run an azure web site that accesses data from our local company database.
I followed a tutorial on the web to setup an azure virtual network and connect it via site-to-site vpn to our local company network. In the azure portal I can see that the connection is actually working and that data is received and transmitted.
What do I have to do make the azure web site connect to the database? Is it enough to enter a connection string in the web config?
Is it meant to work this way, or is the site-to-site vpn only set up to access azure virtual machines from the company network.
Let me know if I should provide more details on the connection overall.
Thanks for you help in advance.
Best regards,
Frank.
Azure Web Sites do not support the Azure Virtual Network (as of 8/22/2013);
http://www.windowsazure.com/en-us/manage/services/web-sites/choose-web-app-service/
You will need to create a cloud service deployment instead if you would like to use Virtual Network and access the on-premises database. Once that is done and your firewall is properly configured, it is like you say just a connection string.
I am currently looking into connecting Azure Web Sites to an on-prem SQL database using the Azure Service Bus:
http://www.bradygaster.com/post/windowsazurewebsites-onprem-servicebus
http://azure.microsoft.com/en-us/documentation/articles/cloud-services-dotnet-hybrid-app-using-service-bus-relay/

Resources