Microsoft Azure For Spoiled People 2: Deploy your App using Azure Pipelines
Tags: javascript, beginners, vue, devops
Published: 2019-05-29 14:22:04

---
title: Microsoft Azure For Spoiled People 2: Deploy your App using Azure Pipelines
cover_image: https://media.giphy.com/media/Gf1hwiVNLnPVe/giphy.gif
published: true
description: In the second part of this series, we will learn how to make a cleaner build and release system for your Vue.js app on Azure.
tags: javascript, beginners, vue, devops
series: Azure-For-Spoiled-People 
---

There's something in my [last post](https://dev.to/jenlooper/microsoft-azure-for-spoiled-people-5bgh) that doesn't sit quite right either with me, or with folks used to deploying Vue.js apps to other services. That's the idea that you should upload your built assets to a server, after which time they are picked up and moved to prod.

A much better way is to use built-in systems that will pick up changes to your code from GitHub, build them according to the scripts in your `package.json` file, and deploy them seamlessly so that your web site is refreshed without needing to mess with your `.gitignore` file.

With [Azure Pipelines](https://azure.microsoft.com/services/devops/pipelines/?nav=min&WT.mc_id=devto-blog-jelooper), you can! Pipelines offer a way to automate your build and release processes with customizable steps.

![Azure Pipelines](https://thepracticaldev.s3.amazonaws.com/i/vheb8x1uvfsbyhoewdo8.png)

Here's how I edited the very basic Vue.js app that I managed to deploy according to my last post. 

## Get ready for your first pipeline

In preparation for this work, you can undo some of the weird things I had you do earlier. 

First, remove `/dist` from your `.gitignore` file so it will stop being sent to GitHub. That's icky. Commit those changes.

![nope](https://media.giphy.com/media/6h4z4b3v6XWxO/giphy.gif)

Next, create a new file in your codebase root called `azure-pipelines.yml`. In that file, add this code:

```
trigger:
- master

pool:
  vmImage: 'ubuntu-latest'

steps:
- task: NodeTool@0
  inputs:
    versionSpec: '10.x'
  displayName: 'Install Node.js'

- script: |
    npm install
    npm run build
  displayName: 'npm install and build'

- task: PublishBuildArtifacts@1
  inputs:
    artifactName: dist
    pathtoPublish: 'dist'
``` 

You'll find that this is a standard YAML file used by most node apps that make use of Azure Pipelines. It's delineating the steps to build an 'artifact', or a group of publishable files, and then actually publishing them. Commit that to your GitHub repo.

## Get set up to Build on Azure DevOps

Not many frontend developers are comfortable doing DevOps. It's scarier than Oracle Stored Procedures to many of us! You can seriously MESS THINGS UP mucking around with this stuff. Fortunately, Azure DevOps offers a somewhat straightforward way of getting your head around the tasks that those crazy DevOps people do all the time.

So go ahead and create an account for yourself on [Azure DevOps](https://azure.microsoft.com/services/devops/?nav=min&WT.mc_id=devto-blog-jelooper). You can get quite a lot done on the free tier: check out the [pricing page](https://azure.microsoft.com/pricing/details/devops/azure-devops-services/?nav=min&WT.mc_id=devto-blog-jelooper) for more information. 

![Azure DevOps](https://thepracticaldev.s3.amazonaws.com/i/c02a3bgjxeq55qg8wexr.png)

Once you're signed in, create a new project. In that project, you'll see several options. Azure DevOps has an area for project management, and under that, you'll find the pipelines area.

1. Create a new pipeline and connect it to your GitHub code that you set up for your Vue project.

2. The pipeline wizard will find your project's .yml file that you created earlier. Give it a quick check to make sure it looks right.

3. Click 'run' - and watch your build start up! You can watch the processes start in realtime. The important steps to monitor is the `npm install and build` process. A `dist` folder should be created and published.

If all goes well, you'll get an email saying your build succeeded and it will show 'green' in the Build panel:

![built!](https://thepracticaldev.s3.amazonaws.com/i/fet1l1ts93m7wqcn9czf.png)

Great! Your site has been built in the cloud! ⛅️ You can verify that everything is good by visiting the build logs and clicking the blue `Artifacts` button: it shows that a `dist` folder was built.

## Last step: Release!

You might think you're all done, but you'd be wrong. There's one more thing to do, and that is to release the assets you just built. Here's how.

1. On the left nav, click 'Releases' and create a new Release pipeline. 

2. You're presented with a LOT of options on different types of releases. Choose the first one, to build a web app from App Services.

![release step 1](https://thepracticaldev.s3.amazonaws.com/i/mme7595eiw75mhbc2i1r.png)

Then, click on the 'Add an Artifact' button to add the artifacts that your previous process built:

![release step 2](https://thepracticaldev.s3.amazonaws.com/i/i8t51kcdu6hccqp2bdum.png)

Next, go to the Stages area and click the Stage button. You need to do some important edits here. Click into the Tasks tab in this area and change the Release parameters to include your Azure subscription and App service name. **Click Save!**

![release step 3](https://thepracticaldev.s3.amazonaws.com/i/vf1uplqtyry03o1owfxb.png)

Then, click the Deploy Azure App Service button on this page. There are some important tweaks to make here. Go to the Package or folder textbox and click the small button on the right to specify which folder to release. You need to specify `dist`:

![release step 4](https://thepracticaldev.s3.amazonaws.com/i/mok4bdlp18d1r0dxkb4w.png)

**Make sure to click Save to save your Release preferences. Click 'Create release' to test your pipeline.**

Test your work by returning to the Build area and clicking 'Queue' to queue up a build and release.

> If your GitHub change triggers a build, but not a release, make sure that the little 'lightning' icon is clicked on the release, to ensure continuous integration:

> ![lightning arrow](https://thepracticaldev.s3.amazonaws.com/i/ddv24zoh1j6yr3n4km25.png)

The pipeline should also be triggered when changes are made to the code. Test that, too, by committing a change to GitHub.

Azure pipelines are tiring. I need a nap. But now that our builds are succeeding and we have true continuous deployments without chicanery, we can rest a little until the next post in this series, when we'll add a database to our app!

![nap time](https://media.giphy.com/media/ViUqU2JgM4eaY/giphy.gif)

> Useful Links:
> 🛠[Azure Pipelines](https://azure.microsoft.com/services/devops/pipelines/?nav=min&WT.mc_id=devto-blog-jelooper)
> 👛[Pipeline pricing details](https://azure.microsoft.com/pricing/details/devops/azure-devops-services/?nav=min&WT.mc_id=devto-blog-jelooper)
> 📚[Pipeline documentation](https://docs.microsoft.com/en-us/azure/devops/pipelines/?view=azure-devops&WT.mc_id=devto-blog-jelooper)