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

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

问题描述

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

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)

我正在使用Visual Studio 2015 Publish->Microsoft Azure并遵循

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

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

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.

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

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

是否可以将ASP.NET 5应用发布到Azure Web应用?

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

推荐答案

简短回答

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

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

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

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

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

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.

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

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

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

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

包括对Kestrel服务器的依赖性.设置web命令以启动Kestrel.使用dnx451作为目标框架.参见下文,了解针对dnxCore50的其他工作.

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

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

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

.部署(可选)

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

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 (可选)

如果要定位.NET Core,请告诉Azure我们要定位它.添加此文件后,我们可以用dnxCore50替换(或补充) project.json 中的dnx451条目.

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天全站免登陆