Azure Web Apps - 如何在部署前运行脚本 [英] Azure Web Apps - how to run script before deployment

查看:11
本文介绍了Azure Web Apps - 如何在部署前运行脚本的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试使用 Azure Web Apps (Linux) 来托管一个基本的静态站点.我配置了所有内容,因此每次 Git 推送都会发生新的部署.我将预先构建的页面放在我的仓库中,以确认此设置一切正常.

现在我已经删除了预构建的页面,只保留了模板和构建脚本(基本上只是一个 npm install 和一个必须的编译"),我想在我的网络应用程序中运行此构建脚本.我搜索了互联网,但找不到任何东西.

如何在第一次部署时和每次由 Git 推送触发的部署后运行脚本?

解决方案

如何在第一次部署时和每次由 Git 推送触发的部署后运行脚本?

首先,您需要使用

有关详细信息,请参阅这篇博文.

I'm trying to use Azure Web Apps (Linux) to host a basic static site. I configured everything so a new deployment happens with every Git push. I put my pre-built pages in my repo to confirm everything works fine with this setup.

Now I've removed the pre-built pages and kept only the templates and the build script (which is basically just an npm install and a mustatic 'compile') and I'd like to run this build script in my web app. I've scoured the internet but can't find anything.

How can I run a script upon first deployment and after each Git-push-triggered deployment?

解决方案

How can I run a script upon first deployment and after each Git-push-triggered deployment?

First, you need to generate custom deployment script by using azure-cli tool.

1) Set the cli working mode to asm.

azure config mode asm

2) Run the custom deployment script generator command.

azure site deploymentscript --node -t bash

This will generate the files required to deploy your site.

  • .deployment - Contains the command to run for deploying your site.
  • deploy.sh - Contains the deployment script.

Now you can edit the deploy.cmd file and add your custom steps.

After that done, add the generated files to your repository (.deployment and deploy.sh) and push your repository to your Azure Web App and see your custom deployment running.

For more details, please refer to this blog post.

这篇关于Azure Web Apps - 如何在部署前运行脚本的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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