Azure Web App - HTTP Error 502.3 - Code 0x80072f78

0

The Azure Web generates an HTTP Error 502.3 - Code 0x80072f7, the specified CGI application encountered an error and the server terminated the process.

  • Regular ASP.NET Core code
  • Use of Dependency Injection inside the code
  • no error during the build on an Azure Pipeline
  • 2 pages displaying basic .cshtml text work
  • 2 pages calling External web services generate the HTTP Error 502.3

The WebApp works perfectly on my local machine when running the command dotnet run


502 - Web server received an invalid response while acting as a gateway or proxy server.

There is a problem with the page you are looking for, and it cannot be displayed. When the Web server (while acting as a gateway or proxy) contacted the upstream content server, it received an invalid response from the content server.


HTTP Error 502.3 - Code 0x80072f78

WebApp Azure Configuration > General settings

Startup.cs

public void ConfigureServices(IServiceCollection services)
    {
        services.AddApplicationInsightsTelemetry();

        services.AddDbContext<Context>(opt =>
            opt.UseInMemoryDatabase("ConfigurationList"));
        services.Configure<CookiePolicyOptions>(options =>
        {
            options.CheckConsentNeeded = context => true;
            options.MinimumSameSitePolicy = SameSiteMode.None;
        });
        services.AddMvc().SetCompatibilityVersion(CompatibilityVersion.Version_2_1);

        services.AddSwaggerGen(c =>
        {
            c.SwaggerDoc("v1", new Info
            {
                Title = "Gateway API",
                Version = "v1",
                Description = "CRUD",
                TermsOfService = "None",
                Contact = new Contact
                {
                    Name = ",
                    Email = "@alt-f1.be",
                    Url = "https://twitter.com/abdelkrim"
                },
                License = new License
                {
                    Name = "(c) Copyright 2019, all rights reserved.",
                    Url = "http://www.alt-f1.be"
                }
            });
            var xmlFile = $"{Assembly.GetExecutingAssembly().GetName().Name}.xml";
            var xmlPath = Path.Combine(AppContext.BaseDirectory, xmlFile);
            c.IncludeXmlComments(xmlPath);
        });

        services.AddSingleton<IAPI, API>();
        services.AddSingleton<IAPIMandate, APIMandate>();
        services.AddSingleton<IApiRules, ApiRules>();
        services.AddSingleton<IApiTransactions, ApiTransactions>();
        Console.WriteLine("scoped api");
    }

Program.cs

 public class Program
{
    public static void Main(string[] args)
    {
        CreateWebHostBuilder(args).Build().Run();
    }

    public static IWebHostBuilder CreateWebHostBuilder(string[] args) =>
        WebHost.CreateDefaultBuilder(args)
            .UseStartup<Startup>();
}
azure-web-app-service
asked on Stack Overflow Jun 3, 2019 by Abdelkrim

1 Answer

0

Some environment variables were missing and a little piece of code was executed that crashed the WebApp.

if (Environment.GetEnvironmentVariable("a-token") == null)
  {
  ...
  Environment.Exit(-1);
  }

that was the reason logs where unavailable

answered on Stack Overflow Jun 4, 2019 by Abdelkrim • edited Jun 9, 2019 by Abdelkrim

User contributions licensed under CC BY-SA 3.0