DEV Community

Cover image for Node.js + AKS on Azure DevOps
Emily Freeman for Microsoft Azure

Posted on

Node.js + AKS on Azure DevOps

We've selected our favorite tips and tricks created by Michael Crump and are delivering fresh technical content on Azure all April! Miss a day (or more)? Catch up with the series.

Don't have Azure? Grab a free subscription.


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? And AKS?! 😅

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 and see how powerful it is.

Azure Kubernetes Service (AKS) manages your hosted Kubernetes 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.

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

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

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 (telemetry for your live site).

links

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

Taking A Peek At The Code 🔍

In the CI/CD pipeline, click on the commit to see the code. You can also click on Master to take you to the full file list.

code

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

deployed app

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

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

You now see the steps created for building a container image and a Helm 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

Clicking on either of the Docker tasks will show you the new Azure Container Registry (ACR) that the DevOps project created, along with the image name, plus the build number.

docker artifact

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 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

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


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”


Enter fullscreen mode Exit fullscreen mode

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...}


Enter fullscreen mode Exit fullscreen mode

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

edit release button

Then click the Edit tasks link.

edit

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

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

Live App

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

external endpoint

AKS

The second link is to the Azure Kubernetes Service.

AKS

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

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

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

Want more? Don't wait. Continue learning about Azure DevOps.


We'll be posting articles every day in April, so stay tuned! Or jump ahead and check out more tips and tricks now.

Top comments (3)

Collapse
 
alexandrusimandi profile image
Alexandru Simandi

This looks a lot simpler than when we had started with AKS on a project without DevOps. We had a lot of networking problems between the nodes and once, the whole cluster died. Not very satisfied even with the performance, compared to Amazon EKS, pods take 3x the time to reach live probe status.

Collapse
 
prakashbm21 profile image
Prakash Nimmala

Can you suggest while taking from Dev stage to Prod stage(higher environments) what are the changes need to expected? how to reach from Dev to Prod ?

Some comments may only be visible to logged-in visitors. Sign in to view all comments.