dotnet-docs-samples icon indicating copy to clipboard operation
dotnet-docs-samples copied to clipboard

Cloud-SQL: Failure to start container when deplying on gcloud

Open faad021 opened this issue 3 years ago • 1 comments

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;
        }
    }

faad021 avatar Oct 22 '21 15:10 faad021

Fyi @kurtisvg and @jsimonweb

amanda-tarafa avatar Oct 23 '21 11:10 amanda-tarafa

The C# code sample referenced in this issue was updated, tested and confirmed to successfully deploy to Cloud Run since this issue was created.

jsimonweb avatar Oct 11 '22 13:10 jsimonweb