简体   繁体   English

如何将NodeJs应用程序从Bitbucket部署到Azure

[英]How to deploy nodeJs app from Bitbucket to Azure

Bitbucket has from some time ago availability of Pipelines and I've been strugling, not from the Bitbucket part, but the Azure part as I can't find an easy way to deploy. Bitbucket从很早以前就可以使用管道,而我一直在苦苦挣扎,不是从Bitbucket部分开始,而是从Azure部分开始,因为我找不到一种简单的部署方法。

in my BitBucket, I have a bitbucket-pipelines.yml with 在我的BitBucket中,我有一个bitbucket-pipelines.yml

image: node:8.9.4

pipelines:
  default:
    - step:
        name: Build and test
        caches:
          - node
        script: # install packages and run tests
          - npm install
          - npm test
    - step:
        name: Deploy to Azure
        script:
          - git push https://$AZURE_LOGIN:$AZURE_PASSWORD@$AZURE_APP_NAME.scm.azurewebsites.net/$AZURE_APP_NAME.git master

and all works well from BB part, issue is that the code sent to Azure, from that command line is the application source, and I can't find an easy way to tell Azure to run npm install and I end up with Internal Server Error where a package was not found when I try to run the website after being deployed ... 一切都从BB部分正常运行,问题是从该命令行发送到Azure的代码是应用程序源,而我找不到一种简单的方法来告诉Azure运行npm install并且最终导致内部服务器错误当我尝试在部署后运行网站时找不到软件包...

I've then created a VSTS account to configure Continuous Delivery in both parts... the option CD in Azure portal as well create a pipeline in VSTS... 然后,我创建了一个VSTS帐户,以在两个部分中配置连续交付 ... Azure门户中的选件CD以及在VSTS中创建管道...


(through Azure portal directly) (直接通过Azure门户)


(manually from VSTS) (从VSTS手动获得)


My question is simple... in order to avoid anything from Azure portal (seems to complicate at the moment, or it's just me as I'm more used to work with AWS and Heroku), is there a way to actually deploy from BitBucket automagically? 我的问题很简单...为了避免Azure门户带来任何麻烦(目前似乎很复杂,或者只是我,因为我更习惯使用AWS和Heroku),有没有一种方法可以从BitBucket实际部署自动地?

How to deploy nodeJs app from Bitbucket to Azure 如何将NodeJs应用程序从Bitbucket部署到Azure

A simple solution is to use Continuous Deployment, this link has details on how to set up, basically 一个简单的解决方案是使用持续部署,该链接详细介绍了如何设置

  1. you choose where your repository lives: 您选择存储库所在的位置: 在此处输入图片说明
  2. every time you update your source repo, the change will get pushed to Azure 每次更新源存储库时,更改将推送到Azure
  3. Azure will then build the new website, which in your case (node environment), npm install will run automatically 然后,Azure将构建新网站,在您的情况下(节点环境),新网站将自动运行npm install

I am not sure if you need VSTS, since I imagine that your workflow is something like this (based on my assumption of how CI works) 我不确定您是否需要VSTS,因为我认为您的工作流程是这样的(基于我对CI的工作原理的假设)

  1. create pull request, which triggers your bit-bucket pipeline 创建拉取请求,触发您的位桶管道
  2. once build and tests are all successful, you merge your commit 一旦构建和测试全部成功,就可以合并提交
  3. with continuous deployment, Azure will get noticed and update your website 通过持续的部署,Azure将受到关注并更新您的网站

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

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM