Deploy an ASP.NET container to a container registry using Visual Studio

Overview

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 2017with the "ASP.NET and web development" workload
  • Install the latest version of Visual Studio 2019 with the "ASP.NET and web development" workload

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.

  1. In the Visual Studio menu, select File > New > Project.
  2. In the Templates section of the New Project dialog box, select Visual C# > Web.
  3. Select ASP.NET Core Web Application.
  4. Enter a name for your new application (or use the default name), and then select OK.
  5. Select Web Application.
  6. Select the Enable Docker Support check box.
  7. Select the type of container you want (Windows or Linux), and then select OK.
  1. In the Visual Studio start window, select Create a new project.
  2. Select ASP.NET Core Web Application, and then select Next.
  3. Enter a name for your new application (or use the default name), and then select Create.
  4. Select Web Application.
  5. Choose whether you want SSL support by selecting or clearing the Configure for HTTPS check box.
  6. Select the Enable Docker Support check box.
  7. Select the type of container you want (Windows or Linux), and then select Create.

Publish your container to Azure Container Registry

  1. Right-click your project in Solution Explorer and choose Publish.

  2. On the publish target dialog, select the Container Registry tab.

  3. Choose New Azure Container Registry and click Publish.

  4. Fill in your desired values in the Create a new Azure Container Registry.

    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.

    Visual Studio's create Azure Container Registry dialog

  5. Click Create

You can now pull the container from the registry to any host capable of running Docker images, for example Azure Container Instances.