0

I am trying to add a connection string for a SQL server instance for an Azure Function (although I have tried App Service as well). I believe it is not escaping the backslash for the instance.

My connection string that is not working is:

Server=dbname\test;Database=ABC;User Id=azure;password=xxx

I have tested it from my development environment, and it works fine, but when I use it in Azure connection string it does not.

I have used the same connection (with different user and password) with the root server name and it works fine.

Server=dbname;Database=DEF;User Id=azure;password=yyy

Being able to connect from my development environment shows that the server is setup to accept connections, and being able to connect to the root server and not the instance shows that their is not a network issue from Azure to my SQL server. I think the connection string is not able to escape the "\".

I have tried putting 2 backslashes to escape the connection string, and still no luck

Server=dbname\\test;Database=ABC;User Id=azure;password=xxx

Does anyone know if this is a known issue, or is there a special way to enter a connection string for an SQL that has an instance?

Also, to easily test this, you can add the connection string in the configuration page under Connection String. Next go to 'Diagnose and solve problems' then 'diagnostic tools' then 'Check Connection Strings'. Azure Functions or App Service will automatically check the connection.

Eric Wild
  • 641
  • 5
  • 12

1 Answers1

0

This page shows us all types of connection string. We can see the first connection string on that page, we need to provide server address after "server=". enter image description here So you connect to the sql server successfully when use second connection string you provided in the question.

But we can see the third connection string on that page, it shows as below. enter image description here In this type, we need to provide server name and instance name after "server=", but in azure sql server, we can just get server address but not server name(the "myServerName" shown in the screenshot above should be the computer name which we install sql server, so we can't get it on azure portal). So we can't connect to sql server in this type of connection string.

Hope it would be helpful to your problem~

Hury Shen
  • 14,948
  • 1
  • 9
  • 18
  • I should have been more clear. This is not an Azure SQL server, it is a regular SQL Server. It is the function app is connecting to our network through a VNET in Azure. This is why I tested to see if there was a connection at all by connecting to root server (which works). – Eric Wild Oct 30 '19 at 11:35