DEV Community

Cover image for Deno on Azure - Azure Pipelines, Azure Container Registry and Azure Web App for Containers
jishnu koottala
jishnu koottala

Posted on

Deno on Azure - Azure Pipelines, Azure Container Registry and Azure Web App for Containers

In this post I am going to deploy a simple REST API written on Deno to Azure Web app for Containers and use Azure container registry to hold the container, and use Azure Pipelines to enable CI/CD.

Prerequisites

  • Docker
  • Azure Account
  • Azure DevOps Account

Download the repository

  • You can clone the repo from here
  • Create a new repository in either Azure Devops or Github

Create resources

  • Go to Azure Portal
  • Create a Web App for Container

Create a web app

  • Create an Azure Container Registry (ACR)

Azure Container registry

Create Build Pipeline

  • Go to your Azure DevOps Account, go to Releases section, click on new pipeline

Image of Release Pipeline

  • In the connect section, click on classic editor

Select Classic Editor

  • Select a source and Project, Repository and Branch, in my case I have the code uploaded in a new repository in Azure Devops, you can choose anyone of your choice.

Select Source

  • Select Template, click on empty Job

select template

  • In next, step click on add Task (+) icon

click add task

  • Search for docker build, and click on Docker

Select Docker

  • Now give it a name Build an image, and click on + New Button

build image

  • upon, new service connection, select Azure Container Registry, and fill in your subscription and other details, it will automatically populate your ACR created in portal.

Service Connection

Build id

  • Now, create a Task again to push the image, select Docker give the name Push an Image,

Container Registry Type = Azure Container Registry

select subscription, it will populate your ACR,

Action = Push an image

Image name = ur-image-name:tag

Alt Text

Pipeline Running

Thats, it , the build, pipeline configuration is done, now you can click on Run Pipeline

The next process is to create a release pipeline,

  • Go to the release section you will find it in the pipelines menu of Azure Devops on the left side
  • Click on Create Pipeline

New Release

  • Upon click, a modal asks to select a template, from a list, you need to select Azure App Service deployment.

Alt Text

  • Give an appropriate stage name, means (production, development, testing, etc..)
  • Link your Azure Subscription
  • App Type = Web App for Containers (Linux)
  • App Service name = select your webapp service appname you have already created in azure portal
  • Registry = name of Azure container registry (fully qualified)
  • Repository - you can find it from the previous build pipeline step
  • startup command = leave blank

Alt Text

Inorder to enable continous deployment, add an artifact as well
Alt Text

Hurrayyyy!! Thats,it now click on Create a Release, now the pipeline will run, get your image from your ACR and Deploy it in Azure Web App for Container

Accessing API through Public URL

  • go to your app service in Azur eportal - go to overview section, click on the URL, which will open in a new tab

Alt Text

Testing your API in postman

Open postman, click on create a new request,
enter your URL and corresponding api route and click on Send

Alt Text

Troubleshooting

In case you have any DockerAPIException like follows

error message

You need to give access to your Azure App Service for Container,
just go to the Azure Container Registry, go to IAM (left side),
Click on add a role assignment, select contributor role and select your App Service.

Go to Azure Container Registry, enable Admin Access
Goto IAM Control, add a contributor role to App Service( if app service is not reflecting, go to your app service and go to identity section on the left, and click on system assigned - change status to On)

Restart your App Service, changes will take few minutes to propogate.

Top comments (0)