0

When publishing MVC app on Azure, the connection string is picked automatically but I fail to understand how the deployed app connects to the database using this connection.

There's server error: SqlException (0x80131904): A network-related or instance-specific error occurred while establishing a connection to SQL Server. The server was not found or was not accessible.

How do I resolve this on Azure.

Jeroen Heier
  • 3,520
  • 15
  • 31
  • 32
Mazolo
  • 307
  • 4
  • 19
  • How is the connection string defined in your Web.config? Also, have you defined it in Application Settings if using Web Apps? If you tick "Use this database" when deploying, it changes the configuration file to instead include that connection string. If you use Azure Web Apps though, it's better to put the connection string in the Application Settings, from which it can override the connection string in the configuration file. – juunas Mar 02 '17 at 11:09
  • When deploying, there's connection string from web.config. How do I then write connection string on Azure. My context class points to local database. – Mazolo Mar 02 '17 at 11:41
  • You'll need to look at documentation: [link](https://learn.microsoft.com/en-us/azure/app-service-web/web-sites-configure#application-settings). Add your database connection string to the app's Application Settings' Connection strings section with same name as in your Web.config. – juunas Mar 02 '17 at 13:09
  • Thanks, what I do not understand is the connection string credentials like password, do I use myApp.scm.azurewebsites.net:443 as server name? – Mazolo Mar 03 '17 at 05:42

0 Answers0