将Angular 2应用程序部署到Azure

问题描述:

我正在学习Angular 2和Azure.我遵循了 Angular 2教程,并且在本地一切正常.

I am learning Angular 2 and Azure. I followed along the Angular 2 Tutorial and everything worked fine locally.

我将应用程序发布到Azure .发布成功.但是,当我访问该站点时,它停留在加载阶段.在Chrome控制台中查看日志时,看到以下错误.找不到/app/main.ts文件.

I published the app to Azure. The publication was successfully. But when I visit the site it stuck at the loading stage. Looking at logs in the Chrome console I see the following error. The /app/main.ts file is not found.

我按照

I checked my deployed files via the "Kudu" dashboard as suggested by this question. I dont see any *.ts are deployed only the *.js and *.map.

然后我回到Visual Studio,将所有*.ts文件的属性更改为Copy Always.更改之后,我可以看到*.ts文件已复制到.\bin\app目录.但是,在将项目重新发布到Azure之后(再次成功),在请求main.ts文件时,仍然出现404错误.

Then I went back to Visual Studio changed the property of all *.ts file to Copy Always. After the change, I can see that the *.ts files are copied to the .\bin\app directory. However, after I republished the project to Azure (successfully again), I still ended up with the 404 error when requesting the main.ts file.

根据此问题 IIS不提供Typescript文件正确地.

According to the this question IIS does not serve Typescript file correctly.

首先:如何在Azure上应用建议的更改以对其进行修复?

Firstly: How to apply suggested change on Azure to fix it?

第二:为什么我们需要使用*.ts文件?根据我的理解,*.ts被编译为*.js.为什么我们不能只请求正确部署到Azure的*.js文件?

Secondly: why do we need to use the *.ts files? Based on my understanding, the *.ts is complied into *.js. Why can't we just request the *.js files which are correctly deployed to Azure ?

@Frank,

使用.ts文件仅用于演示和教程,实际上建议使用.js文件运行您的网站.

use .ts file is just for demo and tutorial, it is actually suggested to run your site with .js file.

我有一个示例应用程序正在运行,您也许可以参考一下以了解其工作原理.

i have a sample app running which you might be able to reference a bit to see how it work.

https://github.com/shrimpy/AspMVCFileUploadSample

  • Asp.net Core 1.0.0-rc1
  • Angularjs 2

希望这会有所帮助.