简体   繁体   English

如何从Visual Studio Team Services将静态网站部署到Azure

[英]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 ServicesAzure上部署。 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 installgulp构建的构建。 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. 每次签入都会被部署,也会出现错误,因此您可能需要将临时环境作为部署插槽引入,只要您认为您的站点已准备好进行生产,就可以将分段与生产交换。

Without the need to create an artifact, another solution could be FTP deployment after creating an Service Endpoint in VSTS 无需创建工件,在VSTS中创建服务端点后,另一种解决方案可能是FTP部署

在此输入图像描述

在此输入图像描述

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 Azure:使用Visual Studio Team Services从源代码管理部署 - Azure: Deploy from source control using Visual Studio Team Services 从Visual Studio Team Services将Gulp构建文件夹部署到Azure - Deploy the Gulp Build Folder To Azure from Visual Studio Team Services 从Visual Studio Team Services(VSO)部署Azure WebApp - Deploy Azure WebApp from Visual Studio Team Services (VSO) Node.js Azure WebJob:如何通过持续交付从Visual Studio Team Services进行部署 - Node.js Azure WebJob: How to deploy from Visual Studio Team Services with Continuous Delivery 如何使用Visual Code Studio在Azure上部署静态网站? - How to deploy a static website on azure using Visual Code studio? Visual Studio Team Services代码未与Azure网站同步 - git - Visual Studio Team Services code not syncing with Azure website - git Visual Studio团队服务/ Azure - Visual Studio Team Services / Azure 从Visual Studio Team Services发布到Azure Web角色 - Publishing from Visual Studio Team Services to Azure Web Role 从Visual Studio Team Services创建Azure DevTest Lab VM - Create Azure DevTest Lab VM from Visual Studio Team Services 从Visual Studio Team Services到Azure App Service的连续部署 - Continuous deployment from Visual Studio Team Services to Azure App Service
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM