如何从Visual Studio Team Services将静态网站部署到Azure [英] How to deploy a static website to Azure from Visual Studio Team Services

本文介绍了如何从Visual Studio Team Services将静态网站部署到Azure的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个要使用 Visual Studio Team Services 部署在 Azure 上的现有网站.该网站由静态文件组成,不涉及ASP.NET或其他任何内容.

I have an existing website that I would like to deploy on Azure, using Visual Studio Team Services. The website is made up of static files, there's no ASP.NET or anything else involved.

在Visual Studio Team Services中,我创建了一个执行npm installgulp生成的生成.这将导致dist文件夹包含网站的所有文件.在Azure中,所有设置均正确设置(订阅,Web应用程序...).

Within Visual Studio Team Services, I created a build which executes npm install and a gulp build. This results in a dist folder containing all the files for the website. In Azure, everything is set up correctly (subscription, web app,...).

但是,我不确定如何将代码推送到Azure.浏览VSTS中发行"选项卡中的选项,似乎总是需要工件",但是我只有一堆文件.我需要将文件发布到dist文件夹中,并确保提供index.html.

However, I'm unsure on how to push my code to 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. I need to publish the files in the dist folder and make sure index.html is served.

我该怎么办?

此问题与但是,所有答案都表示要从Azure开始,而没有提及如何使用Visual Studio Team Services部署现有代码.

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.

推荐答案

诀窍是自己创建工件,就像创建包含静态网站文件的 zip文件一样简单.压缩文件应作为工件复制到$(build.artifactstagingdirectory)目标目录中.接下来,您可以使用简单的 Web App部署任务将zip文件发布到Azure.如果index.html在根目录中,则Azure足够聪明地可以为其提供服务.

The trick is to create the artifact yourself, which can be as simple as a zip file containing the static website files. The zip file should be copied as an artifact to the $(build.artifactstagingdirectory) target directory. Next, you can use a simple Web App deployment task to publish the zip file to Azure. If index.html is in the root directory, Azure is smart enough to serve it.

以下是有效的构建和部署流程.假定gulp用于构建网站并将构建输出(即静态文件)写入dist文件夹.

Below is a working build and deploy flow. It assumes gulp is used to build the website and write the build output (i.e. the static files) to a dist folder.

这篇关于如何从Visual Studio Team Services将静态网站部署到Azure的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆