Azure Cloud - connecting web application to mysql database - azure

Relatively new to azure cloud so go easy
Configuration as below on
1 x app service (running asp.net web application)
1 x azure database for mysql server
(so currently 2 resources)
Now whenever i put my connection string into my web app to point to the mysql database hosted on azure, it just times out, with the error below
[MySqlException: Unable to connect to any of the specified MySQL hosts.]
I have set the security to allow access to azure services as per documentation, and disabled the enforce SSL for now. I am able to connect to the database remotely from my machine, but my web app times out.
I have tried every permutation of connection string but it makes no difference. It works if i use the mysql in app but this is not a scalable solution for us.

Did you copy your connection string from Azure and plug it into your web config under the connectionstrings node? If so, did you remove the connectionstring name then re-add it? Such as:
<connectionStrings>
<remove name="conn" />
<add name="conn" connectionString="Server=localhost\SQLEXPRESS;Database=***;Trusted_Connection=True;" providerName="System.Data.SqlClient" />
This is the best practice for using a connectionstring in a webconfig file.
As well take a look at your error details. You are trying to use environment variables for connecting to the database. This won't work because you are in two different environments: the first being your web app environment and the second being the database environment.
Even if you are using Azure as a host, it still won't work.

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/

Api App Sqlconnector not allowing Hybrid setup

Trying to configure my SQL Connector API App named (CENTRAL.SQLCONNECTOR.EMPLOYEESYNC.DEV) to use the Hybrid Connection Manager. I have had to delete it and recreate multiple times assessing the query options, and confused because it seems very inconsistent to allow the Hybrid Connection setup. It currently reads below...
Hybrid Connection
Not configured as a hybrid ApiApp
The prior time it allowed it fine, and I was able to successfully setup the Hybrid Connection Manager on my web server. Could you please look at this api app, and maybe tell me what I may be doing wrong.
Thanks

Windows Azure Platform Ready Testing Tool

I am running the platform ready test tool to try and qualify for the Powered By Windows Azure Logo Program.
My application is in production and has been running in azure for 5 months now. The application consists of a windows forms and WPF Client application which connects to a set of WCF Services running in azure which in turn connects to SQL Azure. The application also uses blob storage in Azure and I have getting on for 1TB of documents up there.
The application uses basic http binding and is configured Like this
<security mode="TransportWithMessageCredential">
<message clientCredentialType="UserName" />
</security>
I successfully passed the test for SQL Azure but failed the test for windows azure with the following message
======================================================================
Test case/Verification: TC 1 -
Application must be a valid Azure
application designed to connect with
or work in the Windows Azure Environment
======================================================================
Status is ProtocolError
Fail
The only thing I can think of this is causing this is that the application connects over https and the test tool does not allow me to specify a https endpoint. However I don’t think I can easily expose a plain http endpoint just to pass the test as WCF wont allow me to do that when TransportWithMessageCredential is used.
Does anyone have any ideas?
Our service AzureWatch is in the same boat. I've been in touch with MS engineers at the Ready program and they don't appear to support our precise scenario. However, they do have a version of the tool that can use https channel. I suggest contacting them via support channel. They may supply you with a later version to try, and if that fails with forms to request "bypass" of the actual testing
HTH

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