我在ASP.NET 5(CoreCLR)上有一个应用程序,我尝试将其发布到Microsoft Azure。我使用免费的Web App(不是VDS)

我正在使用Visual Studio 2015 Publish->Microsoft Azurethis instructions发布应用程序。

但是,当我发布并尝试打开它时,我只会看到不停地加载空白页面。我启用了日志记录并从Azure查看日志(stdout.log),只有:

'"dnx.exe"' is not recognized as an internal or external command,

可操作的程序或批处理文件。

我也尝试用git做Continiusly publishing。在插入过程中,它开始还原软件包,并失败,错误no disk space available

有什么方法可以将ASP.NET 5应用发布到Azure Web应用吗?

最佳答案

简短答案



当我们的应用无法通过应用发布发布运行时(dnx.exe)时,就会发生这种情况。

讨论

有几种方法可以将ASP.NET Core rc1应用发布到Azure Web应用。其中包括使用Git进行连续部署以及使用Visual Studio进行发布。发布您存储库的内容以获取特定帮助。

该示例是一个通过GitHub连续部署将ASP.NET Core rc1应用程序部署到Azure Web应用程序的示例。这些是至关重要的文件。

app/
    wwwroot/
        web.config
    project.json
    startup.cs
.deployment           <-- optional: if your app is not in the repo root
global.json           <-- optional: if you need dnxcore50 support

应用程序/wwwroot/web.config

添加HttpPlatformHandler。配置它以将所有请求转发到DNX进程。换句话说,告诉Azure Web应用程序使用DNX。
<?xml version="1.0" encoding="utf-8"?>
<configuration>
  <system.webServer>
    <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>

app/project.json

包括对Kestrel服务器的依赖性。设置一个web命令,它将启动Kestrel。使用dnx451作为目标框架。参见下文,了解针对dnxCore50的其他工作。
{
  "dependencies": {
    "Microsoft.AspNet.Server.Kestrel": "1.0.0-rc1-final"
  },

  "commands": {
    "web": "Microsoft.AspNet.Server.Kestrel"
  },

  "frameworks": {
    "dnx451": { }
  }
}

应用程序/Startup.cs

包括Configure方法。这增加了一个非常简单的响应处理程序。
using Microsoft.AspNet.Builder;
using Microsoft.AspNet.Http;

namespace WebNotWar
{
    public class Startup
    {
        public void Configure(IApplicationBuilder app)
        {
            app.Run(async (context) =>
            {
                await context.Response.WriteAsync(
                    "Hello from a minimal ASP.NET Core rc1 Web App.");
            });
        }
    }
}

.deployment (可选)

如果您的应用程序不在存储库根目录中,请告诉Azure Web App哪个目录包含该应用程序。
[config]
project =  app/

global.json (可选)

如果要定位.NET Core,请告诉Azure我们要定位它。添加此文件之后,我们可以用dnx451替换(或补充) project.json 中的dnxCore50条目。
{
  "sdk": {
    "version": "1.0.0-rc1-update1",
    "runtime": "coreclr",
    "architecture": "x64"
  }
}

关于c# - 将ASP.NET 5(ASP.NET Core)应用程序部署到Azure的问题,我们在Stack Overflow上找到一个类似的问题:https://stackoverflow.com/questions/35516206/

10-12 00:04
查看更多