I built this project as part of my CodeAlpha DevOps training. The goal was to take a small Node.js application, package it with Docker, create the Azure infrastructure with Terraform, and automate the deployment with Azure DevOps Pipelines.
This post is a record of how I approached the work, the commands I used, the decisions I made and the problems I had to solve along the way. I have included the points where I would place screenshots from my own setup so readers can follow the work and see what each stage looked like.
The project is based on an existing Node.js and Express application called DevOps Status Dashboard. It exposes two endpoints:
-
/healthreturns the health of the application. -
/api/statusreturns details about the running application, including its environment and version.
At the end of the work, the application was running on Azure App Service as a Linux custom container. Azure Pipelines built the Docker image, pushed it to Azure Container Registry (ACR), updated the Web App to use that image and checked the health endpoint.
Live application: https://app-codealpha-92njum.azurewebsites.net
Health endpoint: https://app-codealpha-92njum.azurewebsites.net/health
Application status: https://app-codealpha-92njum.azurewebsites.net/api/status
GitHub repository: https://github.com/highpee1991/CodeAlpha_ProjectName
The Azure resource names shown in this post are from my completed deployment. If you follow the guide in your own subscription, Terraform will create names based on your configuration and any generated suffix. Do not assume that your names will be identical to mine.
1. What I used
These were the main tools and services involved:
| Tool or service | What I used it for |
|---|---|
| Node.js and Express | The application |
| Docker | Building and running the application as a container |
| Azure CLI | Signing in and managing Azure resources |
| Terraform | Creating and managing the Azure infrastructure |
| Azure Storage | Keeping Terraform state remotely |
| Azure Container Registry | Storing the Docker image |
| Azure App Service | Running the container |
| Azure DevOps | Building and deploying the image through a pipeline |
| GitHub | Hosting the application source code |
| VS Code and Git Bash | My working environment |
I used Git Bash (UCRT64) in the VS Code terminal on Windows. The commands below are written for Bash. If you use PowerShell, some shell variable and line-continuation syntax will be different.
Before starting
You need:
- An Azure account with an active subscription.
- Azure CLI installed.
- Terraform installed.
- Docker Desktop installed and running.
- Git installed.
- A GitHub account.
- An Azure DevOps organization.
- Access to create the Azure resources and role assignments used in this project.
I used East US as the Azure region. The App Service Plan was Basic B1, and the Container Registry used the Basic SKU. Azure quotas and pricing can vary by subscription and region, so check your own subscription before creating resources.
2. I checked that the application worked locally first
Before writing a Dockerfile, I wanted to know that the application itself worked. There is little value in trying to debug Docker, Azure and the application at the same time.
From the application directory, I installed the dependencies:
npm install
Then I started the application:
npm start
I checked the application in a browser at:
http://localhost:3000
I also checked the endpoints:
curl http://localhost:3000/health
curl http://localhost:3000/api/status
The important things I confirmed in the application were:
- The application starts with
node server.js. - It listens on port
3000by default. - It binds to
0.0.0.0, not onlylocalhost. - The health and status endpoints respond.
The port and host settings matter when an application runs inside a container. A process listening only on 127.0.0.1 inside the container will not be reachable through the container's published port in the way we need.
My application uses the PORT environment variable when it is supplied and falls back to port 3000. The server needs to listen on 0.0.0.0.
Screenshot to add: 02-local-app-running.png
Capture the local application running in the browser, or the terminal showing npm start and a successful request to /health.
3. I created the Dockerfile
After confirming the application worked locally, I moved on to Docker.
I created a file named Dockerfile in the project root:
FROM node:20-alpine
WORKDIR /app
COPY package*.json ./
RUN npm ci --omit=dev
COPY . .
EXPOSE 3000
USER node
CMD ["node", "server.js"]
A few details are worth explaining.
-
node:20-alpinegives me a smaller Node.js base image. -
WORKDIR /appsets the working directory inside the container. - I copy the package files first and install production dependencies with
npm ci --omit=dev. - I then copy the application source.
-
EXPOSE 3000documents the port the application uses. -
USER noderuns the application as the non-root Node user provided by the image. -
CMD ["node", "server.js"]starts the application.
I used npm ci because the project has a lock file. It installs the dependency versions recorded in that lock file and is suitable for repeatable builds.
I also created a .dockerignore file
The .dockerignore file keeps unnecessary files out of the Docker build context. Mine included:
node_modules/
npm-debug.log
.git/
.gitignore
.env
Dockerfile
.dockerignore
README.md
terraform/
*.tfstate
*.tfstate.*
*.tfvars
*.tfplan
tfplan
The exact exclusions should match your project. Do not exclude files that the application needs at runtime. In particular, keep secrets out of the image and do not copy Terraform state or local environment files into it.
It is worth understanding the difference between .gitignore and .dockerignore:
-
.gitignorecontrols what Git ignores. -
.dockerignorecontrols what Docker sends as the build context.
They solve different problems, so I used both.
Screenshot to add: 03-dockerfile-and-dockerignore.png
Capture the Dockerfile and .dockerignore open in VS Code. Make sure the file contents are readable.
4. I built and tested the container locally
I built the image from the project root:
docker build -t devops-status-dashboard:1.0.0 .
The -t option gives the image a name and tag. The final dot tells Docker to use the current directory as the build context.
I checked that the image had been created:
docker images
Then I started a container:
docker run -d \
-p 3000:3000 \
--name devops-dashboard-test \
-e APP_ENV=development \
-e APP_VERSION=1.0.0 \
devops-status-dashboard:1.0.0
The options mean:
-
-druns the container in the background. -
-p 3000:3000maps port 3000 on my computer to port 3000 in the container. -
--namegives the container a name that is easier to use in later commands. -
-esupplies environment variables to the application.
I checked the running container:
docker ps
I tested the endpoints from my computer:
curl http://localhost:3000/health
curl http://localhost:3000/api/status
If a container is not listed by docker ps, check stopped containers as well:
docker ps -a
To see why a container stopped, check its logs:
docker logs devops-dashboard-test
Other useful commands are:
docker stop devops-dashboard-test
docker rm devops-dashboard-test
docker images
A Dockerfile mistake I had to correct
My first Docker build used the wrong application entry point. I had set the Dockerfile to start index.js, but the actual file was server.js.
The container did not stay running. I checked:
docker ps -a
docker logs devops-dashboard-test
The logs showed a Node.js MODULE_NOT_FOUND error for /app/index.js. That told me the problem was not the Azure environment or the port. Docker was starting Node with a file that did not exist.
I corrected the command to:
CMD ["node", "server.js"]
Then I rebuilt the image and replaced the old container. Editing a Dockerfile does not change an image that has already been built, so rebuilding was necessary.
5. I prepared Azure and checked the subscription
Before creating Azure resources, I signed in through Azure CLI:
az login
I checked which subscription was active:
az account show --output table
I also listed the subscriptions available to my account:
az account list --output table
If you have more than one subscription, select the one you intend to use:
az account set --subscription "<YOUR_SUBSCRIPTION_ID>"
Use the subscription ID from your own az account list output. Do not copy another person's ID.
I checked the registration state of the Azure resource providers required by the project:
az provider show \
--namespace Microsoft.Web \
--query registrationState \
--output tsv
az provider show \
--namespace Microsoft.ContainerRegistry \
--query registrationState \
--output tsv
az provider show \
--namespace Microsoft.Storage \
--query registrationState \
--output tsv
If a required provider is not registered, register it:
az provider register --namespace Microsoft.Web
az provider register --namespace Microsoft.ContainerRegistry
az provider register --namespace Microsoft.Storage
Provider registration can take a little time. Check the state again before continuing.
6. I created a separate Terraform remote state backend
One decision I made early was to keep Terraform's state storage separate from the application resources.
Terraform state records the resources Terraform manages and the relationship between the configuration and the real Azure resources. If that state is lost or becomes inconsistent, managing the infrastructure becomes much harder.
I used a separate resource group and storage account for the backend:
| Setting | Value used in my project |
|---|---|
| Region | eastus |
| Resource group | rg-terraform-state |
| Storage account | stcodealphatfstate |
| Blob container | tfstate |
| State key | codealpha-project1.tfstate |
I used shell variables to make the commands easier to read:
LOCATION="eastus"
RG_NAME="rg-terraform-state"
STORAGE_ACCOUNT="stcodealphatfstate"
CONTAINER_NAME="tfstate"
Check that the storage account name is available before creating your own. Azure storage account names must be globally unique and follow Azure's naming rules.
Create the backend resource group
az group create \
--name "$RG_NAME" \
--location "$LOCATION"
Create the storage account
The storage account should use secure settings. In my setup, I used HTTPS-only access, disabled anonymous blob access and shared-key access, and used locally redundant storage.
A command for creating a storage account with these settings is:
az storage account create \
--name "$STORAGE_ACCOUNT" \
--resource-group "$RG_NAME" \
--location "$LOCATION" \
--sku Standard_LRS \
--kind StorageV2 \
--https-only true \
--allow-blob-public-access false \
--allow-shared-key-access false \
--min-tls-version TLS1_2
Enable recovery protections
I enabled blob versioning and soft delete so that accidental changes or deletions would be easier to recover from.
az storage account blob-service-properties update \
--account-name "$STORAGE_ACCOUNT" \
--resource-group "$RG_NAME" \
--enable-versioning true \
--enable-delete-retention true \
--delete-retention-days 7 \
--enable-container-delete-retention true \
--container-delete-retention-days 7
Create the state container
I used Microsoft Entra ID authentication with Azure CLI:
az storage container create \
--name "$CONTAINER_NAME" \
--account-name "$STORAGE_ACCOUNT" \
--auth-mode login
Give my signed-in identity access to the state
The identity running Terraform needs permission to read and write blobs in the storage account. I assigned the Storage Blob Data Contributor role at the storage account scope.
First, I obtained the storage account resource ID and my signed-in user object ID:
STORAGE_ID=$(az storage account show \
--name "$STORAGE_ACCOUNT" \
--resource-group "$RG_NAME" \
--query id \
--output tsv)
USER_ID=$(az ad signed-in-user show \
--query id \
--output tsv)
Then I assigned the role:
az role assignment create \
--assignee "$USER_ID" \
--role "Storage Blob Data Contributor" \
--scope "$STORAGE_ID"
Role assignments can take a short time to become effective. If Terraform immediately reports an authorization error, wait briefly and retry after checking the assignment.
7. I configured Terraform
I kept the Terraform configuration in a separate terraform directory in the project.
The configuration used the AzureRM provider. I installed the AzureRM 4.0 provider line and used version 4.0.1 in my working environment.
The provider configuration needs to target the subscription you selected. For example:
terraform {
required_version = ">= 1.0"
required_providers {
azurerm = {
source = "hashicorp/azurerm"
version = "~> 4.0.0"
}
random = {
source = "hashicorp/random"
version = "~> 3.6"
}
}
backend "azurerm" {
resource_group_name = "rg-terraform-state"
storage_account_name = "stcodealphatfstate"
container_name = "tfstate"
key = "codealpha-project1.tfstate"
use_azuread_auth = true
}
}
provider "azurerm" {
features {}
subscription_id = "<YOUR_SUBSCRIPTION_ID>"
}
Replace <YOUR_SUBSCRIPTION_ID> with your own subscription ID. Do not commit credentials or access keys to GitHub.
The backend block points Terraform to the storage account and blob container created earlier. The use_azuread_auth = true setting tells the backend to use Microsoft Entra ID authentication rather than a storage account key.
I also used variables for values such as the location, project name, environment, App Service Plan SKU, image name and image tag. This made it easier to keep resource names and settings consistent.
The infrastructure configuration created these resources:
- A resource group for the application.
- An Azure Container Registry using the Basic SKU.
- A Linux App Service Plan using the Basic B1 tier.
- A Linux Web App configured to run a custom container.
- A system-assigned managed identity for the Web App.
- An
AcrPullrole assignment so the Web App could pull the image from ACR. - A random suffix to help keep globally unique resource names unique.
The application infrastructure was deployed in East US. The Web App was configured to use port 3000 and HTTPS.
Important: The subscription ID and the generated resource suffix are specific to each deployment. Keep your own values in your local Terraform configuration. The full Terraform resource definitions should be kept in the project's
terraformdirectory and committed with the project, excluding state files and secret variable files.
Initialize and validate Terraform
From the Terraform directory:
cd terraform
terraform init
I ran formatting and validation before planning:
terraform fmt -recursive
terraform validate
Then I reviewed the proposed infrastructure:
terraform plan
I did not want to apply a plan without checking which resources Terraform intended to create.
Apply the infrastructure
Once the plan showed the expected resources, I applied it:
terraform apply
Review the plan and confirm when Terraform asks for approval.
After creation, I checked the state:
terraform state list
I also checked the outputs:
terraform output
The outputs helped me confirm the registry name, registry login server, resource group and Web App details without guessing resource names.
8. I had to resolve an Azure App Service quota issue
My first attempt to create the Basic B1 App Service Plan in East US was blocked by an Azure quota restriction.
This was not a syntax error in my Terraform configuration. Azure was rejecting the requested App Service capacity for the subscription and region.
I checked the error and contacted Azure Support to request help with the quota. After the issue was resolved, I ran the Terraform deployment again and the six resources were created.
This was a useful reminder that a valid Terraform plan does not guarantee that Azure will accept every resource request. Subscription quotas, regional capacity and service restrictions still apply.
If you encounter a similar error:
- Read the full Azure error message.
- Identify the resource type, SKU and region involved.
- Check the quota for that subscription and region.
- Request a quota increase through Azure if needed.
- Re-run the Terraform plan and apply after the quota issue is resolved.
Do not keep changing working Terraform configuration to solve a quota restriction unless the error actually points to a configuration problem.
Screenshot to add: 13-app-service-quota-error.png
Show the quota error. Remove subscription IDs or other private details.
9. I built the image and pushed it to Azure Container Registry
After the infrastructure was available, I needed to put the Docker image in a registry that Azure App Service could access.
I first checked the Terraform outputs to get the actual ACR name and login server:
terraform output
I used the registry name from my own output. In my completed deployment, the registry was:
acrcodealpha92njum
The login server was:
acrcodealpha92njum.azurecr.io
Your registry name will probably be different because the configuration uses a generated suffix.
Sign in to ACR
From the terminal:
az acr login --name "<YOUR_ACR_NAME>"
Replace the placeholder with the registry name from your Terraform output.
Build the image
From the application root, build the image:
docker build -t devops-status-dashboard:1.0.0 .
Tag the image for ACR
Use the login server from your own Terraform output:
docker tag devops-status-dashboard:1.0.0 \
<YOUR_ACR_LOGIN_SERVER>/devops-status-dashboard:1.0.0
For example, the final deployment used:
docker tag devops-status-dashboard:1.0.0 \
acrcodealpha92njum.azurecr.io/devops-status-dashboard:1.0.0
Push the image
docker push <YOUR_ACR_LOGIN_SERVER>/devops-status-dashboard:1.0.0
I then checked the repositories and tags in the Azure Portal to confirm the image was available.
10. I configured the Web App to pull from ACR using managed identity
I did not want to store an ACR username and password in the Web App configuration.
Instead, I used the Web App's system-assigned managed identity.
The identity needs the AcrPull role on the Container Registry. Terraform created this role assignment.
The important parts of this arrangement are:
- The Web App has a system-assigned managed identity.
- The identity has the
AcrPullrole on the registry. - ACR admin authentication is disabled.
- The Web App is configured to use its managed identity when pulling the container image.
For the completed deployment, the Web App was configured with the full image path and the system-assigned identity. The equivalent Azure CLI configuration is:
az webapp config set \
--resource-group rg-codealpha-dev \
--name app-codealpha-92njum \
--linux-fx-version "DOCKER|acrcodealpha92njum.azurecr.io/devops-status-dashboard:1.0.0" \
--acr-use-identity true \
--acr-identity '[system]'
Use your own resource group, Web App name, registry login server and image tag. Do not copy my generated names if your Terraform outputs are different.
I also configured the application to use port 3000. For Linux custom containers on App Service, the application port must match the port the application listens on. In this project, that was 3000.
11. I prepared Azure DevOps
I used Azure DevOps Pipelines for the CI/CD part of the project.
I already had Azure CLI installed, so I added the Azure DevOps extension:
az extension list \
--query "[?name=='azure-devops'].name" \
--output tsv
If it was not installed, I added it:
az extension add --name azure-devops
I checked the installed version:
az extension show \
--name azure-devops \
--query version \
--output tsv
I then checked my Azure CLI login:
az account show --output table
Azure authentication and Azure DevOps authentication are related, but they are not the same thing. I checked the DevOps CLI configuration too:
az devops configure --list
Create the Azure DevOps organization
I created the organization through the Azure DevOps website:
- Open https://dev.azure.com.
- Sign in.
- Create a new organization.
- Choose an available organization name.
My organization was:
https://dev.azure.com/taiwo-cloud-devops
Configure the CLI to use the organization
az devops configure --defaults \
organization=https://dev.azure.com/taiwo-cloud-devops
I checked the configuration:
az devops configure --list
I also checked that the organization was accessible:
az devops project list \
--org https://dev.azure.com/taiwo-cloud-devops \
--detect false \
--output table
The --detect false option prevents automatic repository detection for that command. Supplying --org makes it clear which organization the CLI should use.
Create the project
I created a private project:
az devops project create \
--name "CodeAlpha-DevOps-Project1" \
--description "Automated CI/CD pipeline for DevOps Status Dashboard" \
--visibility private \
--source-control git \
--org https://dev.azure.com/taiwo-cloud-devops \
--detect false
Then I verified it:
az devops project show \
--project "CodeAlpha-DevOps-Project1" \
--org https://dev.azure.com/taiwo-cloud-devops \
--detect false \
--output table
12. I checked the GitHub repository before connecting the pipeline
Before creating the pipeline, I checked that I was working in the right repository and branch.
git remote -v
git branch --show-current
git status --short
ls -la
I confirmed that the repository remote pointed to my project repository:
https://github.com/highpee1991/CodeAlpha_ProjectName.git
I checked whether a pipeline YAML file already existed:
if [ -f azure-pipelines.yml ]; then
echo "Pipeline YAML already exists"
else
echo "Pipeline YAML does not exist yet"
fi
I also checked the security-related files:
cat .gitignore
cat .dockerignore
And checked whether sensitive files were being tracked:
git ls-files .env terraform.tfstate terraform.tfstate.backup
To see whether expected files were ignored:
git check-ignore -v .env terraform.tfstate node_modules/
The point of these checks was to avoid committing secrets, Terraform state or local dependencies to GitHub.
13. I created the service connections
The pipeline needed permission to push images to ACR and update the Web App.
I configured two service connections in Azure DevOps:
- A Docker Registry service connection for Azure Container Registry.
- An Azure Resource Manager service connection for deploying to Azure.
The Azure Resource Manager connection was named:
sc-codealpha-azure
I used workload identity federation (OIDC) for the Azure Resource Manager connection. This avoids putting a long-lived client secret in the pipeline YAML.
I scoped the connection to the application resource group, rg-codealpha-dev, and authorized the pipeline to use it.
The Docker registry service connection was used by the Docker task to authenticate to ACR and push the image.
There are two separate identities involved in the deployment:
| Identity | Responsibility |
|---|---|
| Azure DevOps service connection | Allows the pipeline to update Azure resources |
| App Service system-assigned managed identity | Allows the Web App to pull the image from ACR |
These identities do different jobs. The pipeline identity deploys the application; the Web App identity pulls the container image when it starts.
14. I added the Azure Pipelines YAML file
I created azure-pipelines.yml in the root of the GitHub repository.
The pipeline has two stages:
- Build: Build the Docker image and push it to ACR.
- Deploy: Update the Web App to use the new image, restart it and check the health endpoint.
This is the pipeline used for the completed deployment:
trigger:
- main
resources:
- repo: self
variables:
dockerRegistryServiceConnection: "35bff728-40ea-42a4-bf8f-ead90173c7bd"
azureServiceConnection: "sc-codealpha-azure"
imageRepository: "devops-status-dashboard"
containerRegistry: "acrcodealpha92njum.azurecr.io"
dockerfilePath: "$(Build.SourcesDirectory)/Dockerfile"
tag: "$(Build.BuildId)"
vmImageName: "ubuntu-latest"
stages:
- stage: Build
displayName: Build and push stage
jobs:
- job: Build
displayName: Build Docker image
pool:
vmImage: $(vmImageName)
steps:
- task: Docker@2
displayName: Build and push image to ACR
inputs:
command: buildAndPush
repository: $(imageRepository)
dockerfile: $(dockerfilePath)
containerRegistry: $(dockerRegistryServiceConnection)
tags: |
$(tag)
- stage: Deploy
displayName: Deploy to Azure App Service
dependsOn: Build
condition: succeeded()
jobs:
- job: Deploy
displayName: Deploy container
pool:
vmImage: $(vmImageName)
steps:
- task: AzureCLI@2
displayName: Update App Service container
inputs:
azureSubscription: $(azureServiceConnection)
scriptType: bash
scriptLocation: inlineScript
inlineScript: |
set -e
echo "Configuring App Service with the full ACR image path..."
az webapp config set \
--resource-group rg-codealpha-dev \
--name app-codealpha-92njum \
--linux-fx-version "DOCKER|$(containerRegistry)/$(imageRepository):$(tag)" \
--acr-use-identity true \
--acr-identity '[system]'
echo "Restarting App Service..."
az webapp restart \
--resource-group rg-codealpha-dev \
--name app-codealpha-92njum
echo "Waiting for application health check..."
for attempt in {1..18}; do
status=$(curl -sS -o /tmp/health-response -w "%{http_code}" \
https://app-codealpha-92njum.azurewebsites.net/health || true)
if [ "$status" = "200" ]; then
echo "Application is healthy!"
cat /tmp/health-response
exit 0
fi
echo "Attempt $attempt: HTTP $status. Waiting..."
sleep 10
done
echo "Application failed its health check."
cat /tmp/health-response || true
exit 1
Important: update the values for your own Azure deployment
The YAML above contains the actual service connection ID and resource names from my completed environment. For your own deployment, update:
-
dockerRegistryServiceConnectionto the ID of your Docker Registry service connection. -
azureServiceConnectionto your Azure Resource Manager service connection name. -
containerRegistryto your ACR login server. - The resource group and Web App names in the Azure CLI commands.
- The health URL to your own Web App URL.
Do not copy the service connection ID from this article and expect it to work in another Azure DevOps organization. Service connection IDs are specific to an organization.
The $(Build.BuildId) variable gives each pipeline run a build-specific image tag. This makes it easier to identify which image was deployed.
The deployment stage uses the full ACR image path. This detail mattered in my deployment. An earlier configuration caused App Service to try pulling the image from Docker Hub. I corrected the Web App configuration so it pointed to the full ACR image path and used the system-assigned identity.
The health-check loop gives the Web App time to restart. It checks /health and only succeeds when it receives HTTP 200. If the endpoint does not become healthy within the retry window, the pipeline fails instead of reporting a successful deployment.
15. I connected GitHub and ran the pipeline
In Azure DevOps, I created a pipeline and selected the GitHub repository:
highpee1991/CodeAlpha_ProjectName
I selected the existing azure-pipelines.yml file from the main branch.
After saving the pipeline, I pushed the YAML file and any final changes to GitHub:
git add azure-pipelines.yml
git diff --cached
git diff --check
git commit -m "Add Azure DevOps CI/CD pipeline"
git push origin main
Review the staged changes before committing. Do not commit .env files, Terraform state, plan files, access keys or other secrets.
Because the pipeline has a trigger for main, a push to that branch starts a run.
I opened the pipeline run in Azure DevOps and followed the two stages.
Build stage
The Docker task:
- Authenticates to ACR using the Docker Registry service connection.
- Builds the image using the project's Dockerfile.
- Tags the image with the Azure Pipelines build ID.
- Pushes the image to ACR.
Deploy stage
The Azure CLI task:
- Uses the Azure Resource Manager service connection.
- Updates the Web App to use the new image in ACR.
- Configures the Web App to pull using its system-assigned identity.
- Restarts the Web App.
- Checks the
/healthendpoint. - Fails the deployment if the health endpoint does not return HTTP 200 within the retry period.
My successful pipeline run completed both stages and printed the health response.
16. I verified the live application
I did not treat a successful pipeline run as the only proof that the deployment worked. I checked the live application itself.
I opened the health endpoint:
https://app-codealpha-92njum.azurewebsites.net/health
I also tested it from the terminal:
curl -i https://app-codealpha-92njum.azurewebsites.net/health
Then I checked the status endpoint:
curl -i https://app-codealpha-92njum.azurewebsites.net/api/status
Both endpoints returned HTTP 200 in my final verification.
The health response contained:
{
"status": "healthy"
}
The status endpoint returned information about the running application, including:
- Environment:
dev - Application version:
1.0.0 - Node.js version:
v20.20.2
The live values can change between restarts, so the timestamp, hostname and uptime in the response may be different when you test your own deployment.
17. The deployment flow
This is the flow I implemented:
flowchart TD
A["GitHub Repository"] --> B["Azure DevOps Pipelines"]
B --> C["Build Docker Image"]
C --> D["Azure Container Registry"]
D --> E["Azure App Service"]
E --> F["Health Check"]
F --> G["Application Running"]
The source code lives in GitHub. A push to main triggers Azure Pipelines. The pipeline builds the container image and pushes it to ACR. The deployment stage updates Azure App Service to use that image. App Service pulls the image with its managed identity, starts the container and the pipeline checks the health endpoint.
18. What I struggled with
This project was not a straight line from writing a Dockerfile to getting a successful deployment. I had to stop and investigate a few problems.
The Docker container could not find the application entry point
I initially pointed the Dockerfile to index.js, but the application entry point was server.js. The container stopped because Node could not find the file.
I checked docker ps -a and docker logs, corrected the Dockerfile and rebuilt the image. This reminded me to check the container logs before changing unrelated configuration.
Terraform initialization and configuration issues
I had to correct some Terraform configuration issues during initialization and planning. I learned to read the error message carefully, check the relevant provider and backend settings, make one correction at a time and run initialization or validation again.
Azure provider registration
Some Azure resource providers were not registered in the subscription. I checked their registration state and registered the required providers before continuing.
The App Service B1 quota
Azure rejected the Basic B1 App Service Plan request in East US because of a subscription quota restriction. I contacted Azure Support and continued after the quota issue was resolved.
App Service tried to pull from Docker Hub
During deployment, App Service was not using the ACR image path I intended. I corrected the container configuration to use the full ACR login server and image name, and enabled managed identity authentication for the registry pull.
Service connection setup
The Azure DevOps service connection setup also needed care. I used workload identity federation for the Azure Resource Manager connection rather than storing a client secret in the pipeline YAML. I also had to make sure the pipeline was authorized to use the connection.
These issues took time, but each one helped me understand what was happening instead of just repeating commands.
19. What I learned
By completing this project, I gained practical experience with:
- Checking that an application works before containerising it.
- Writing a Dockerfile for a Node.js application.
- Using
.dockerignoreto keep unnecessary files out of the build context. - Building, running, inspecting and troubleshooting Docker containers.
- Using Azure CLI to inspect subscriptions and register resource providers.
- Creating a separate Azure Storage backend for Terraform state.
- Using Microsoft Entra ID authentication for Terraform remote state.
- Provisioning Azure resources with Terraform.
- Understanding the relationship between an App Service Plan, Web App and Container Registry.
- Using managed identity and the
AcrPullrole for registry access. - Creating an Azure DevOps organization and project.
- Connecting GitHub to Azure Pipelines.
- Using workload identity federation for pipeline access to Azure.
- Building and pushing a versioned container image through a CI/CD pipeline.
- Deploying the image to Azure App Service and checking the application health.
20. Lessons I took home
The biggest lesson for me was to troubleshoot the layer where the problem is happening.
When Docker could not start the application, I checked the container logs instead of changing Azure settings. When Terraform was blocked by a quota, I investigated the Azure quota rather than rewriting working Terraform code. When App Service pulled from the wrong registry, I checked the image configuration and corrected the ACR path.
I also learned that identity and permissions need to be planned as part of the deployment. The pipeline needs permission to deploy, while the Web App needs permission to pull the image. Giving each identity only the access it needs makes the setup easier to understand and safer to manage.
Another lesson was to verify every stage. I checked the application locally before Docker, tested the container before pushing it, reviewed the Terraform plan before applying it, checked the image in ACR and tested the live endpoints after deployment.
Most importantly, I learned not to assume that a green pipeline alone means the application is working. The final check should be against the running application.
21. Cleaning up Azure resources
After I had captured the screenshots and completed the documentation, I could remove the application resources to avoid leaving them running unnecessarily.
Before destroying anything, I checked the Terraform workspace and reviewed the destroy plan:
cd terraform
terraform plan -destroy
Only after confirming that the plan contained the application resources I intended to remove would I run:
terraform destroy
I kept the separate Terraform state backend:
- Resource group:
rg-terraform-state - Storage account:
stcodealphatfstate - Container:
tfstate - State key:
codealpha-project1.tfstate
Do not destroy the remote state backend while you still need the state file. Also remember that resources created outside the Terraform configuration, or resources managed by another state file, will not necessarily be removed by this command.
Check the destroy plan carefully before approving it. Azure resources can incur charges while they remain deployed.
Final thoughts
This project gave me the chance to work through a deployment from the application level to the cloud infrastructure and CI/CD pipeline. I had to understand how the application starts, how Docker packages it, how Terraform creates the Azure resources, how identities allow the services to communicate and how the pipeline moves a new image into production.
I did run into problems, especially with the Docker entry point, Terraform setup, Azure quota and the ACR image configuration. Working through those issues was an important part of the project.
The final result was a Node.js application running on Azure App Service as a container, with its image stored in Azure Container Registry and its deployment automated through Azure DevOps Pipelines.
Thanks for reading.












Top comments (1)
The ACR plus managed identity part is the one that saves the most trouble later. Hardcoded credentials in a container image are the leak that keeps showing up.