【问题标题】:Configuration of ASP.NET Core 1.0 web Kestrel application on Azure在 Azure 上配置 ASP.NET Core 1.0 Web Kestrel 应用程序
【发布时间】:2016-08-01 18:26:37
【问题描述】:

我正在尝试通过 git 在 Azure 上部署 aspnetcore 应用程序。如https://docs.asp.net/en/latest/tutorials/your-first-mac-aspnet.html所示,我已经直接完成了所有操作

后来我什至遵循Problems with deploy ASP.NET 5 (ASP.NET Core) app to Azure 中定义的步骤,并从https://github.com/bigfont/WebNotWar 部署了普通项目 在这两种情况下,我得到的一切都只是一条消息

您无权查看此目录或页面..

当我尝试访问任何控制器时,响应是

您要查找的资源已被删除,有它的名字 已更改,或暂时不可用。

我很确定部署本身没有问题,因为我尝试破解代码并且它反应正确。

【问题讨论】:

  • WebNotWar 的部署是一个 RC1 应用程序。您使用的是哪个版本的 ASP.NET Core?您可以通过 project.json 文件进行检查。
  • 我使用 > 1.0.0-preview2-003121 但我认为没关系,因为我尝试部署 WebNotWar 并且它也不起作用。
  • 可能很重要,因为在 RC1 之后 Azure 与 AspNetCore 集成的方式发生了变化。
  • 所以,基本上 Azure 已经改变了集成。那么为什么您的 WebNotWar 仍在工作而我的部署(代码和配置没有任何更改)失败了?我使用 git 部署,这就是为什么我说我的运行时版本并不重要,但我可能是错的。

标签: c# asp.net azure kestrel-http-server .net-core


【解决方案1】:

Azure App Service no longer supports pre-RTM ASP.NET Core

...Azure 应用服务不再支持 ASP.NET 5、Core RC1 或 RC2。 唯一受支持的 ASP.NET Core 堆栈是 Azure 应用服务上的 RTM。(已添加重点)。

现有的 RC1 应用程序目前可以继续工作。如果我们在 Azure 放弃支持之前将 ASP.NET Core RC1 应用程序部署到 Azure 应用程序服务,那么该应用程序将继续工作,它的持续性也将如此部署。

ASP.NET Core IIS integration has changed

对 web.config 的更改

The ASP.NET Core Module 已替换 HttpPlatformHandler。

<?xml version="1.0" encoding="utf-8"?>
<configuration>
  <system.webServer>

    // Use the ASP.NET Core Module
    <handlers>
      <add name="aspNetCore" path="*" verb="*"
        modules="AspNetCoreModule" resourceType="Unspecified" />
    </handlers>
    <aspNetCore processPath="..\MySite.exe" arguments="" 
      stdoutLogEnabled="false" stdoutLogFile="..\logs\stdout" />

    // Remove the HTTP Platform Handler
    // <handlers>
    //   <add name="httpPlatformHandler" path="*" verb="*"
    //     modules="httpPlatformHandler" resourceType="Unspecified"/>
    // </handlers>
    // <httpPlatform processPath="%DNX_PATH%" arguments="%DNX_ARGS%"
    //   stdoutLogEnabled="false" startupTimeLimit="3600" />

  </system.webServer>
</configuration>

更改为Startup

public void Configure(IApplicationBuilder app)
{    
    // Remove call to app.UseIISPlatformHandler(); 
    // Remove call to app.UseForwardedHeaders(); 
    // Both are handled by UseIISIntegration in Main.
}

public static void Main(string[] args)
{
    var host = new WebHostBuilder()
        .UseKestrel()
        .UseIISIntegration() // Replace UseIISPlatformHandlerUrl()
        .UseStartup<Startup>()
        .Build();

    host.Run();
}

【讨论】:

  • 好的,所以我现在有点困惑。我很确定我的应用程序正在使用 RTM,但它仍然无法正常工作。感谢您的帮助,我需要深入研究。
  • 值得发布您的 web.config 文件 @rylek90。如果您愿意,我可以用一个在 Azure 中工作的 RTM 的最小示例来扩充我的答案。告诉我。
  • 那太好了,我的 web.config 与 WebNotWar 的完全相同。这是我的 project.json - ideone.com/Nk4lbK 我没有定义 global.json
  • 非常感谢,现在看来可以使用了!不过,它并不完美。这个 Kudu 工具似乎生成了不完全正确的部署脚本,它不复制 web.config 文件。我所做的是连接到 powershell 控制台并手动将 web.config 复制到 wwwroot 并且奇迹发生了。再次感谢您的帮助!
  • 谢谢,值得一试。目前,我刚刚编辑了 Kadu 的 deploy.cmd。
猜你喜欢
  • 1970-01-01
  • 1970-01-01
  • 2018-03-02
  • 2019-08-10
  • 2011-05-21
  • 1970-01-01
  • 2023-04-08
  • 2016-10-03
相关资源
最近更新 更多