1

We are trying to get connectionstring from Azure Web App to work with our ASP.net Website.

We have configured the connection string correctly in Azure Web App:

enter image description here

However, when we visit our Kudu environment page its showing a completely incorrect connection string, cannot figure out why its not showing our custom connection string.

enter image description here

Also - we are using a custom connection string because we have a special connector (Devart Mysql) that we need the provider name to remain correctly.

enter image description here

When we try to load our site we receive this: enter image description here

I'm wondering if azure web app is overriding our provider and resetting it to a Sql Server provider instead of the Devart.MySql provider we need to use. Appreciate any help/guidance

UPDATE

Checking the web.config using kudu it appears that azure is automatically changing the provider name to System.Data.Entityclient - how can we prevent this from happening? I believe this is the root of the issue

Also - we are using a barebones project to test this with the bare minimum so we know that there aren't other factors in the project manipulating these values, pretty certain azure web app is making this change, just not sure how to fix it

enter image description here

99823
  • 2,407
  • 7
  • 38
  • 60
  • you don't need to specify azure connection string if you have specified it in app.config. it works the opposite way too. you can specify both, but azure setting is always top prio though. i am not sure how it is possible to get this kind of error, maybe you have Debug config to have correct connection string, but did not change your Release config which is used when you deploy to azure? – Yehor Androsov Jan 23 '20 at 19:36
  • i would assume that you have wrong release config and have not specified correct db for it too, that is why it is showing wrong value in Kudu – Yehor Androsov Jan 23 '20 at 19:38
  • you also can check your current web.config using the Kudu cmd panel, under wwwroot folder – Yehor Androsov Jan 23 '20 at 19:40
  • i've checked the kudu web.config - it is automatically changing the provider name - i've updated the question with more details - how can we prevent the providername from changing? – 99823 Jan 23 '20 at 19:49
  • what configuration are you deploying with? you should locate Web.Release.config in your VS web project and make sure you have correct connection string. – Yehor Androsov Jan 23 '20 at 19:55
  • or just try CTRL+Shift+F and look for EntityClient in your solution, i still think the issue is in your project, not in azure – Yehor Androsov Jan 23 '20 at 19:57
  • we have checked both the release and debug config and neither reference the System.Data.EntityClient – 99823 Jan 23 '20 at 20:05

1 Answers1

0

For .NET apps like ASP.NET, these connection strings are injected into your .NET configuration connectionStrings settings at runtime, overriding existing entries where the key equals the linked database name.

These settings will also be available as environment variables at runtime, prefixed with the connection type. The environment variable prefixes are as follows:

SQL Server: SQLCONNSTR_
MySQL: MYSQLCONNSTR_
SQL Database: SQLAZURECONNSTR_
Custom: CUSTOMCONNSTR_

You retrieve the settings in your application using ConfigurationManager.ConnectionStrings["keyname"];.

So in web.config set the connectionString blank and will automatically use the connectionString of the application settings. For more details, you could refer to this tutorial.

Joey Cai
  • 18,968
  • 1
  • 20
  • 30