1
我想从我创建的Azure功能连接到Azure的MySQL数据库(预览)。但是,当我尝试打开连接时,出现错误消息Authentication failed because the remote party has closed the transport stream
。无法通过Azure功能连接到Azure MySQL数据库 - C#
我的功能代码如下所示:
#r "System.Data" <--- Uploaded System.Data.dll into the root folder
#r "MySql.Data" <--- Uploaded MySql.Data.dll (6.9) into root folder
using MySql.Data;
using MySql.Data.MySqlClient;
using System.Configuration;
public static void Run(TimerInfo myTimer, TraceWriter log)
{
var connStr = ConfigurationManager.ConnectionStrings["MySQL_Conn"].ConnectionString;
using(MySqlConnection conn = new MySqlConnection(connStr))
{
try{
conn.Open();
log.Info("Connection opened");
}catch(Exception ex){
log.Info("Error: " + ex.Message);
}
}
//log.Info($"C# Timer trigger function executed at: {DateTime.Now}");
}
排除错误,这是我到目前为止已经试过:
- 复制连接字符串,并与MySQL工作台尝试过了,它的工作很好
- 将我函数的应用程序的IP地址添加到MySQL允许的IP列表中。
这些方法都不适用于我。
我会很高兴,如果有人能指出我在正确的方向,因为大多数指南是用于SQL Server,而不是用C#MySQL。
谢谢
你会很高兴,如果你可以指向到SQL Server?我不明白。请重写。错误本身:添加您的连接字符串(不含密码)。检查你的mysql用户是否允许你在你的应用程序中从IP连接到你的应用程序。 –
我的问题是关于Azure MySQL和Azure功能。我在问题中说我的连接字符串工作正常。所以我希望有人协助解决这个问题,因为我似乎无法找到与MySQL的Azure函数相关的指南。这是我的连接字符串的样子:'Server = {your_servername};端口= 3306;数据库= {your_database}; UID = {your_username}; PWD = {your_password}; SslMode =首选;' – adjaharrison
鉴于您有本地验证的控制台应用程序。尝试在kudu控制台(https://github.com/projectkudu/kudu/wiki/Kudu-console)上运行相同的命令以隔离如果Azure WebApps或函数特定的排除规则。 –