【问题标题】:Azure Web App - HTTP Error 502.3 - Code 0x80072f78Azure Web 应用程序 - HTTP 错误 502.3 - 代码 0x80072f78
【发布时间】:2019-06-03 12:44:38
【问题描述】:

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

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

运行命令dotnet run时,WebApp 在我的本地机器上完美运行


502 - Web 服务器在充当 网关或代理服务器。

你所在的页面有问题 正在寻找,无法显示。当 Web 服务器(而 作为网关或代理)联系上游内容服务器, 它收到了来自内容服务器的无效响应。


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

程序.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


    【解决方案1】:

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

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

    这就是日志不可用的原因

    【讨论】:

      猜你喜欢
      • 2017-11-22
      • 1970-01-01
      • 2018-04-09
      • 1970-01-01
      • 2015-11-26
      • 2017-09-11
      • 2017-11-07
      • 2016-07-14
      • 1970-01-01
      相关资源
      最近更新 更多