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.
- 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
Step 2
Configure your application
Step 3
Provide additional information
Step 4
Add docker support inside the application using Visual Studio
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
Step 3
After that, Create a new Azure Container Registry
Step 4
Next, right-click on the application solution and click on publish
Step 5
Click on Docker Container Registry and press Next
Step 6
Select Azure Container Registry and Click Next
Step 7
After that, select the subscription and container registry which we created earlier and click on finish
Step 8
Next, click on Publish and it will upload a docker image on the azure container registry
Step 9
Here you can see application image details inside the repository section of our container registry on the Azure portal
Run application image inside Azure Container Instance
Step 1
Create Container Instance
Step 2
Configure container registry and a few details related to that.
(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)
Step 3
After that, we can see Public IP using that we can able to access our application
Step 4
Open the browser and hit the URL
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!