0

-- Background: I am using asp.net mvc project with 3.1 .net core. I have azure setup for hosting it in app service. For Database, I have mysql database server set up on Azure (version 5.7).

-- Problem: I am using basic connection string when connecting to mysql database. But it is not working for hosted application.

  • When I connect the azure hosted database server locally using WorkBench, and run the program (locally), it 'works'. (WorkBench connection has Ssl = required and SSL cert File attached.)
  • But when I publish the same code with same connectionString, it is not working.

IS IT BCZ OF:

  • I am using 5.7 azure mysql database server? (To update the version, do I need to create new mysql server on azure and pay $20? Because Mycrosoft documentation says there is 'Upgrade' option on overview. But there is not. Or might for higher subscription. Any suggestions?)

  • If the reason is I am missing mentioning ssl certi on hosted platform, how can I add it? Do I need to get storage to store that certificate? How can I mention that path in connectionString?

  • Any other reason for this problem?

I checked YouTube, Microsoft documents, And Google but didn't find solution.

UPDATE:

Libraries used:

MySql.EntityFrameworkCore 3.1.X

Microsoft.EntityFrameworkCore 3.1.X

MySql-Connector-Net 8.0.X

Connection String used: "Server=.mysql.database.azure.com;Port=3306;Database=;Uid=;Pwd=;"

  • 1
    You didn't post any code, connection string, exceptions or explain what libraries you use, so we can only guess. .NET Core 3.1 has reached End-of-Life. The oldest supported version is .NET 6, supported until 2024. MySQL 5.7 is old too, and Oracle's Connector/NET is full of problems in even the most basic things. More people use the truly open source [MySqlConnector](https://www.nuget.org/packages/MySqlConnector/) package than Oracle's buggy driver – Panagiotis Kanavos Jan 25 '23 at 16:59
  • You need to provide some code and sample connection strings as @Panagoitis pointed out. Try to hard code your connection string instead of adding that to `web.config` to avoid any other dependencies. The other reason would be you are missing some configuration in Azure website settings, check out [this[(https://stackoverflow.com/questions/45591130/deploying-to-azure-cannot-connect-to-database). – Talkhak1313 Jan 25 '23 at 18:05
  • Thanks for your suggestions. And I am sorry for not providing libraries and connection string. I added it now. – Jems Chaudhary Jan 25 '23 at 18:57
  • What's the error? – Panagiotis Kanavos Jan 25 '23 at 19:00
  • It was cause of incomplete networking. I had to allow other azure services to connect that server. Thanks for your suggestions. – Jems Chaudhary Jan 26 '23 at 14:06
  • And error was 404! – Jems Chaudhary Jan 26 '23 at 15:17
  • @JemsChaudhary If the above issue resolved with stated approach, post it as an answer so that it will help other community members. – Naveen Sharma Feb 02 '23 at 06:48

1 Answers1

0

Solution: It was unable to connect because of incomplete networking.

I had to allow other azure services to connect that server.

Thanks for your comments.