Skip to main content

Command Palette

Search for a command to run...

Deploy a Docker App to App Services on Azure.

Published
3 min read
Deploy a Docker App to App Services on Azure.
K

I have experience building highly accessible, scalable, and reliable cloud infrastructure and have experience with AWS, Linux, Git, Docker, and Kubernetes. S3, EC2, CloudFormation, CloudFront, Auto-Scaling Group, Elastic Load Balancer, IAM, Cloud9, VPC, RDS, Route53, and other AWS services are just a few of the ones I am familiar with. I have experience building CI/CD pipelines, high-availability web apps, and websites. I'm excited about designing, implementing, and automating cloud-based apps while utilizing best practices like configuration management, continuous integration, and deployment.

This article is a walkthrough on how to "dockerize" a node js app and host via Azure app service.

Azure app service is a fully managed service that enables you to build and host web apps, mobile backends, and RESTful APIs in the programming language of your choice without managing infrastructure. This is a Platform as a Service (PAAS) because the job of managing infrastructure is not on the user.

This walkthrough is divided into 2 parts:

  • Creating a Docker image (with a Node app) and pushing it to a registry (Azure Container Registry).

  • Hosting the image via Azure app service.

The following tools are needed:

  • An Azure account with an active subscription.

  • Docker and a terminal.

Part 1: Dockerize a Node js app and push to Azure Container Registry

  • Login to your Azure account and navigate to container registries to create a container registry (this is where our docker image will be stored) by clicking on create container registry.

ACR

  • Complete the necessary details before clicking create (a summary of mine).

Summary of ACR

  • Progress of ACR being initialized and on the way to getting created and finally successful creation.

Initialize ACR

ACR in Progress

ACR completed

  • Navigating to my Container Registry dashboard.

ACR dashboard

  • On the LHS, navigate to Settings => Access keys and enable admin user, the details will be used to login to ACR via your terminal on your local machine.

Enable admin user

  • Navigate to your project directory via the terminal and login using the details from the step above docker login <login server> --username <username> --password <password>

Establish a connection with ACR

  • Build docker image using this command docker build -t <name>:<tag> . where . is the current directory.

Build docker image

  • Check the image exists using docker images command ( this lists all available images).

List docker image(s)

  • Push the image to ACR using docker push <name>:<tag>

Pushing image to ACR

  • On Azure portal, navigate to your container registry => repositories to view pushed image.

View Image on Repositories

Part 2: Hosting my docker app on app service

  • On the image click the options icon and choose deploy to the web app.

Deploy to web app

  • Details for my app service where my docker image is the source, then click create.

App service details

  • Deployment is completed.

    App service deployment

  • Navigate to just created app service.

App service

  • Following Azure's best practices.

Add port to configurations

  • Adding port as a variable to Configurations

Add port 4000

  • Access the app via the default domain on the browser

Default domain

To avoid incurring charges, I cleaned up my resources.

Visit my Github repo to view the code.

More from this blog

Untitled Publication

21 posts