16

I am learning ASP.NET 5 (vNext) on my Mac. For the last day, I've been stuck trying to connect to my SQL Azure database. In that attempt, I've been using the following code:

var serverName = "[protected]";
var dbName = "[protected]";
var userId = "[protected]";
var password = "[protected]";
var sql = "SELECT * FROM Customer";

using (var database = new SqlConnection("Server=tcp." + serverName + ".database.windows.net,1433;Database=" + dbName + ";User Id=" + userId + ";Password=" + password + ";Trusted_Connection=False;Encrypt=True;Max Pool Size=25"))
{
  database.Open();
  return await database.QueryAsync<T>(sql);                     
}

When this code gets executed, an exception is thrown. The exception details looks like this:

Type:
System.NotImplementedException

Message:
SSL encryption for data sent between client and server is not implemented.

UPDATE I learned that encryption isn't supported in the framework running on Mac OS X at this time. For that reason, I updated my connection string to looks like the following:

var connectionString = "Persist Security Info=False;Integrated Security=true;Initial Catalog=" + dbName + ";server=" + serverName + ";User Id=" + userId + ";Password=" + password;

Still, when I use the connection string above, I get the following error.

Type:
System.Data.SqlClient.SqlException

Message:
Server does not exist or connection refused.

I have confirmed that my IP address is not blocked by Azure. I did this by logging into the Azure Portal and managing the SQL Server database from the Silverlight app. Yet, I'm still not sure why I'm getting this error.

If I am understanding this correctly, there is not a way to connect to a SQL Azure database at this time from ASP.NET 5 running on a Mac. Is that true? If it is not true, what am I doing wrong?

5
  • Which framework are you using? Commented May 28, 2015 at 13:36
  • @PanagiotisKanavos I am using ASP.NET 5 (vNext). I am attempting to connect via the System.Data.SqlClient.SqlConnection which is in the ` "EntityFramework.SqlServer": "7.0.0-*"` package.
    – Some User
    Commented May 28, 2015 at 16:01
  • I'm closer. I've updated the question with more details.
    – Some User
    Commented May 29, 2015 at 18:48
  • @BrianAtkins I just confirmed it is not blocked. I am able to manage it through the portal. In addition, I got the ip address via ifconfig | grep "inet " | grep -v 127.0.0.1. I confirmed that both of these were whitelisted in the allow ip address list. I am still getting the same error.
    – Some User
    Commented May 30, 2015 at 12:36
  • In your new connection string, I don't see database.windows.net as part of the server name. Did you include that in your server name?
    – Satya_MSFT
    Commented May 31, 2015 at 5:31

3 Answers 3

11
+25

As you are aware vNext on Mac is under public preview.
We are still working on providing SQL connectivity. SSL encryption is not supported on Mac yet and Azure SQL DB requires one. The project is in the pipeline and we will let you know once we have something to share.
In the meanwhile if you have any other questions please let me know.

Best,
Meet Bhagdev
Program Manager, Microsoft

6
  • Any updates yet? This still doesn't seem supported – it's a critical scenario if you're running any server hitting an Azure SQL DB (which is pretty much the core server scenario)
    – Marchy
    Commented Dec 5, 2016 at 15:04
  • Integrated security is not yet available on .NET Core. I think that's why the original post failed. Can you try SQL Authentication with SSL enabled to see if that works? (set encrypt=true). Commented Dec 6, 2016 at 1:34
  • Is there still no answer to this?
    – Jonathan
    Commented Jan 26, 2017 at 19:27
  • @Jonathan - what version of .NET Core are you using? More specifically, what version of System.Data.SqlClient are you using? Commented Jan 27, 2017 at 0:59
  • <package id="System.Data.Common" version="4.3.0" targetFramework="net461" /> <package id="System.Data.SqlClient" version="4.3.0" targetFramework="net461" />
    – Jonathan
    Commented Jan 27, 2017 at 1:06
4

Switch to using mono as a build target. This should give you access to ssl in entity framework.

3

I know this isn't the answer you are looking for, but SQL Azure requires SSL per https://msdn.microsoft.com/en-us/library/azure/ff394108.aspx.

I am pretty sure you are stuck until SSL support is added to OS X (either via Mono or CoreCLR).

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.