Asp.net Core Failed to determine the https port for redirect

Viewed 1188

I wrote an Asp web application in .net Core 5.0 for google cloud. The applicatin delpoyed as CloudRun using the following command

gcloud run deploy cdm-viewer-wacore --image gcr.io/mot-cz-test/mot-cdm-viewer-wacore:v48 --platform managed --vpc-connector mot-test-connector --region=europe-west1 --project=project1 --set-env-vars=ProjectId=project1

The application works properly in project1, but when deploying to the same image in another project (project2), the application gives an error message

Failed to determine the https port for redirect.

It is quite clear that there is a difference in the settings / properties of cloudrun between the projects. What differences can cause this error?

1 Answers

It would be needed to set permissions to Cloud Run to pull container images from other projects.

For Artifacty Registry:

  • members:

        serviceAccount:service-@serverless-robot-prod.iam.gserviceaccount.com 
    
        role: roles/artifactregistry.reader
    

For Container Registry:

  • members:

         serviceAccount:service-@serverless-robot-prod.iam.gserviceaccount.com 
    
         role: roles/storage.objectViewer
    

Also make sure that you have “app.UseHttpsRedirection();” in your configuration of Startup.cs .

If you see “Failed to determine the https port for redirect” in the container output, add this to your ConfigureServices(): services.AddHttpsRedirection(opt => opt.HttpsPort = 443);

Refer the links for Https Redirection and for deploying a Cloud Run Service using an image from another project.

Related