dotnet-docs-samples
dotnet-docs-samples copied to clipboard
Cloud-SQL: Failure to start container when deplying on gcloud
I am trying to try out this tutorial with cloud sql but I am getting error during deployment with the following message.
Cloud Run error: Container failed to start. Failed to start and then listen on the port defined by the
PORT environment variable. Logs for this revision might contain more information.
X Creating Revision... Cloud Run error: Container failed to start. Failed to start and then listen on the port defin
Logs
Here is the Program.cs file and the application already listens on the port. I do not know why I am getting this error
static class ProgramExtensions
{
// Google Cloud Run sets the PORT environment variable to tell this
// process which port to listen to.
public static IWebHostBuilder UsePortEnvironmentVariable(
this IWebHostBuilder builder)
{
var port = Environment.GetEnvironmentVariable("PORT");
var urls = string.IsNullOrWhiteSpace(port)
? "http://0.0.0.0:80;http://0.0.0.0:8080"
: $"http://0.0.0.0:{port}";
builder.UseUrls(urls);
return builder;
}
}
Fyi @kurtisvg and @jsimonweb
The C# code sample referenced in this issue was updated, tested and confirmed to successfully deploy to Cloud Run since this issue was created.