因此,我有一个.NET Core 3.1 Web Api应用程序(在App Service中运行),该应用程序使用连接字符串server=example.co.uk;port=3306;database=db_name;user=db_user;password=supersecretpassword
连接到托管服务器上的MySQL数据库(无root访问权限)。
该应用程序本身可以在本地运行,允许我使用Pomelo.EntityFrameworkCore.MySql
进行选择,插入和更新,但是发布失败后会出现以下情况:
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()
只会导致更长的时间,直到我得到相同的错误消息。所以我检查了连接字符串,结果发现语法略有改变,因此将其更改为
Server=example.co.uk; Port=3306; Database=db_name; Uid=db_user; Pwd=supersecretpassword
,但没有任何更改,并且由于完全相同的错误而失败。
连接字符串,用户名和密码正确,因为我可以从家用PC(托管服务器之外)访问数据库。我能想象的唯一的问题是;
MySql实例在托管服务器上运行,我必须在其中输入可以访问数据库的地址白名单。我已经允许azure.com和azurewebsites.net,所以我不确定这是否涵盖所有基础。
我缺少有关如何设置Azure App Services的一些基本知识。
有人对此有任何想法吗?