将 ASP.NET 5 (ASP.NET Core) 应用程序部署到 Azure 的问题 [英] Problems with deploy ASP.NET 5 (ASP.NET Core) app to Azure

查看:32
本文介绍了将 ASP.NET 5 (ASP.NET Core) 应用程序部署到 Azure 的问题的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

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

我正在使用 Visual Studio 2015 Publish->Microsoft Azure 发布应用程序并遵循 此说明.

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

'"dnx.exe"' 未被识别为内部或外部命令,

可运行的程序或批处理文件.

我也尝试用 git 进行 Continiusly publishing.在推送期间,它开始恢复包并失败并出现错误 no disk space available.

有没有办法将 ASP.NET 5 应用发布到 Azure Web App?

解决方案

简答

<块引用>

但是当我发布它并尝试打开时,我看到的只是不停地加载空白页面.

当我们的应用无法将运行时 (dnx.exe) 与应用一起发布时,就会发生这种情况.

讨论

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

该示例是一个 ASP.NET Core rc1 应用程序,通过 GitHub 持续部署部署到 Azure Web 应用程序.这些是重要文件.

app/wwwroot/网络配置项目.json启动.cs.deployment <-- 可选:如果您的应用不在 repo 根目录中global.json <-- 可选:如果你需要 dnxcore50 支持

app/wwwroot/web.config

添加 HttpPlatformHandler.将其配置为将所有请求转发到 DNX 进程.换句话说,告诉 Azure Web 应用使用 DNX.

<?xml version="1.0" encoding="utf-8"?><配置><system.webServer><处理程序><添加名称="httpPlatformHandler"路径="*" 动词="*"模块="httpPlatformHandler"resourceType="未指定"/></处理程序>

app/project.json

包括对 Kestrel 服务器的依赖.设置将启动 Kestrel 的 web 命令.使用 dnx451 作为目标框架.有关针对 dnxCore50 的额外工作,请参见下文.

<代码>{依赖":{Microsoft.AspNet.Server.Kestrel":1.0.0-rc1-final"},命令":{网络":Microsoft.AspNet.Server.Kestrel"},构架": {dnx451":{}}}

app/Startup.cs

包括 Configure 方法.这个添加了一个非常简单的响应处理程序.

使用 Microsoft.AspNet.Builder;使用 Microsoft.AspNet.Http;命名空间 WebNotWar{公共类启动{公共无效配置(IApplicationBuilder 应用程序){app.Run(异步(上下文)=>{等待上下文.Response.WriteAsync(来自最小 ASP.NET Core rc1 Web 应用程序的问候.");});}}}

.deployment(可选)

如果您的应用不在存储库根目录中,请告诉 Azure Web 应用哪个目录包含该应用.

[配置]项目=应用程序/

global.json(可选)

如果您希望以 .NET Core 为目标,请告诉 Azure 我们希望以它为目标.添加此文件后,我们可以将 project.json 中的 dnx451 条目替换(或补充)为 dnxCore50.

<代码>{SDK":{版本":1.0.0-rc1-update1",运行时":coreclr",架构":x64"}}

I have an app on ASP.NET 5 (CoreCLR) and I try to publish it to the Microsoft Azure. I using free Web App (not VDS)

I am publishing app using Visual Studio 2015 Publish->Microsoft Azureand following this instructions.

But when I publish it and try to open, I see just non-stop loading of empty page. I enabling logging and view the log (stdout.log) from Azure and there was only:

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

operable program or batch file.

Also I tried to do Continiusly publishing with git. During push, It started restoring packages and failed with error no disk space available.

Is there any way to publish ASP.NET 5 app to the Azure Web App?

解决方案

Short Answer

But when I publish it and try to open, I see just non-stop loading of empty page.

This happens when our app fails to publish the runtime (dnx.exe) with the application.

Discussion

There are several ways to publish ASP.NET Core rc1 apps to an Azure Web App. These include continuous deployment with Git and publishing with Visual Studio. Post your repository's contents for specific help.

The example is an ASP.NET Core rc1 app, deployed to an Azure Web App, via GitHub continuous deployment. These are the vital files.

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

app/wwwroot/web.config

Add the HttpPlatformHandler. Configure it to forward all requests to a DNX process. In other words, tell the Azure Web app to use 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

Include a dependency on the Kestrel server. Set a web command that will startup Kestrel. Use dnx451 as the target framework. See below for the additional work to target dnxCore50.

{
  "dependencies": {
    "Microsoft.AspNet.Server.Kestrel": "1.0.0-rc1-final"
  },

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

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

app/Startup.cs

Include the Configure method. This one adds an extremely simple response handler.

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 (optional)

If your app is not in the repositories root directory, tell the Azure Web App which directory contains the app.

[config]
project =  app/

global.json (optional)

If you would like to target .NET Core, tell Azure that we want to target it. After adding this file, we can either replace (or complement) the dnx451 entry in our project.json with dnxCore50.

{
  "sdk": {
    "version": "1.0.0-rc1-update1",
    "runtime": "coreclr",
    "architecture": "x64"
  }
}

这篇关于将 ASP.NET 5 (ASP.NET Core) 应用程序部署到 Azure 的问题的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆