8 steps to deploy A CI/CD dockerised .NET App with Azure Container registry To Azure Web Apps.

Adeniye Kehinde Afusat
5 min readJan 5, 2022

Implementing CI/CD using Azure DevOps.

Prerequisites

_ Docker Desktop

_ Azure subscription (Azure portal , Dev Portal)

_Microsoft Visual Studio 2019.

_Azure container registry and Azure App Services.

Step 1:

Create a project locally on Microsoft Visual Studio 2019.

  • The project folder called cicddockerapp
  • Select Asp.Net Application.
  • Select the docker option
  • Create the .net application
  • Verify if the application and docker is running using f5 or the docker option shown in the screenshot below.

The docker container is running

The docker container is running
  • The image above shows that the ASP.NET app is running and the docker installed is running also. https://localhost:49153/

Step 2:

Login to http://dev.azure.com/ to create a project on the dev environment.

  • create a new project called cicddockerapp
  • Select the advanced option git.
  • Copy out the azure repro URL.( This would be used to push the code)

Step 3:

Pushing the code locally to the Azure repro.

  • Cd into the project file explorer using the command prompt.
  • Use the following git commands Azure repro
  • (- git init, git add. , git commit -m “pushing the code”, git add remote origin (azure repro URL copied in step 2.), git push -u origin — all).
  • Lastly, refresh the dev.azure.com, this shows the code has been pushed successfully to the remote repository.

Step 4:

Creating azure container registry using http://portal.azure.com/, would be used to upload the docker image.

  • Select container registry from Azure portal and create
enable admin user.
  • After creating the container, the next is to enable the access key, this is required in the release part, as the admin user needs to be enabled. this would automatically take the image from container history to the azure web app.

Step 5:

Create build process using the azure pipeline.

  • Create your first pipeline using classic editor, which selects the project by default, then click continue.
  • Select an empty job and click Ubuntu latest.
  • Click on the + icon, then search for docker, then add docker to the agent job.
  • Add a task that would build and push the image to the container registry.
  • Select the azure container registry, this would require logging into the Azure portal, then select the Azure container registry created in step 4.
  • Fill the required parameter shared in the image below, then save and queue.
  • Lastly, the agent job runs the build and push task.

Step 6:

Create a web app using https://portal.azure.com/#home

  • Select the docker container when creating the app service.
  • Then select the docker image “cicdcontainerepo” created in step 4
  • In the azure container registry, the images appear.

Step 7:

Create a new release pipeline.

  • Select the build artifact, select the source and add the build artifact.
  • Select the stage, rename it as prod, add the agent job and select ubuntu-latest as specification.
  • Add the empty task, and choose Azure web app for containers.
  • Give a web app name, navigate to the container registry to get the image name.

Step 8:

Implementing continuous integration and continuous deployment on the containerized .NET application.

  • Edit pipeline created in step 5, click on trigger, and enable the continuous integration.
  • Edit the release pipeline, enable continuous deployment, then click on save.

Finally, make some changes on the code locally, push to the Azure repo using git commands as shown in step 3 above and this should automatically trigger a new build pipeline and new release pipeline.

Now we have a successful deployment, we can navigate to the web app URL Home Page — cicdockerapp (cicddockerwebappp.azurewebsites.net) which should be running.

Conclusion

Thank you for reading and following through. In this article we have deployed a dockerized .NET app to azure app services integrating CI/CD pipeline with Azure container registry to manage the image inside the container.

Feel free to lookup my Github and connect with me on Linkedin and Twitter.

Articles/ Resources used.

Deploy ASP.NET Docker container to Azure Container Registry — Visual Studio (Windows) | Microsoft Docs

Quickstart — Create registry in portal — Azure Container Registry | Microsoft Docs

https://www.youtube.com/watch?v=tQH1EsVLmoU

--

--

Adeniye Kehinde Afusat

Kehinde is a technology enthusiast, experienced with Azure DevOps. She has expertise in Cloud technologies and software programming.