I am trying to connect to Azure's MySQL Database (preview) from an Azure function I am creating. However, when I try opening the connection I get an error saying Authentication failed because the remote party has closed the transport stream.
My Function code looks like this:
#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}");
}
Troubleshooting the error, this is what I have tried so far:
- Copied the connection string and tried it with MySQL Workbench and it worked fine
- Added the IP Address of my function's application to MySQL allowed IP List.
None of these method worked for me.
I would be glad if someone can point me in the right direction since most of the guides out there is meant for SQL Server and not MySQL with C#.
Thank you

Server={your_servername}; Port=3306; Database={your_database}; Uid={your_username}; Pwd={your_password}; SslMode=Preferred;