'Could not find Host of Azure In App SQL Database

I've created a MySQL In App database for my Azure App, and got the connection string for it. This string is injected into the application.json, and then used to create the actual connection:

WebApplicationBuilder builder = // get it somewhere
var connectionString = builder.Configuration.GetConnectionString("DefaultConnection")
builder.Services.AddDbContext<DatabaseContext>(options => options.UseMySQL(connectionString));

Only... no connection string works. The one with the port (Database=localdb;Data Source=127.0.0.1:53844;User Id=azure;Password=password) throws:

System.Net.Sockets.SocketException (11001): No such host is known.

And the one without the port (Database=localdb;Data Source=127.0.0.1;User Id=azure;Password=password) throws:

System.Net.Sockets.SocketException (10013): An attempt was made to access a socket in a way forbidden by its access permissions.

This question sugested another connection string (Server=127.0.0.1; Port=53844; Database=localdb; Uid=azure; Pwd=password), which weirdly enough also throws this exception, even though the port is defined:

System.Net.Sockets.SocketException (10013): An attempt was made to access a socket in a way forbidden by its access permissions.

And the manual suggests yet another string (server=localhost;database=localdb;user=azure;password=password) which again throws one of the two exceptions depending on if the port is present.

Connecting via the browser works fine, so I can confirm port, username and password work normally.

Just to be sure, I tried "localhost" as the host, too. Same results.

What am I doing wrong?



Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source