Connecting ASP on Azure Virtual Machine to Azure Db - azure

Has anyone ever connected ASP (ASP, aka classic not .NET) to an Azure db? I've had three experts looks at connection strings, endpoints, firewalls, db accounts and they're finding
the database works and contains data
the database is accessible remotely by our local machines via Visual Studio and SQL Server Manager
ASP runs on web server on the VM machine
All the connection strings offered by Azure fail
All db related ports are open

If you're connecting to the Azure DB from SSMS, everything is probably configured properly.
Which client library are you using to connect to the Azure SQL instance? You may need to download and install the MS SQL Native Client on the VM, which I know works.
Are you using ADO in your app? If so, and assuming you have installed the Native Client, this connection string will work:
Driver={SQL Server Native Client 10.0};Server=tcp:[serverName].database.windows.net; Database=myDataBase;Uid=[LoginForDb]#[serverName];Pwd=myPassword;Encrypt=yes;

Related

How do I connect to an on-premise DB2 database to an application deployed in Bluemix

I have a Node.js/JavaScript application deployed to Bluemix. I need my application to be able to connect to a DB2 datasource (connection string shown below).
The lexbz181112.cloud.dst.ibm.com is an IBM server running on premise.
What steps do I need to take to connect to this datasource from my application (which is running in Bluemix)? I don't want to change any of my application code in order to read/write from the database.
DRIVER={DB2};DATABASE=MYDB;HOSTNAME=lexbz181112.cloud.dst.ibm.com;UID=xxx;PWD=xxx;PORT=nnnnn;PROTOCOL=TCPIP
It is the same when you connect your application to remote database or cloud database, as long as you have hostname:port, database name and username/password.
If your application and database both on Bluemix, have you tried to bind this database service to your application directly?
The Bluemix Secure Gateway service is used in such cases. It establishes a secure, transparent bridge between your on-premises resource, in your case the DB2 server, and your cloud application. Because it is transparent to the application you don't need to change your application code. The secure connection is established from "on-prem" to the cloud, so that the on-prem administrators are in charge.
Some time I ago I wrote a sample application to walk through all the steps to create a scenario as described by you. You can find the instructions on GitHub.
If the host is reachable from the Internet you can simply access it from your application as you'd normally do, since a Bluemix application is able to connect to the Internet. The only improvement I'd do to this is to use a user provided service instance. It allows you to separate the DB connection parameters from the application code, avoiding to have those hard coded in the application.

Connect Azure app service to SQL Server VM using Windows auth?

Is there a way to connect from a web app (azure app service) to a SQL Server VM in Azure using Windows authentication? I'm not exactly sure if I need to impersonate or if the app needs to run under the identity that has access to the DB on the SQL Server.
I believe that you can do this - but you will need to share a Active Directory between the two - or have then in a private network together so that they are in the same broadcast subnet.
If you need to use your own Active Directory the create a network and a VPN to your site.
If you don't need to use Active Directory then use SQL Auth.
Looks like it is not possible, although it may be with Azure SQL. But not a VM running MSSQL. Ref links below.
SQL Server Integrated Security from an Azure Web Site
https://azure.microsoft.com/en-us/documentation/articles/sql-database-aad-authentication/

How to: Connect to Windows Azure SQL Server Database Through Windows virtual machin

Hi guys,
i created sql server database in windows azure. after i integrate this database with my application its working fine.i want to move my application also windows azure virtual machine.i created required Environment(means install java and tomcat) for this.and also allow the ip address in azure sql server database also.but it showing
Connect open connection error
while connecting database.i also allow the port number in wirewall settings but still i am not able to connect database.
please give any suggestions.
From your question it is a little bit unclear which database you're using -
If you're using 'Windows Azure SQL Database' (i.e. the PaaS version), than you need to ensure that your server's firewall, through the Windows Azure Management Portal, is configured to allow Windows Azure Services and then, of course, you need to use the fully qualified name of the server when trying to connect (i.e. ABCD.database.windows.net)
If you have deployed SQL Server as a VM on IaaS you have two options - either define an endpoint for the VM to open port 1433 (or any other port mapped to 1433 for that matter) to the outside world and then use the cloud service's DNS entry to connect to the database or define a virtual network onto which you will deploy both your database VM and your application VM. if you do the latter you will be able to refer to the database using it's private IP.
this might be somewhat useful

How do I SQL query from Azure Web Role to SQL Server 2008 R2 Express hosted on VM Role?

I have SQL Server 2008 R2 Express installed on Azure VM Role (1 extra small instance).
Because of hosting very old banking system, which is not able to connect to SQL Azure. Data persistency is reached via Azure Storage Page Blob. I have written a Windows Service, which can mount VHD file and also can attach MDF database file to SQL Server.
My problem is that I need to SQL query from Azure Web Role to SQL Server hosted on Azure VM Role.
I tried nearly everything:
I have opened TCP 1433, UDP 1434, added SQL Browser to Windows Firewall.
I have enabled remote connection, SQL Server Browser, TCP/IP, Named Pipes on SQL Server.
I have changed TCP/IP port to 1433 and I have disabled dynamic port.
I have already read:
http://social.msdn.microsoft.com/Forums/en-US/windowsazuremanagement/thread/b5f2967e-57e6-4099-9077-fb6d74897dbf
http://social.msdn.microsoft.com/Forums/en/windowsazuremanagement/thread/2b64a56f-fda7-4247-b016-9d25bbeebe8b
How to access sql server installed on Azure VM (VM Role ) outside of VM?
If you were so kind and wanted to help me, I would send you all the screenshot from my settings.
Thank you for your time.
Regards,
Martin David
Wenchao Zeng from Microsoft Contingent Staff gave me a solution:
http://social.msdn.microsoft.com/Forums/en-US/windowsazureconnectivity/thread/c7124598-4894-4b6c-8987-709a9f788ea4

Can I host an application in Windows Azure and have the database stored on different server

Can I host an application in Windows Azure and have the database stored on different server? For example I want to keep my data on a server where I dont have to worry about privicy issues. And if this is possible does it remove the value of having an application hosted in the cloud?
thanks
You mean hosting your application on Windows Azure and then hosting the database on your own servers? This is totally possible, but you'd have to publicly expose your database. You could host your database on SQL Azure and that would be a 'separate server' from your Windows Azure host. With SQL Azure, you can set up a firewall rule to allow only your application to access your database.
If you were to host your database on your own servers, I don't think that it would completely diminish the value of hosting your application on the cloud as your app tier at least would still be hosted "in the cloud". Though, you could also run into performance issues in this scenario as SQL is a little slow to access over the internet using TCP.
You can host on premise and use a secure VPN as part of Azure now. This can be done using Azure network in the latest release.
Can setup an Azure site to site VPN and get access to your private data centre that way.

Resources