Deploy an ASP.NET container to a container registry using Visual Studio
Docker is a lightweight container engine, similar in some ways to a virtual machine, which you can use to host applications and services. This tutorial walks you through using Visual Studio to publish your containerized application to an Azure Container Registry.
If you don't have an Azure subscription, create a free account before you begin.
Prerequisites
To complete this tutorial:
- Install the latest version of Visual Studio 2019 with the "ASP.NET and web development" workload
- Install Docker Desktop for Windows
- Install the latest version of Visual Studio 2022 with the "ASP.NET and web development" workload
- Install Docker Desktop for Windows
Create an ASP.NET Core web app
The following steps guide you through creating a basic ASP.NET Core app that will be used in this tutorial. If you already have a project, you can skip this section.
In the Visual Studio start window, select Create a new project.
Select ASP.NET Core Web App, and then select Next.
Enter a name for your new application (or use the default name), specify the location on disk, and then select Next.
Choose the .NET version you want to target. If you don't know, choose the LTS (long-term support) release.
Choose whether you want SSL support by selecting or clearing the Configure for HTTPS checkbox.
Select the Enable Docker Support checkbox.
Select the type of container you want (Windows or Linux), and then select Create.
In the Visual Studio start window, select Create a new project.
Select ASP.NET Core Web App, and then select Next.
Enter a name for your new application (or use the default name), specify the location on disk, and then select Next.
Choose the .NET version you want to target. If you don't know, choose the LTS (long-term support) release.
Choose whether you want SSL support by selecting or clearing the Configure for HTTPS checkbox.
Select the Enable Docker checkbox.
In the Docker OS textbox, select the type of container you want (Windows or Linux), and then select Create.
Publish your container to Azure Container Registry
Right-click your project in Solution Explorer and choose Publish.
On the Publish dialog, select Docker Container Registry.
Choose Create New Azure Container Registry.
Fill in your desired values in the Azure Container Registry screen.
Setting Suggested value Description DNS Prefix Globally unique name Name that uniquely identifies your container registry. Subscription Choose your subscription The Azure subscription to use. Resource Group myResourceGroup Name of the resource group in which to create your container registry. Choose New to create a new resource group. SKU Standard Service tier of the container registry Registry Location A location close to you Choose a Location in a region near you or near other services that will use your container registry. Click Create.
Choose Finish to complete the process.
Publish your container to Azure Container Registry
Right-click your project in Solution Explorer and choose Publish.
On the Publish dialog, select Docker Container Registry.
Choose Create New Azure Container Registry.
Fill in your desired values in the Azure Container Registry screen.
Setting Suggested value Description DNS Prefix Globally unique name Name that uniquely identifies your container registry. Subscription Choose your subscription The Azure subscription to use. Resource Group myResourceGroup Name of the resource group in which to create your container registry. Choose New to create a new resource group. SKU Standard Service tier of the container registry Registry Location A location close to you Choose a Location in a region near you or near other services that will use your container registry. Click Create.
Choose Finish to complete the process.
You can now pull the container from the registry to any host capable of running Docker images, for example Azure Container Instances.
Related content
Quickstart: Deploy a container instance in Azure using the Azure CLI
Feedback
https://aka.ms/ContentUserFeedback.
Coming soon: Throughout 2024 we will be phasing out GitHub Issues as the feedback mechanism for content and replacing it with a new feedback system. For more information see:Submit and view feedback for