Deploy And Run .NET Core 7 Web API On Azure Container Registry And Container Instance

We will learn about the Containerization of .NET Core Web API using Docker and then deploy it on Azure Container Registry and then run that image into the Azure Container Instance.

Agenda

  • Overview
  • Implementation of .NET Core Web API
  • Dockerization of application
  • Deploy application image on Azure Container Registry
  • Run application image inside Azure Container Instance

Prerequisites

Overview

  • In the software world, we all want to automate things and reduce manual work related to the deployment and management of different application components, in that case, azure provides many services for that like azure container registry and container instance as I have shown below diagram.

Deploy and Run .NET Core 7 Web API on Azure Container Registry and Container Instance

  • Azure container registry stores private docker images and manages the same.
  • Azure container instance is a managed service that helps us to run a container directly on the azure cloud without requiring any other infrastructure like a virtual machine (VM) and like that.
  • Also, it helps to automate our application deployment by using CI/CD tools in which we configure some automation steps which build and deploy our application docker image inside the container registry and after that, we can quickly run that image inside the azure container instance in an isolated environment very efficiently.

Implementation of .NET Core Web API

Step 1

Create a new .NET Core 7 Web API

Deploy and Run .NET Core 7 Web API on Azure Container Registry and Container Instance

Step 2

Configure your application

Deploy and Run .NET Core 7 Web API on Azure Container Registry and Container Instance

Step 3

Provide additional information

Deploy and Run .NET Core 7 Web API on Azure Container Registry and Container Instance

Step 4

Add docker support inside the application using Visual Studio

Deploy and Run .NET Core 7 Web API on Azure Container Registry and Container Instance

Deploy and Run .NET Core 7 Web API on Azure Container Registry and Container Instance

Deploy and Run .NET Core 7 Web API on Azure Container Registry and Container Instance

Step 5

Run the application using the docker (Note: Make sure Docker Desktop is installed and running on your machine)

Deploy application image on Azure Container Registry

Step 1

Login on Azure Portal

Step 2

Create Resource Group

Deploy and Run .NET Core 7 Web API on Azure Container Registry and Container Instance

Deploy and Run .NET Core 7 Web API on Azure Container Registry and Container Instance

Deploy and Run .NET Core 7 Web API on Azure Container Registry and Container Instance

Step 3

After that, Create a new Azure Container Registry

Deploy and Run .NET Core 7 Web API on Azure Container Registry and Container Instance

Deploy and Run .NET Core 7 Web API on Azure Container Registry and Container Instance

Deploy and Run .NET Core 7 Web API on Azure Container Registry and Container Instance

Deploy and Run .NET Core 7 Web API on Azure Container Registry and Container Instance

Deploy and Run .NET Core 7 Web API on Azure Container Registry and Container Instance

Step 4

Next, right-click on the application solution and click on publish

Deploy and Run .NET Core 7 Web API on Azure Container Registry and Container Instance

Step 5

Click on Docker Container Registry and press Next

Deploy and Run .NET Core 7 Web API on Azure Container Registry and Container Instance

Step 6

Select Azure Container Registry and Click Next

Deploy and Run .NET Core 7 Web API on Azure Container Registry and Container Instance

Step 7

After that, select the subscription and container registry which we created earlier and click on finish

Deploy and Run .NET Core 7 Web API on Azure Container Registry and Container Instance

Step 8

Next, click on Publish and it will upload a docker image on the azure container registry

Deploy and Run .NET Core 7 Web API on Azure Container Registry and Container Instance

Deploy and Run .NET Core 7 Web API on Azure Container Registry and Container Instance

Deploy and Run .NET Core 7 Web API on Azure Container Registry and Container Instance

Step 9

Here you can see application image details inside the repository section of our container registry on the Azure portal

Deploy and Run .NET Core 7 Web API on Azure Container Registry and Container Instance

Deploy and Run .NET Core 7 Web API on Azure Container Registry and Container Instance

Deploy and Run .NET Core 7 Web API on Azure Container Registry and Container Instance

Deploy and Run .NET Core 7 Web API on Azure Container Registry and Container Instance

Run application image inside Azure Container Instance

Step 1

Create Container Instance

Deploy and Run .NET Core 7 Web API on Azure Container Registry and Container Instance

Deploy and Run .NET Core 7 Web API on Azure Container Registry and Container Instance

Step 2

Configure container registry and a few details related to that.

Deploy and Run .NET Core 7 Web API on Azure Container Registry and Container Instance

(Note: Sometimes we got issues while configuring the container registry and we need to provide admin user access for that go to the container registry and inside the access key section and enable the admin user as I shown below)

Deploy and Run .NET Core 7 Web API on Azure Container Registry and Container Instance

Step 3

After that, we can see Public IP using that we can able to access our application

Deploy and Run .NET Core 7 Web API on Azure Container Registry and Container Instance

Step 4

Open the browser and hit the URL

Deploy and Run .NET Core 7 Web API on Azure Container Registry and Container Instance

Conclusion

Here we discuss the Containerization of applications using Azure container registry and instance. Also, the step-by-step like how to create the resource and run it on Azure.

Happy Learning!