我的网络应用无法在Azure中运行 - 错误0x00000000

时间:2016-09-22 01:22:34

标签: azure iis deployment asp.net-core

我正在尝试在Azure http://iberodev.azurewebsites.net

中部署应用程序

该应用程序使用Identity,IdentityServer4,Entity Framework Core等。 它有一些npm和bower依赖项,它使用gulp从SASS等生成CSS。 非常标准的网络应用程序。

本地的一切运作良好 发布到Azure时我没有收到任何错误,我可以看到所有的dll和wwwroot组件都在那里。

当我访问该应用程序时,它显示一个空白页面。但我可以看到应用程序正在运行(它返回favicon.ico,它到达中间件管道)。

我在Azure中启用了一些日志记录,我可以看到,每当我向应用程序发送请求时,都会导致 500内部服务器错误。但它没有提供太多细节:

printscreen of error

错误是0x00000000

有关如何更好地解决此问题或可能是什么的任何想法?我的想法用完了。

这是我在Azure中的web.config

<?xml version="1.0" encoding="utf-8"?>
<configuration>
  <!--
  <system.webServer>
    <handlers>
      <add name="aspNetCore" path="*" verb="*" modules="AspNetCoreModule" resourceType="Unspecified" />
    </handlers>
    <aspNetCore processPath="dotnet" arguments=".\Iberodev.Web.dll" stdoutLogEnabled="false" stdoutLogFile="\\?\%home%\LogFiles\stdout" forwardWindowsAuthToken="false" />
    <rewrite>
      <rules>
        <!-- BEGIN rule TAG FOR HTTPS REDIRECT -->
        <rule name="Force HTTPS" enabled="true">
          <match url="(.*)" ignoreCase="false" />
          <conditions>
            <add input="{HTTPS}" pattern="off" />
          </conditions>
          <action type="Redirect" url="https://{HTTP_HOST}/{R:1}" appendQueryString="true" redirectType="Permanent" />
        </rule>
        <!-- END rule TAG FOR HTTPS REDIRECT -->
      </rules>
    </rewrite>
  </system.webServer>
</configuration>

我的project.json也很简单:

{
  "dependencies": {
    "Microsoft.NETCore.App": {
      "version": "1.0.1",
      "type": "platform"
    },
    "Iberodev.Common": "1.0.0",
    "Iberodev.Data": "1.0.0",
    "Iberodev.Data.SqlServer": "1.0.0",
    "Iberodev.Web.Model": "1.0.0",
    "Microsoft.AspNetCore.Authentication.Cookies": "1.0.0",
    "Microsoft.AspNetCore.Authentication.OpenIdConnect": "1.0.0",
    "Microsoft.AspNetCore.Diagnostics": "1.0.0",
    "Microsoft.AspNetCore.Mvc": "1.0.*",
    "Microsoft.AspNetCore.Server.IISIntegration": "1.0.0",
    "Microsoft.AspNetCore.Server.Kestrel": "1.0.1",
    "Microsoft.AspNetCore.StaticFiles": "1.0.0",
    "Microsoft.EntityFrameworkCore.Design": "1.0.0-preview2-final",
    "Microsoft.EntityFrameworkCore.Tools": "1.0.0-preview2-final",
    "Microsoft.Extensions.Configuration.EnvironmentVariables": "1.0.0",
    "Microsoft.Extensions.Configuration.FileExtensions": "1.0.0",
    "Microsoft.Extensions.Configuration.Json": "1.0.0",
    "Microsoft.Extensions.Logging.Console": "1.0.0"
  },

  "tools": {
    "BundlerMinifier.Core": "2.0.238",
    "Microsoft.AspNetCore.Server.IISIntegration.Tools": "1.0.0-preview2-final",
    "Microsoft.EntityFrameworkCore.Tools": "1.0.0-preview2-final"
  },

  "frameworks": {
    "netcoreapp1.0": {
      "imports": [
        "dotnet5.6",
        "portable-net45+win8"
      ]
    }
  },

  "buildOptions": {
    "emitEntryPoint": true,
    "preserveCompilationContext": true
  },

  "runtimeOptions": {
    "configProperties": {
      "System.GC.Server": true
    }
  },

  "publishOptions": {
    "include": [
      "wwwroot",
      "web.config"
    ]
  },

  "scripts": {
    "prepublish": [
      "npm install",
      "bower install",
      "dotnet bundle",
      "gulp clean",
      "gulp compile"
    ],
    "postpublish": [ "dotnet publish-iis --publish-folder %publish:OutputPath% --framework %publish:FullTargetFramework%" ]
  },
  "version": "1.0.0"
}

这是我的初创班     公共课启动     {         私人只读IHostingEnvironment _env;         public IConfigurationRoot Configuration {get;私人集; }

    public Startup(IHostingEnvironment env)
    {
        _env = env;
        var builder = new ConfigurationBuilder()
            .SetBasePath(env.ContentRootPath)
            .AddJsonFile(Constants.IberodevisSettings.SETTINGS_FILE_FULLNAME, optional: true, reloadOnChange: true)
            .AddJsonFile($"{Constants.IberodevisSettings.SETTINGS_FILE_NAME}.{env.EnvironmentName}.{Constants.IberodevisSettings.SETTINGS_FILE_EXTENSION}", optional: true)
            .AddEnvironmentVariables();
        Configuration = builder.Build();
    }

    public void ConfigureServices(IServiceCollection services)
    {
        var connectionString = Configuration.GetConnectionString("DefaultConnection");
        var migrationsAssembly = typeof(Startup).GetTypeInfo().Assembly.GetName().Name;

        // AspNet Core Identity
        services.AddIdentity<User, Role>(config => {
            config.User.RequireUniqueEmail = Constants.IdentityValues.REQUIRE_UNIQUE_EMAIL;
            config.Password.RequiredLength = Constants.IdentityValues.PASSWORD_MIN_LENGTH;
            config.Password.RequireDigit = Constants.IdentityValues.REQUIRE_DIGIT;
            config.Password.RequireUppercase = Constants.IdentityValues.REQUIRE_UPPERCASE;
            config.Password.RequireNonAlphanumeric = Constants.IdentityValues.REQUIRE_NON_ALPHANUMERIC;
        })
            .AddEntityFrameworkStores<IberodevContext, Guid>()
            .AddDefaultTokenProviders()
            .AddUserStore<UserStore<User, Role, IberodevContext, Guid>>();

        //Add EF services
        services.AddDbContext<IberodevContext>(options =>
        {
            options.UseSqlServer(connectionString,
                sqlServerOptions => sqlServerOptions.MigrationsAssembly(migrationsAssembly));
        });

        // Identity Server 4.
        services.AddIdentityServer()
        .AddInMemoryStores()
        .AddInMemoryClients(ConfigInMemory.GetClients("http://localhost:8080"))
        .AddInMemoryScopes(ConfigInMemory.GetScopes())
        .AddAspNetIdentity<User>();

        // AspNet Core MVC
        services.AddMvc();

        BootstrapServices(services);
        BootstrapRepositories(services);
    }

    private void BootstrapServices(IServiceCollection services)
    {
        services.AddScoped<IUserService, UserService>();
    }

    private void BootstrapRepositories(IServiceCollection services)
    {
        services.AddScoped<IUserRepository, UserRepository>();
    }


    public void Configure(IApplicationBuilder app, IHostingEnvironment env, ILoggerFactory loggerFactory)
    {
        var logLevel = env.IsDevelopment() ? LogLevel.Debug : LogLevel.Information;
        loggerFactory.AddConsole(logLevel);

        if (env.IsDevelopment())
        {
            app.UseDeveloperExceptionPage();
        }

        //ASP.NET Core Identity (adds cookie authentication)
        app.UseIdentity();
        app.UseIdentityServer(); // it relies on the authentication cookie Identity creates, so it must be after.
        app.UseStaticFiles();
        app.UseMvcWithDefaultRoute();
    }
}

1 个答案:

答案 0 :(得分:0)

我设法通过让Azure应用程序相信它处于开发环境中以便显示开发错误来查找更多详细信息。 我在“应用程序设置”中添加了此键值对: ASPNETCORE_ENVIRONMENT Development

我设法看到视图索引丢失,因为我没有在发布选项中添加视图:

  "publishOptions": {
    "include": [
      "wwwroot",
      "**/*.cshtml",
      "appsettings.json",
      "web.config"
    ]
  },