Docker

Deploy .Net Core App to Azure Container Registry in 5min

Prerequisites
Docker Desktop
Visual Studio Code
VS Code Extension: Azure Tools and Docker
Azure Container Registry, an Azure subscription
Running Docker container for .Net Core App
Reference: https://phpwebplus.wordpress.com/2019/11/02/dockerize-an-asp-net-core-application-in-5min

Step 1:  Create azure resource group
Using Azure Cli create the Resource Group, Container registry and Webapp much more.
az login -u <username> -p <password>
az group create --name <group_name> --location <location>
az group create --name demogroup --location eastus

Step 2:  Create azure container registry
Azure Container Registry allows you to store images for all types of container deployments including DC/OS, Docker Swarm, Kubernetes and Azure services such as App Service, Batch, Service Fabric and others
az acr create --name <container_name> -g <group_name>
az acr create -g demogroup --name demoContainerRegistry --sku Basic --admin-enabled true

Step 2.1:  Getting the credentials
az acr credential show -n <container_registery_name>
az acr credential show -n demoContainerRegistry

Step 3:  Tag Docker Image with registry reference
docker tag <registry_uri>/<name:version>
docker tag demoContainerRegistry.azurecr.io/dotnetdemo:v1

Step 4:  Login to Container Registry
docker login https://<registry_uri> -u <username> -p <parrword>
-u <registry-username>
-p <registry-password>

Step 5:  Publish your Docker Image to Azure Container Registry
docker push <docker_tag_name> (<registry_uri>/<name:version>)

Step 6:  Deploy as Webapp

Step 6.1:  Creating Service Plan
az appservice plan create -n <plan_name> -g <group_name>
az appservice plan create -n demoplan -g demogroup --sku S1 --is-linux

Step 6.2:  Creating WebApp
az webapp create -g <group_name> -p <plan_name> -n <app-name> --deployment-container-image-name <azure-container-registry-name>

Step 6.3:  Configure WebApp with Container Registry
az webapp config container set
-n <app-name>
-g <group>
--docker-custom-image-name <tag_name>
--docker-registry-server-url <container-registry-url>
--docker-registry-server-user <username>
--docker-registry-server-password <password>

Resource
Github: https://github.com/deepaksvjois/dotnetcore_docker

Leave a comment