# Deploy your web app in Windows Containers on Azure App Service

# Running applications with dependencies on Azure App Service

Sometimes you have a web application that runs on the full .NET Framework and has dependencies to libraries and capabilities that aren't available in a service like Azure App Service Web App(opens new window) . Applications like this sometimes rely on things to be installed in the GAC (Global Assembly Cache). In the past, you could only run an application like that in Azure if you run it in IIS on a Virtual Machine(opens new window) or in Azure Cloud Services(opens new window) . Now, you can run such an application in a Windows Container in an Azure App Service Web App(opens new window) . This enables you to use features like automatic scaling(opens new window) , deployment slots(opens new window) , testing in production(opens new window) and easy authentication and authorization(opens new window) .

In this post, we'll containerize an existing ASP.NET Forms application and run that in a Windows Container in an Azure App Service Web App.

# Prerequisites

If you want to follow along, you'll need the following:

# Deploy your web app in Windows Containers on Azure App Service

Let's start by containerizing our existing application. I have an existing ASP.NET Forms web application that runs on .NET Framework 4.7. This is a very simple application and you crate your own by simply creating a new APS.NET Forms application in Visual Studio. Let's containerize it:

  1. In Visual Studio, right-click the project file and click Add > Docker Support a. This adds a Docker file that describes the container image that the application will run in. If you want, you can customize the Docker file

(Adding Docker support in Visual Studio)

  1. Next, publish the container image with the application in it to a container registry. From there, the image can be used by Azure services. We'll use Azure Container Registry(opens new window) to store the image but you can also use something like Docker Hub(opens new window) . Right-click the project file and click Publish. This will start the publish wizard

(Publish wizard in Visual Studio)

  1. Choose "Create a new Azure Container Registry" and click Publish
  2. The Create new Azure Container Registry screen opens: a. Type the DNS Prefix, which is the name for the registry and will be used for its URL b. Choose a Resource Group c. Pick a Location d. Click Create to create the Azure Container Registry and push the image to it. This will take a few minutes

(Create a new Azure Container Registry in Visual Studio)

Now that the container image is in an Azure Container Registry, we can use it to create a new App Service Web App and run the application in it.

  1. Go to the Azure portal(opens new window)

  2. Click the Create a resource button (the plus-sign in the top left corner)

  3. Click on Web App. This opens the Create Web App blade a. Under Resource Group, click Create new and fill in a name for the new Resource Group b. Fill in a Name for the Web App c. For the Publish setting, select Docker Image d. For the Operating System, select Windows e. Select a Region near the location of the Azure Container Registry. This will speed up the deployment process f. Click Next: Docker

    (Create Web App blade in the Azure portal)

    g. Select Azure Container Registry for the Image Source h. For Registry, select the container registry that we've created before i. For Image, select the image that we've pushed into the registry. This will be called something like mywebformsapp j. For Tag, select latest k. Click Review and Create and click Create in the next screen. This will create the Web App

    (Docker configuration of the Web App in the Azure portal)

When the Web App is created, go to it in the Azure portal. In the Overview blade, you'll see the Web App URL. Click on it to open it in a browser. This will show you a screen that says that the container is starting up.

(Web App's container is starting up)

It will take several minutes before the container starts. You can check what is going on in the background by going to the Web App in the Azure portal and looking at the Logs in the Container settings.

(Container logs in the Azure portal)

After a couple of minutes, try the Web App URL again in a browser to see the application in action, running in Azure.

(Application running in Azure)

# Conclusion

Sometimes, you need a lot of control over the environment that your app runs in. A container can give you that control, as it acts as a complete virtual environment in a sandbox. And now, you can run Windows Containers on Azure App Service Web App(opens new window) . This give you control and a lot of cloud-only functionality, like automatic scaling(opens new window) , deployment slots(opens new window) , testing in production(opens new window) and easy authentication and authorization(opens new window) . Go check it out!