Unable to connect to MySQL in app from ASP.NET Core Blazor app deployed in Azure app service

Sathya Narayanan 1 Reputation point
2022-12-01T05:52:17.263+00:00

I have my ASP.NET Core Blazor app in Azure app service. This app uses a MySQL DB.

I am trying to use MySQL in app feature in Azure app service.

Below if the connection string in appsettings.json

"DefaultConnection": "Server=xxxxx.azurewebsites.net;Port=50016;Uid=myUserIdGotFromMySQL.INI;Pwd=myPwdGotFromMySQL.INI;Database=test1;SslMode=none;default command timeout=0;"

Below is the error when I open the web page that fetches data from DB:

MySqlException: Connect Timeout expired.
MySqlConnector.Core.ServerSession.OpenTcpSocketAsync(ConnectionSettings cs, ILoadBalancer loadBalancer, Activity activity, IOBehavior ioBehavior, CancellationToken cancellationToken) in ServerSession.cs, line 1129

Any help would be gratefully acknowledged.

TIA

Blazor
Blazor
A free and open-source web framework that enables developers to create web apps using C# and HTML being developed by Microsoft.
1,549 questions
Azure Database for MySQL
Azure Database for MySQL
An Azure managed MySQL database service for app development and deployment.
802 questions
Azure App Service
Azure App Service
Azure App Service is a service used to create and deploy scalable, mission-critical web apps.
7,630 questions
0 comments No comments
{count} votes

2 answers

Sort by: Most helpful
  1. Sathya Narayanan 1 Reputation point
    2022-12-01T08:21:54.603+00:00

    I switched off the 'HTTPS ON' option (in app service configuration) and also changed server to '127.0.0.1' in conn string. Now the app is able to connect to DB.

    Thanks


  2. KAMBOU OLLO DIDIER 0 Reputation points
    2023-09-13T09:13:23.4933333+00:00

    comment connecter MySQL et EF Core ?

    0 comments No comments

Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.