Skip to content

Azure Deployment

PROJECT ZERO edited this page Jan 18, 2025 · 1 revision

Azure Deployment

This document provides step-by-step instructions for deploying the application to Azure.

Prerequisites

Before you begin, ensure you have the following:

  • An Azure account
  • Azure CLI installed and configured
  • Docker installed

Step 1: Build the Docker Image

First, build the Docker image for the application.

docker build -t myapp:latest .

Step 2: Push the Docker Image to Azure Container Registry (ACR)

Create a repository in Azure ACR and push the Docker image to it.

  1. Create a resource group:
az group create --name myResourceGroup --location <your-location>
  1. Create a container registry:
az acr create --resource-group myResourceGroup --name myContainerRegistry --sku Basic
  1. Authenticate Docker to the Azure ACR registry:
az acr login --name myContainerRegistry
  1. Tag the Docker image:
docker tag myapp:latest mycontainerregistry.azurecr.io/myapp:latest
  1. Push the Docker image:
docker push mycontainerregistry.azurecr.io/myapp:latest

Step 3: Deploy the Application to Azure Kubernetes Service (AKS)

Create a Kubernetes cluster and deploy the application to AKS.

  1. Create a Kubernetes cluster:
az aks create --resource-group myResourceGroup --name myAKSCluster --node-count 1 --enable-addons monitoring --generate-ssh-keys
  1. Get the credentials for the Kubernetes cluster:
az aks get-credentials --resource-group myResourceGroup --name myAKSCluster
  1. Create a deployment YAML file (deployment.yaml):
apiVersion: apps/v1
kind: Deployment
metadata:
  name: myapp
spec:
  replicas: 1
  selector:
    matchLabels:
      app: myapp
  template:
    metadata:
      labels:
        app: myapp
    spec:
      containers:
      - name: myapp
        image: mycontainerregistry.azurecr.io/myapp:latest
        ports:
        - containerPort: 80
  1. Apply the deployment:
kubectl apply -f deployment.yaml
  1. Expose the deployment as a service:
kubectl expose deployment myapp --type=LoadBalancer --name=myapp-service

Step 4: Verify the Deployment

Verify that the application is running by checking the AKS service and accessing the application URL.

  1. Check the AKS service status:
kubectl get services myapp-service
  1. Access the application URL:

Retrieve the external IP address of the service and access the application in your web browser.

Conclusion

You have successfully deployed the application to Azure using Azure Kubernetes Service (AKS) and Docker.

TABLE OF CONTENTS

Clone this wiki locally