[英]How to deploy a static website to Azure from Visual Studio Team Services
I have an existing website that I would like to deploy on Azure , using Visual Studio Team Services . 我有一个现有的网站,我想使用Visual Studio Team Services在Azure上部署。 The website is made up of static files, there's no ASP.NET or anything else involved.
该网站由静态文件组成,没有ASP.NET或其他任何涉及的内容。
Within Visual Studio Team Services, I created a build which executes npm install
and a gulp
build. 在Visual Studio Team Services中,我创建了一个执行
npm install
和gulp
构建的构建。 This results in a dist
folder containing all the files for the website. 这导致
dist
文件夹包含网站的所有文件。 In Azure, everything is set up correctly (subscription, web app,...). 在Azure中,一切都设置正确(订阅,Web应用程序,...)。
However, I'm unsure on how to push my code to Azure. 但是,我不确定如何将我的代码推送到Azure。 Exploring the options in the Release tab in VSTS, an 'artifact' always seems to be required, but I just have a bunch of files.
探索VSTS的Release选项卡中的选项,似乎总是需要'工件',但我只有一堆文件。 I need to publish the files in the
dist
folder and make sure index.html
is served. 我需要在
dist
文件夹中发布文件,并确保提供index.html
。
How can I do that? 我怎样才能做到这一点?
This question is related to this one, however, the answers all state to start from Azure, and do not mention how to deploy existing code using Visual Studio Team Services. 这个问题是有关这一之一,然而,答案全部状态,从Azure的开始,并没有提及如何使用Visual Studio团队服务部署现有的代码。
The trick is to create the artifact yourself, which can be as simple as a zip file containing the static website files. 诀窍是自己创建工件,这可以像包含静态网站文件的zip文件一样简单。 The zip file should be copied as an artifact to the $(build.artifactstagingdirectory) target directory.
应将zip文件作为工件复制到$(build.artifactstagingdirectory)目标目录。 Next, you can use a simple Web App deployment task to publish the zip file to Azure.
接下来,您可以使用简单的Web App部署任务将zip文件发布到Azure。 If
index.html
is in the root directory, Azure is smart enough to serve it. 如果
index.html
位于根目录中,则Azure足够智能,可以为其提供服务。
Below is a working build and deploy flow. 下面是一个有效的构建和部署流程。 It assumes
gulp
is used to build the website and write the build output (ie the static files) to a dist folder. 它假定
gulp
用于构建网站并将构建输出(即静态文件)写入dist文件夹。
The easiest way is to deploy from a source control, if you take a look under "Settings" for your Website in the Azure portal you will probably see "Continuous deployment" . 最简单的方法是从源控件进行部署,如果您在Azure门户中查看网站的“设置”,您可能会看到“持续部署” 。
From there you can deploy from Visual Studio Team Services, Github, etc. 从那里,您可以从Visual Studio Team Services,Github等部署。
Every check-in will be deployed, also wrong ones, so you may want a introduce a staging environment as a deployment slot as well, where you can swap staging with production whenever you feel your site is ready for production. 每次签入都会被部署,也会出现错误,因此您可能需要将临时环境作为部署插槽引入,只要您认为您的站点已准备好进行生产,就可以将分段与生产交换。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.