将ASP.NET核心JavaScript服务部署到Azure故障节点

时间:2017-09-08 23:31:02

标签: azure asp.net-core asp.net-core-mvc-2.0

我安装了Visual Studio 2017 R3和ASP.NET Core 2.0版本。当我创建一个具有反应的新Web应用程序时,它在本地工作,当我部署到azure时没有问题(如预期的那样)。我想在混合中添加节点和为核心2.0编写的文章

https://docs.microsoft.com/en-us/aspnet/core/client-side/spa-services

表示:

注意:如果您要部署到Azure网站,则无需在此处执行任何操作 - 已在服务器环境中安装并提供Node.js

我按照文章中的步骤操作,了解如何添加nodeservices并在本地工作。我的步骤是:

https://blogs.msdn.microsoft.com/webdev/2017/02/14/building-single-page-applications-on-asp-net-core-with-javascriptservices/

添加services.AddNodeServices();   创建关于控制器和视图   放下myNodeModule.js

当我部署到Azure时,当我浏览到

时出现错误

http://webapplication220170908032616.azurewebsites.net/home/about

我添加了环境变量ASPNETCORE_ENVIRONMENT并将其设置为Production。我通过向另一个页面添加标记帮助器来验证它。

我看到的错误是:

处理您的请求时出错。 要求ID:0HL7N1AN8GM1N:00000002

我暂时没有使用Azure,所以有点生疏。

2 个答案:

答案 0 :(得分:0)

根据我的经验,当我没有在.csproj文件中指定正确的运行时标识符时,Azure for .NET Core的部署失败。

我在我的项目中使用以下内容并停止查看错误。

  <PropertyGroup>
    <RuntimeIdentifiers>win7-x64</RuntimeIdentifiers>
  </PropertyGroup>

答案 1 :(得分:0)

我有这个问题,我发现这是因为默认安装的Node版本是v4.8.2(Ubuntu 16.04的当前发行版本)。我运行以下脚本来安装Node 8.x:

cd ~
apt-get update && apt-get install -y gnupg
curl -sL https://deb.nodesource.com/setup_8.x -o nodesource_setup.sh
# You might want to inspect nodesource_setup.sh before blindly running it
# vi nodesource_setup.sh
bash nodesource_setup.sh
apt-get install -y nodejs

(归功于DigitalOcean:https://www.digitalocean.com/community/tutorials/how-to-install-node-js-on-ubuntu-16-04

现在我的nodejs是v8.11.2,我的dotnet核心应用程序可以运行NodeServices。

相关问题