So I have a .NET Core 3.1 Web Api app (running in App Service) that connects to a MySQL database on a hosted server (no root access) using the connection string
The app itself works running locally, allows me to select, insert, and update fine using
Pomelo.EntityFrameworkCore.MySql, however after publishing fails with:
System.InvalidOperationException: An exception has been raised that is likely due to a transient failure. Consider enabling transient error resiliency by adding 'EnableRetryOnFailure()' to the 'UseMySql' call. ---> MySql.Data.MySqlClient.MySqlException (0x80004005): Connect Timeout expired. ---> MySql.Data.MySqlClient.MySqlException (0x80004005): Unable to connect to any of the specified MySQL hosts.
EnableRetryOnFailure() simply results in a longer duration before I get the same error message. So I check the connection string and it turns out the syntax is slightly off, so changed it to
Server=example.co.uk; Port=3306; Database=db_name; Uid=db_user; Pwd=supersecretpassword, but no change, and it fails with the exact same error.
The connection string, username, and password are correct, as I can access the database from my home PC (outside of hosted server). The only issues I can imagine that would exist are;
The MySql instance is running on a hosted server, where I have to enter a whitelist of addresses that can access the databases. I have allowed azure.com and azurewebsites.net, so I'm not sure if that would cover all bases.
I'm missing something pretty fundamental with how Azure App Services need to be set up.
Anyone have any ideas regarding this?
User contributions licensed under CC BY-SA 3.0