Azure Web应用程序-HTTP错误502.3-代码0x80072f78

时间:2019-06-03 12:44:38

标签: azure-web-sites azure-web-app-service

Azure Web生成HTTP错误502.3-代码0x80072f7,指定的CGI应用程序遇到错误,服务器终止了该过程。

  • 常规ASP.NET Core代码
  • 在代码内部使用依赖注入
  • 在Azure管道上构建期间
  • 没有错误
  • 2个显示基本.cshtml文本作品的页面
  • 2个调用外部Web服务的页面会生成HTTP错误502.3

运行命令dotnet run

时,WebApp可以在我的本地计算机上完美运行
  

502-Web服务器在充当服务器时收到无效响应   网关或代理服务器。

     

您所在的页面有问题   寻找,并且无法显示。当Web服务器(同时   充当网关或代理)联系了上游内容服务器,   它收到了来自内容服务器的无效响应。


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

1 个答案:

答案 0 :(得分:0)

缺少一些环境变量,并且执行了一些代码,使WebApp崩溃了。

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

这是日志不可用的原因