Deploy an app into a container in Azure or Docker Hub

You can deploy a .NET 7 or later app without Docker Desktop or a Dockerfile. Visual Studio provides a deployment option that handles this conveniently for you.

Prerequisites

You don't need Docker Desktop.

Deploy to Docker Hub

  1. Right-click on the project node and choose Publish.

    Screenshot of Publish screen.

  2. Choose Docker Container Registry, and then Docker Hub.

    Screenshot showing Docker Container Registry publish option.

  3. Provide your Docker username and password. You can skip the password, if it's in the docker.config file.

    Screenshot of Docker credentials screen.

Deploy to Azure Container Registry

  1. Right-click on the project node and choose Publish.

    Screenshot of Publish screen, choosing Docker Container Registry.

  2. Choose Docker Container Registry, and then Azure Container Registry.

    Screenshot of Publish screen, choosing Azure Container Registry.

The app is deployed to Azure Container Registry, and Visual Studio creates a publish profile for the selected deployment target.

Deploy to Azure Container Apps

If you have an ASP.NET Core 7 or later project, you can deploy it to Azure Container Apps.

  1. Right-click on the project node and choose Publish, then Azure.

  2. Choose Azure Container Apps (Linux).

    Screenshot of Publish screen with Azure Container Apps (Linux) selected.

  3. Choose an existing container app or create a new one.

    Screenshot showing choosing a container app.

    If you create a new one, review and modify the default app name, resource group, location, environment, and container name, and choose Create. It might take some time to create the resources in Azure.

    Screenshot showing creating a new Azure Container App.

  4. Choose Finish and wait for the container app to be created. If you see a message box about enabling the Admin user on the container instance, you'll need to accept this to continue.

    Screenshot asking for permissions to add the Admin user to the container instance.

When the container app has been created, Visual Studio creates a publish profile (.pubxml file) and displays the settings on the Publish tab.

Screenshot of publish profile.

You can access the containerized web site online using the Site link.

Next time you want to publish using the same target and settings, you can use the Publish button on this screen. If you want to publish using different settings, use the New button. You can repeat the entire process and save the target and other settings in a separate .pubxml file.

Clean up resources

To clean up resources, use the Azure portal or use the Azure CLI or Azure PowerShell to delete the resource group, if you created one, or delete the resources individually.

Learn more about: