Achraf Ben Alaya
No Result
View All Result
  • Home
  • News
  • Blog
    • blazor
    • c#
    • Cloud
      • Azure
    • docker
    • sql
    • xamarin
    • Dapr
    • Tricks, Tips and Fixes
    • General Tips & Fix
  • AI
  • Cloud
  • Motivation
  • Courses
  • About
    • Resume
    • Privacy Policy
SUBSCRIBE
  • Home
  • News
  • Blog
    • blazor
    • c#
    • Cloud
      • Azure
    • docker
    • sql
    • xamarin
    • Dapr
    • Tricks, Tips and Fixes
    • General Tips & Fix
  • AI
  • Cloud
  • Motivation
  • Courses
  • About
    • Resume
    • Privacy Policy
No Result
View All Result
Achraf Ben Alaya
No Result
View All Result
ADVERTISEMENT
Home Blog Cloud Azure

From Docker Hub, switch to Azure Container Registry & AKS

achraf by achraf
January 16, 2023
in Azure, Blog
4 min read
1
0
SHARES
587
VIEWS
Share on FacebookShare on Twitter

We previously looked at how to configure an ingress controller for the Azure Kubernetes Service (AKS) using TLS/SSL. In this section, we’ll look at how to construct an Azure container registry using Terraform and how to utilize it in our deployment. We’ll also look at some of the benefits of an acr :

– Ability to find, pull, and push Docker images
– Integration with other Azure services
– Built-in security features
– Role-based access control
– Image signing

This article is a part of a series:

  1. Part 1 : How to setup nginx reverse proxy for aspnet core apps with and without Docker compose
  2. Part 2 :How to setup nginx reverse proxy && load balancer for aspnet core apps with Docker and azure kubernetes service
  3. Part 3 : How to configure an ingress controller using TLS/SSL for the Azure Kubernetes Service (AKS)
  4. Part 4 : switch to Azure Container Registry from Docker Hub
  5. Part 5: Using Azure DevOps, Automate Your CI/CD Pipeline and Your Deployments
  6. Part 6 : Using Github, Automate Your CI/CD Pipeline and Your Deployments
  7. Part 7 : Possible methods to reduce your costs

    Part 1 : Creating Azure container registry (ACR)

    The first step is to set up the Azure container registry and ensure that it is connected to our Kubernetes cluster.

    Terrafrom Block to create the acr :

    resource "azurerm_container_registry" "acr001" {
      name                = "containerRegistryachraf"
      resource_group_name = azurerm_resource_group.rg.name
      location            = azurerm_resource_group.rg.location
      sku                 = "Standard"
    }
    
    
    resource "azurerm_role_assignment" "roleforaks" {
      principal_id                     = azurerm_kubernetes_cluster.cluster.kubelet_identity[0].object_id
      role_definition_name             = "AcrPull"
      scope                            = azurerm_container_registry.acr001.id
      skip_service_principal_aad_check = true
    }

    Now that we have added this block to our infrastructure, acr will be ready to use, but first we must deploy an application to our repository. To do this, we will take the same dotnet application and simply add the word “acr” to the index page.

    Part 2 : Deploying to ACR

    Install Docker first, then create a fresh copy of our application to test out the Azure Container Registry.

    To access your container registry, use the following command:

    docker login containerregistryname.azurecr.io.

    Next, let’s tag and push our image:

    docker tag hello-world containerregistryname.azurecr.io/hello-world 
    docker push containerregistryname.azurecr.io/hello-world

    once we deployed our application it will look like the below image inside ACR :

    Part 3: Create our deployment and updating our ingress

    In this part, we are creating a new deployment as we are adding a new application  :

    apiVersion: apps/v1
    kind: Deployment
    metadata:
      name: backend-restapp-acr
      namespace: ingress 
      labels:
        app: backend-restapp-acr
        tier: backend 
    spec:
      replicas: 2
      selector:
        matchLabels:
          app: backend-restapp-acr
      template:
        metadata:
          labels:
            app: backend-restapp-acr
            tier: backend 
        spec: 
          containers:
            - name: backend-restapp-acr
              image: containerregistryachraf.azurecr.io/hello-world:latest
              ports:
                - containerPort: 5000        
    ---
    apiVersion: v1
    kind: Service
    metadata:
      name: my-backend-serviceacr ## VERY VERY IMPORTANT - NGINX PROXYPASS needs this name
      labels:
        app: backend-restapp-acr
        tier: backend   
    spec:
      selector:
        app: backend-restapp-acr
      ports:
        - name: http
          port: 5000 # ClusterIP Service Port
          targetPort: 5000 # Container Port
      type: ClusterIP    
    

    using the following commands, you can deploy our application:

    kubectl apply -f 01-backend-acr-deployment.yml

    Great , now if we try to check our services using :

    kubectl get services --namespace ingress

    we will get a new service in our list :
    Also , if we check our deployements :

    kubectl get deployments --namespace ingress

    Now let’s update our ingress with our new app :

    apiVersion: networking.k8s.io/v1
    kind: Ingress
    metadata:
      name: webapp-ingress
      namespace: ingress
      annotations:
        nginx.ingress.kubernetes.io/ssl-redirect: "false"
        nginx.ingress.kubernetes.io/use-regex: "true"
        nginx.ingress.kubernetes.io/rewrite-target: /$1
    spec:
      ingressClassName: nginx
      rules:
      - http:
          paths:
          - backend:
              service:
                name: my-backend-service
                port:
                  number: 5000
            path: /
            pathType: Prefix
          - backend:
              service:
                name: my-backend-serviceacr
                port:
                  number: 5000
            path: /acr(/|$)(.*)
            pathType: Prefix  
          - backend:
              service:
                name: my-nginx-service-01
                port:
                  number: 80
            path: /webapp1(/|$)(.*)
            pathType: Prefix        
          - backend:
              service:
                name: my-nginx-service-02
                port:
                  number: 80
            path: /webapp2(/|$)(.*)
            pathType: Prefix  
          - backend:
              service:
                name: my-nginx-service-03
                port:
                  number: 80
            path: /webapp3(/|$)(.*)
            pathType: Prefix                          
      - host: yourdomaine.com # change the IP address here
        http:
          paths:
          - backend:
              service:
                name: my-backend-service
                port: 
                  number: 5000
            path: /
            pathType: Prefix
          - backend:
              service:
                name: my-backend-serviceacr
                port: 
                  number: 5000
            path: /acr
            pathType: Prefix    
          - backend:
              service:
                name: my-nginx-service-01
                port: 
                  number: 80
            path: /webapp1
            pathType: Prefix        
          - backend:
              service:
                name: my-nginx-service-02
                port: 
                  number: 80
            path: /webapp2
            pathType: Prefix     
          - backend:
              service:
                name: my-nginx-service-03
                port: 
                  number: 80
            path: /webapp3
            pathType: Prefix

    Let’s deploy and see the results :

    kubectl apply -f app-ingress.yml

    Now if we visit the url of our ingress using the /acr prefix that we have created we should find the new deployment that we have added :
    Hope this was helpful ^^

ShareTweet
Previous Post

How to configure an ingress controller using TLS/SSL for the Azure Kubernetes Service (AKS)

Next Post

Configuring Self-hosted Agent In Azure DevOps Pipeline

Related Posts

Blog

 2025 – Certifications, Community, and 50K Views

December 28, 2025
35
Azure

From Manual Terraform to AI-Assisted DevOps: Building an Azure Container Platform (Part 1)

December 23, 2025
17
AI

Build and Host an Expense Tracking MCP Server with Azure Functions

November 2, 2025
704
Azure

Log Analytics Workspace Chaos: How We Tamed 100+ Orphaned Workspaces

October 17, 2025
203
Azure

Honored to be recognized as a Microsoft Azure MVP for 2025-2026

July 20, 2025
134
AI

Model Context Protocol (MCP): The Future of AI Integration

April 21, 2025
312
Next Post
Configuring Self-hosted Agent In Azure DevOps Pipeline

Configuring Self-hosted Agent In Azure DevOps Pipeline

Comments 1

  1. Pingback: Reflecting on a Year of Growth: 2023 in Review – achraf ben alaya

Leave a Reply Cancel reply

Your email address will not be published. Required fields are marked *

Terraform

Certifications

Microsoft certified trainer (MCT)

Recommended

Dapr – State management (redis)  Part 1/2

Dapr – State management (redis) Part 1/2

August 17, 2021
779
Azure Function to Upload Data to Azure Blob

Azure Function to Upload Data to Azure Blob

August 29, 2020
3.5k
Configure Azure Web App Logging With .NET 5

Configure Azure Web App Logging With .NET 5

December 11, 2020
2.4k
My 2020 Review

My 2020 Review

December 31, 2020
278
Welcome to Azure Resource Mover service

Welcome to Azure Resource Mover service

February 2, 2021
249
Animations with Lottie in Xamarin Forms

Animations with Lottie in Xamarin Forms

April 26, 2020
1.1k
Facebook Twitter LinkedIn Youtube

 2025 – Certifications, Community, and 50K Views

December 28, 2025

From Manual Terraform to AI-Assisted DevOps: Building an Azure Container Platform (Part 1)

December 23, 2025

Build and Host an Expense Tracking MCP Server with Azure Functions

November 2, 2025

Categories

  • AI (3)
  • Apps (1)
  • Azure (67)
  • blazor (2)
  • Blog (94)
  • c# (7)
  • Cloud (69)
  • Courses (4)
  • Dapr (4)
  • docker (4)
  • Games (1)
  • General Tips & Fix (1)
  • Home (1)
  • Kubernetes Service (AKS) (1)
  • motivation (2)
  • Motivation (3)
  • News (9)
  • Resume (1)
  • sql (4)
  • Terrafrom (2)
  • Tricks, Tips and Fixes (4)
  • xamarin (5)
No Result
View All Result
  • Home
  • News
  • Blog
    • blazor
    • c#
    • Cloud
      • Azure
    • docker
    • sql
    • xamarin
    • Dapr
    • Tricks, Tips and Fixes
    • General Tips & Fix
  • AI
  • Cloud
  • Motivation
  • Courses
  • About
    • Resume
    • Privacy Policy