Skip to content

Deploy an existing .Net Web App to App Service using a Windows Container

Andrew Westgarth edited this page Sep 23, 2018 · 3 revisions

Pre-Requisites:

  1. Create a new or open an existing ASP.Net Web Forms application in Visual Studio 2017
  2. Select the Web Forms project, right click on the project in solution explorer and select Add Container Orchestration Support, choose Docker Compose. If you do not see this option check that you have the .Net Core workload installed with the Visual Studio Installer

Add Docker Support to existing project

  1. 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} .
  1. 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`
  1. Build the project.
  2. 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: Publish in Visual Studio
  3. When prompted enter your Docker Hub account username and password and click Save Once published take a note of the container image name and tag from the Output window. Output of Publish Operation
  4. Go to the [Azure portal](https://portal.azure.com) and sign in with your Azure subscription credentials
  5. Choose to Create a resource in the upper left-hand corner of the Azure portal.
  6. In the search box above the list of Azure Marketplace resources, search for and select Web App for Containers.
  7. 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 OK

Create 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.

  1. 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.

  2. In the application overview click Browse, you will see a page showing the container is starting up Web App Starting

  3. Refresh the page after a few minutes and you will see your ASP.Net Web Forms application running! Running web app