Node.js + AKS on Azure DevOps
Tags: azureapril, kubernetes, node, devops
Published: 2019-04-03 00:35:05

---
title: Node.js + AKS on Azure DevOps
published: true
description: 
tags: azureapril, kubernetes, node, devops
series: Azure April
cover_image: https://thepracticaldev.s3.amazonaws.com/i/pblyvmtj4y8bdqisyzey.jpeg
---

*We've selected our favorite tips and tricks created by [Michael Crump](https://twitter.com/mbcrump) and are delivering fresh technical content on Azure all April! Miss a day (or more)? [Catch up with the series](https://dev.to/t/azureapril).*

**Don't have Azure?** [Grab a free subscription](https://azure.microsoft.com/en-us/free?&WT.mc_id=azureapril_devto-blog-cxa).  

----

I want to give you a quick tour around Azure DevOps and Azure Kubernetes Service(AKS) using Node.js. 

We'll walk through creating an AKS cluster using an Azure DevOps and take a look under the hood to help understand how to get started with AKS.

> The Azure Portal and Azure DevOps is always evolving and improving! If a screenshot doesn't match exactly what you're seeing, that's why. I believe the explanations are enough to help you find your way. If you run into issues, comment below and we can figure it out together! 

# What The Heck Is [Azure DevOps](https://azure.microsoft.com/en-us/services/devops/?WT.mc_id=azureapril_devto-blog-cxa)? And [AKS](https://docs.microsoft.com/en-us/azure/aks/intro-kubernetes?WT.mc_id=azureapril_devto-blog-cxa)?! 😅

Azure DevOps is a cloud service (formally called VSTS) for collaborating on code development. It essentially powers the entire software delivery lifecycle for engineering teams. You can create processes for you and your team around:

* Source control
* CD/CD
* Agile tooling
* Testing
* Builds
* Releases

You can think of Azure DevOps as a more verbose cousin to Jenkins or CircleCI. 

> **Don't wait!** [Check out Azure DevOps](https://azure.microsoft.com/en-us/services/devops/?WT.mc_id=azureapril_devto-blog-cxa) and see how powerful it is.  

Azure Kubernetes Service (AKS) manages your hosted [Kubernetes](https://docs.microsoft.com/en-us/azure/aks/intro-kubernetes?WT.mc_id=azureapril_devto-blog-cxa) environment, making it quick and easy to deploy and manage containerized applications without container orchestration expertise. It also eliminates the burden of ongoing operations and maintenance by provisioning, upgrading, and scaling resources on demand, without taking your applications offline.

> Kubernetes is **HOT**. [We've got you covered on everything you need to know](https://docs.microsoft.com/en-us/azure/aks/intro-kubernetes?WT.mc_id=azureapril_devto-blog-cxa). 

# Create Your DevOps Project 👩🏾‍💻

> A common pitfall in this tutorial is creating the project before your organization has been created in Azure. If you run into any errors, ensure your organization was created in Azure. 

1. Open the [Azure portal](https://azure.microsoft.com/en-us/features/azure-portal/?WT.mc_id=azureapril_devto-blog-cxa).
2. Search for "DevOps" and choose `DevOps Project`.
3. Click the `Add` button.
4. Select the Node.js application, click it and then the `Next` button.
5. Select `Express.js` for the application framework and click `Next`.
6. For deploying the application, select `Kubernetes Service` and click `Next`. 
7. Now just give the DevOps project an organization name and a project name. You can make this anything you want. 

Provide a subscription and a cluster name and click the `Done` button.

**Boom!** You did it. Seriously. It's *that* easy. 

![project name](https://microsoft.github.io/AzureTipsAndTricks/files/devops-k8s1.gif)

A lot of amazing work is happening in the background, so now is the time to drink a cup of coffee or read another post (or drink some wine...) before clicking the refresh button on your DevOps Projects list.

![refresh](https://microsoft.github.io/AzureTipsAndTricks/files/devops-k8s2.png)

Click on your DevOps project name in the list to go to the DevOps project dashboard. This has everything you need to access the source code repository and the application build and release pipelines. These pipelines automate the steps needed to take your committed code, integrate it, build it and deploy it to a live Kubernetes environment. 

There are also links to your live deployed application, the Kubernetes cluster and [Application Insights](https://docs.microsoft.com/en-us/azure/azure-monitor/app/app-insights-overview?WT.mc_id=azureapril_devto-blog-cxa) (telemetry for your live site).

![links](https://microsoft.github.io/AzureTipsAndTricks/files/devops-k8s3.png)

You should also have received an email from Azure DevOps or an alert in the portal letting you know the project is ready. If you'd like, set up team members in your project. 

![email](https://microsoft.github.io/AzureTipsAndTricks/files/devops-k8s20.png)

# Taking A Peek At The Code 🔍

In the [CI/CD pipeline](https://azure.microsoft.com/en-us/services/devops/pipelines/), click on the commit to see the code. You can also click on `Master` to take you to the full file list.

![code](https://microsoft.github.io/AzureTipsAndTricks/files/devops-k8s4.png)

This takes you to the commit for the repo we just released containing the deployed sample app.

![deployed app](https://microsoft.github.io/AzureTipsAndTricks/files/devops-k8s5.png)

When you created the DevOps project, it cloned the source code from the `devops-project-samples` GitHub project and added it your DevOps projects and did a lot of the initial plumbing for you. *How cool is that?*

# Taking A Look At The Build 🤓

Back on the DevOps Project dashboard, click the `Build` link that has the successful build number.

![build number](https://microsoft.github.io/AzureTipsAndTricks/files/devops-k8s6.png)

This takes you to the new Azure DevOps Pipelines build that was created for the project. Now click the `Edit` button at the top.

![edit button](https://microsoft.github.io/AzureTipsAndTricks/files/devops-k8s7.png)

You now see the steps created for building a container image and a [Helm](https://docs.microsoft.com/en-us/azure/aks/kubernetes-helm?WT.mc_id=azureapril_devto-blog-cxa) package. Helm is used to deploy applications to Kubernetes and is the default in DevOps projects that target Kubernetes.

> Microsoft is solving really hard problems to make your life easier. 

![helm](https://microsoft.github.io/AzureTipsAndTricks/files/devops-k8s8.png)

Clicking on either of the Docker tasks will show you the new [Azure Container Registry (ACR)](https://azure.microsoft.com/en-us/services/container-registry/?WT.mc_id=azureapril_devto-blog-cxa) that the DevOps project created, along with the image name, plus the build number.

![docker artifact](https://microsoft.github.io/AzureTipsAndTricks/files/devops-k8s9.png)

The build creates an ACR as well as builds and pushes the image using Docker. It automatically checks if Helm is properly installed and begins packaging and deploying the `charts/sampleapp` directory. It also creates the [ARM templates](https://docs.microsoft.com/en-us/azure/azure-resource-manager/resource-manager-quickstart-create-templates-use-the-portal?WT.mc_id=azureapril_devto-blog-cxa) and finally publishes the build artifact.

If you switch back over to `Repos`, then `Files`, then `Applications`, you can see the `charts/sampleapp` folder.

![repos](https://microsoft.github.io/AzureTipsAndTricks/files/devops-k8s10.png)

We'll finish up the pipeline section by looking at `dev` and reviewing the `resources` section. 

# Finishing Up Your Pipelines 🔧

Back on the DevOps Project dashboard, click the `Release` link with the number. 

![successful build](https://microsoft.github.io/AzureTipsAndTricks/files/devops-k8s11.png)

---
> Be sure the build you select is GREEN. It signifies a successful build without errors. 

>If the build is RED, click on it and find the error. A common error you might encounter is `The subscription is not registered to use namespace 'Microsoft.ContainerService'` 

> One way to quickly resolve that is by bringing up Cloud Shell, selecting PowerShell and running the following command:

> While this is designed for PowerShell, if you're an avid Bash user, will you comment below with the command you used?

```
PS Azure:\> Register-AzureRmResourceProvider -ProviderNamespace “Microsoft.ContainerService”
```

You'll receive an output similar to below. 

```
ProviderNamespace : Microsoft.ContainerService
RegistrationState : Registering
ResourceTypes     : {containerServices, managedClusters, locations, locations/operationresults...}
Locations         : {Japan East, Central US, East US 2, Japan West...}
```
---

If all goes well, you'll see the basic Azure DevOps release pipeline. Click the `Edit` release button at the top.

![edit release button](https://microsoft.github.io/AzureTipsAndTricks/files/devops-k8s12.png)

Then click the `Edit` tasks link.

![edit](https://microsoft.github.io/AzureTipsAndTricks/files/devops-k8s13.png)

You now see the list of tasks that need to be run such as Creating the AKS cluster, running a PowerShell script and packaging and deploying Helm charts.

![AKS cluster](https://microsoft.github.io/AzureTipsAndTricks/files/devops-k8s14.png)

# Azure Resources In A Nutshell 🥜

Back in the DevOps Project dashboard, let’s look at the Azure resources and Application Insights. The resources are the URL to your live site running in Kubernetes and a link to the AKS cluster. The last link will take you to see the live telemetry for your site provided by Application Insights. 

> Telemetry is just a fancy way of saying this is how you monitor the health of your app. 

![application insights](https://microsoft.github.io/AzureTipsAndTricks/files/devops-k8s15.png)

### Live App 

Click on the `External Endpoint` link to be taken to the deployed application.

![external endpoint](https://microsoft.github.io/AzureTipsAndTricks/files/devops-k8s16.png)

### AKS

The second link is to the Azure Kubernetes Service.

![AKS](https://microsoft.github.io/AzureTipsAndTricks/files/devops-k8s17.png)

### Application Insights

The last link shows the Application Insights created for the service which includes powerful analytics tools to help you diagnose issues and to understand what users actually do with your app. It's designed to help you continuously improve performance and usability and works seamlessly with Azure DevOps

![application insights](https://microsoft.github.io/AzureTipsAndTricks/files/devops-k8s18.png)

Now if you go to `Resource Groups` on the Azure portal and search for the name of the DevOps project, you’ll see that three resource groups were created.

![resource groups](https://microsoft.github.io/AzureTipsAndTricks/files/devops-k8s19.png)

> Remember! Avoid any costs related to this tutorial by deleting the resources created.

**Want more?** Don't wait. [Continue learning about Azure DevOps](https://azure.microsoft.com/en-us/services/devops/?WT.mc_id=azureapril_devto-blog-cxa). 


----
We'll be posting articles every day in April, so stay tuned! Or jump ahead and check out more tips and tricks [now](http://azuredev.tips?WT.mc_id=azureapril_devto-blog-cxa).