Windows Containers on Azure App Service Public Preview

2 minute read • August 8, 2018

Andrew Westgarth
This morning we announced the public preview of Windows Container support on Azure App Service Web App for Containers.  You can read the announcement blog, which covers the new capabilities and Dv3 powered SKUs, here - https://azure.microsoft.com/blog/announcing-the-public-preview-of-windows-container-support-in-azure-app-service/ This public preview will enable new opportunities for customers looking to modernize their existing applications.  For example here are the steps required to take an existing .Net Framework Web Forms application, containerise it, publish to Docker Hub and then deploy to App Service. Pre-Requisites: Visual Studio 2017 with .Net Core and Azure workloads installed Docker for Windows Docker Hub Account or an Azure Container Registry
  1. Create a new or open an existing ASP.Net Web Forms application in Visual Studio 2017
  2. Select the Web Forms project, go to the Project Menu and select "Docker Support".  If you do not see this option check that you have the .Net Core workload installed with the Visual Studio Installer [caption id="attachment_9135" align="aligncenter" width="300"]Add Docker Support to existing project Add Docker Support to existing project[/caption]
  3. Visual Studio will have created a new docker-compose project and added a Dockerfile to the Web Forms Project.  Open the Dockerfile:
    FROM microsoft/aspnet:4.7.1-windowsservercore-1709
    ARG source
    WORKDIR /inetpub/wwwroot
    COPY ${source:-obj/Docker/publish} .
  4. Change the FROM argument in the Dockerfile to point to a Windows Server 2016 Core base image from the Long Term Servicing Channel.  Should you wish to publish a .Net Core application in a Windows Container, use a Windows Server 2016 Nano base image from the Long Term Servicing Channel.  We cache certain images as listed in the announcement blog post to enable faster container deployment, for example here specify microsoft/aspnet:4.7.2-windowsservercore-ltsc2016:
    FROM microsoft/aspnet:4.7.2-windowsservercore-ltsc2016
    ARG source
    WORKDIR /inetpub/wwwroot
    COPY ${source:-obj/Docker/publish} .
  5. Build the project.
  6. Select the Web Application and right click Publish.
  7. As we are publishing the application in a container we need to publish to a Container Registry.  Visual Studio 2017 enables the publishing of containers to an Azure Container Registry, a private registry or Docker Hub.  In this example we're going to publish to Docker Hub, so select Container Registry, then choose Docker Hub and click Publish:
  8. When prompted enter your Docker Hub account username and password and click Save
  9. Once published take a note of the container image name and tag from the Output window. Output of Publish Operation
  10. Go to the Azure portal and sign in with your Azure subscription credentials
  11. Choose to Create a resource in the upper left-hand corner of the Azure portal.
  12. In the search box above the list of Azure Marketplace resources, search for and select Web App for Containers.
  13. Provide an app name, such as WindowsContainerHelloWorld, accept the defaults to create a new resource group, and click Windows (Preview) in the OS box.Create Web App For Windows Containers application
  14. Create an App Service plan by clicking App Service plan/Location > Create new. Give the new plan a name, accept the defaults, and click OKCreate Windows Container App Service Plan
  15. Click Configure container, type the username/image:tag that you noted in the output window earlier, for example, mydockerhub/myimage:latest in Image and optional tag, and click OK.
  16. Click Create and wait for Azure to create the required resources, you will be notified when the operation completes.  Click Go to resource in the notification box.
  17. In the application overview click Browse, you will see a page showing the container is starting up
  18. Refresh the page after a few minutes and you will see your ASP.Net Web Forms application running!

We want to hear from you!

Windows Container support for Azure App Service provides you with even more ways to build, migrate, deploy, and scale enterprise grade web and API applications running on the Windows platform. We are planning to add even more capabilities during the public preview and we are very interested in your feedback as we move towards general availability.