Run a custom Windows container in Azure (Preview)

Azure App Service provides pre-defined application stacks on Windows like ASP.NET or Node.js, running on IIS. The preconfigured Windows environment locks down the operating system from administrative access, software installations, changes to the global assembly cache, and so on. For more information, see Operating system functionality on Azure App Service. If your application requires more access than the preconfigured environment allows, you can deploy a custom Windows container instead.

This quickstart shows how to deploy an ASP.NET app, in a Windows image, to Docker Hub from Visual Studio. You run the app in a custom container in Azure App Service.


To complete this tutorial:

Create an ASP.NET web app

Create an ASP.NET web app by following these steps:

  1. Open Visual Studio and then select Create a new project.

  2. In Create a new project, find and choose ASP.NET Web Application (.NET Framework) for C#, then select Next.

  3. In Configure your new project, name the application myfirstazurewebapp, and then select Create.

    Configure your web app project

  4. You can deploy any type of ASP.NET web app to Azure. For this quickstart, choose the MVC template.

  5. Select Docker support, and make sure authentication is set to No Authentication. Select Create.

    Create ASP.NET Web Application

  6. If the Dockerfile file isn't opened automatically, open it from the Solution Explorer.

  7. You need a supported parent image. Change the parent image by replacing the FROM line with the following code and save the file:

  8. From the Visual Studio menu, select Debug > Start Without Debugging to run the web app locally.

    Run app locally

Publish to Docker Hub

  1. In Solution Explorer, right-click the myfirstazurewebapp project and select Publish.

  2. Choose App Service and then select Publish.

  3. In Pick a publish target, select Container Registry and Docker Hub, and then click Publish.

    Publish from project overview page

  4. Supply your Docker Hub account credentials and select Save.

    Wait for the deployment to complete. The Publish page now shows the repository name to use later.

    Publish from project overview page

  5. Copy this repository name for later.

Create a Windows container app

  1. Sign in to the Azure portal.

  2. Choose Create a resource in the upper left-hand corner of the Azure portal.

  3. In the search box above the list of Azure Marketplace resources, search for Web App for Containers, and select Create.

  4. In Web App Create, choose your subscription and a Resource Group. You can create a new resource group if needed.

  5. Provide an app name, such as win-container-demo and choose Windows for Operating System. Select Next: Docker to continue.

    Create a Web App for Containers

  6. For Image Source, choose Docker Hub and for Image and tag, enter the repository name you copied in Publish to Docker Hub.

    Configure your a Web App for Containers

    If you have a custom image elsewhere for your web application, such as in Azure Container Registry or in any other private repository, you can configure it here.

  7. Select Review and Create and then Create and wait for Azure to create the required resources.

Browse to the container app

When the Azure operation is complete, a notification box is displayed.

Deployment succeeded

  1. Click Go to resource.

  2. In the overview of this resource, follow the link next to URL.

A new browser page opens to the following page:

Windows Container App Starting

Wait a few minutes and try again, until you get the default ASP.NET home page:

Windows Container App running

Congratulations! You're running your first custom Windows container in Azure App Service.

See container start-up logs

It may take some time for the Windows container to load. To see the progress, navigate to the following URL by replacing <app_name> with the name of your app.


The streamed logs looks like this:

2018-07-27T12:03:11  Welcome, you are now connected to log-streaming service.
27/07/2018 12:04:10.978 INFO - Site: win-container-demo - Start container succeeded. Container: facbf6cb214de86e58557a6d073396f640bbe2fdec88f8368695c8d1331fc94b
27/07/2018 12:04:16.767 INFO - Site: win-container-demo - Container start complete
27/07/2018 12:05:05.017 INFO - Site: win-container-demo - Container start complete
27/07/2018 12:05:05.020 INFO - Site: win-container-demo - Container started successfully

Update locally and redeploy

  1. In Visual Studio, in Solution Explorer, open Views > Home > Index.cshtml.

  2. Find the <div class="jumbotron"> HTML tag near the top, and replace the entire element with the following code:

    <div class="jumbotron">
        <h1>ASP.NET in Azure!</h1>
        <p class="lead">This is a simple app that we've built that demonstrates how to deploy a .NET app to Azure App Service.</p>
  3. To redeploy to Azure, right-click the myfirstazurewebapp project in Solution Explorer and choose Publish.

  4. On the publish page, select Publish and wait for publishing to complete.

  5. To tell App Service to pull in the new image from Docker Hub, restart the app. Back in the app page in the portal, click Restart > Yes.

    Restart web app in Azure

Browse to the container app again. As you refresh the webpage, the app should revert to the "Starting up" page at first, then display the updated webpage again after a few minutes.

Updated web app in Azure

Use a different parent image

You're free to use a different custom Docker image to run your app. However, you must choose the right parent image (base image) for the framework you want:

It takes some time to download a parent image during app start-up. However, you can reduce start-up time by using one of the following parent images that are already cached in Azure App Service:

Next steps