如何从 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 ServicesAzure 上部署该网站.该网站由静态文件组成,不涉及 ASP.NET 或其他任何内容.

在 Visual Studio Team Services 中,我创建了一个执行 npm install 和一个 gulp 构建的构建.这会生成一个 dist 文件夹,其中包含网站的所有文件.在 Azure 中,一切都已正确设置(订阅、Web 应用程序……).

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

我该怎么做?

这个问题与

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.

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,...).

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.

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.

解决方案

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.

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天全站免登陆