Deploy an existing .Net Web App to App Service using a Windows Container
Pre-Requisites:
- Visual Studio 2017 with .Net Core and Azure workloads installed
- Docker for Windows
- Docker Hub Account or an Azure Container Registry
- Create a new or open an existing ASP.Net Web Forms application in Visual Studio 2017
- 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
- 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} .
- 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`
- Build the project.
- 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:
- 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.
- Go to the [Azure portal](https://portal.azure.com) and sign in with your Azure subscription credentials
- Choose to Create a resource in the upper left-hand corner of the Azure portal.
- In the search box above the list of Azure Marketplace resources, search for and select Web App for Containers.
- 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.
-
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.
-
In the application overview click Browse, you will see a page showing the container is starting up
-
Refresh the page after a few minutes and you will see your ASP.Net Web Forms application running!
Deploy an existing .Net Web App to App Service using a Windows Container
How to use System Managed Identities to pull Windows Container Image
How to use User Assigned Managed Identities to pull Windows Container Image
Serve content from Azure Files share
.Net Application connecting to an Access Database
.Net Application using a custom culture (or any MSI/EXE)
.Net Application using a custom font
.Net 3.5 Application which connects to a MSMQ Server
Check out Windows Container Support on Azure App Service.