Skip to content
Permalink
Browse files

deploy

  • Loading branch information
mbcrump committed Dec 1, 2019
1 parent 93ff061 commit ba645f7397f0bd9b9803a3165b35658314f5f273
BIN +0 Bytes (100%) .DS_Store
Binary file not shown.
@@ -32,12 +32,12 @@ module.exports = {
{
title: 'Recently Added',
collapsable: false,
children: ['/blog/tip235','/blog/tip234','/blog/tip233','/blog/tip232','/blog/tip231','/blog/tip230','/blog/tip229','/blog/tip228','/blog/tip227','/blog/tip226','/blog/tip225','/blog/tip224','/blog/tip223','/blog/tip222','/blog/tip221','/blog/tip220']
children: ['/blog/tip236','/blog/tip235','/blog/tip234','/blog/tip233','/blog/tip232','/blog/tip231','/blog/tip230','/blog/tip229','/blog/tip228','/blog/tip227','/blog/tip226','/blog/tip225','/blog/tip224','/blog/tip223','/blog/tip222','/blog/tip221','/blog/tip220']
},
{
title: 'App Service',
collapsable: true,
children: ['/blog/tip232','/blog/tip218','/blog/tip216','/blog/tip208','/blog/tip16', '/blog/tip20', '/blog/tip21', '/blog/tip22', '/blog/tip23', '/blog/tip26', '/blog/tip27', '/blog/tip28', '/blog/tip29', '/blog/tip30', '/blog/tip31', '/blog/tip32', '/blog/tip33',
children: ['/blog/tip236','/blog/tip232','/blog/tip218','/blog/tip216','/blog/tip208','/blog/tip16', '/blog/tip20', '/blog/tip21', '/blog/tip22', '/blog/tip23', '/blog/tip26', '/blog/tip27', '/blog/tip28', '/blog/tip29', '/blog/tip30', '/blog/tip31', '/blog/tip32', '/blog/tip33',
'/blog/tip101', '/blog/tip102', '/blog/tip103', '/blog/tip104', '/blog/tip105', '/blog/tip107', '/blog/tip108', '/blog/tip109', '/blog/tip110',
'/blog/tip112', '/blog/tip113', '/blog/tip117', '/blog/tip119', '/blog/tip132', '/blog/tip143',
'/blog/tip144', '/blog/tip149', '/blog/tip184']
@@ -86,7 +86,7 @@ module.exports = {
{
title: 'Containers',
collapsable: true,
children: ['/blog/tip45', '/blog/tip46', '/blog/tip47', '/blog/tip48', '/blog/tip54', '/blog/tip55', '/blog/tip56', '/blog/tip57', '/blog/tip58', '/blog/tip60']
children: ['/blog/tip236','/blog/tip45', '/blog/tip46', '/blog/tip47', '/blog/tip48', '/blog/tip54', '/blog/tip55', '/blog/tip56', '/blog/tip57', '/blog/tip58', '/blog/tip60']
},
{
title: 'Cosmos DB',
BIN +0 Bytes (100%) .vuepress/public/.DS_Store
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
@@ -11,7 +11,7 @@ date: 2019-11-17 02:00:00

:free: Grab your FREE [Azure Stickers](https://get.printfection.com/mbcrump/3960040838) now! Limited to first 10 folks!

:fire: Make sure you [star the repo](http://azuredev.tips?WT.mc_id=azure-azuredevtips-micrum) to keep up to date with new tips and tricks.
:tv: Watch the video : [How to Availability Zones for your Kubernetes cluster in Azure](https://www.youtube.com/watch?v=M5y92imCkh0&list=PLLasX02E8BPCNCK8Thcxu-Y-XcBUbhFWC&index=4?WT.mc_id=youtube-azuredevtips-micrum).

:bulb: Learn more : [Create an Azure Kubernetes Service (AKS) cluster that uses Availability Zones](https://docs.microsoft.com/azure/aks/availability-zones?WT.mc_id=docs-azuredevtips-micrum).

@@ -0,0 +1,110 @@
---
type: post
title: "Tip 236 - Deploy your web app in Windows Containers on Azure App Service"
excerpt: "Learn how to deploy your web app in Windows Containers on Azure App Service"
tags: [azure, webapp, containers, appservice, containerregistry]
share: true
date: 2019-12-01 02:00:00
---

::: tip

:free: Grab your FREE [Azure Stickers](https://get.printfection.com/mbcrump/3960040838) now! Limited to first 10 folks!

:tv: Watch the video : [How to deploy your web app in Windows Containers on Azure App Service](https://www.youtube.com/watch?v=d5omcL6z9dI&list=PLLasX02E8BPCNCK8Thcxu-Y-XcBUbhFWC&index=2?WT.mc_id=youtube-azuredevtips-micrum).

:bulb: Learn more : [Run a custom Windows container in Azure ](https://docs.microsoft.com/azure/app-service/app-service-web-get-started-windows-container?WT.mc_id=docs-azuredevtips-micrum).

:::

#### 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](https://azure.microsoft.com/services/app-service/web/?WT.mc_id=azure-azuredevtips-micrum). 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](https://azure.microsoft.com/services/virtual-machines/?WT.mc_id=azure-azuredevtips-micrum) or in [Azure Cloud Services](https://azure.microsoft.com/services/cloud-services/?WT.mc_id=azure-azuredevtips-micrum). Now, you can run such an application in a [Windows Container in an Azure App Service Web App](https://docs.microsoft.com/azure/app-service/app-service-web-get-started-windows-container?WT.mc_id=docs-azuredevtips-micrum). This enables you to use features like [automatic scaling](https://docs.microsoft.com/azure/app-service/manage-scale-up?WT.mc_id=docs-azuredevtips-micrum), [deployment slots](https://docs.microsoft.com/azure/app-service/deploy-staging-slots?WT.mc_id=docs-azuredevtips-micrum), [testing in production](https://www.youtube.com/watch?v=MP8fXgxq6xo) and [easy authentication and authorization](https://docs.microsoft.com/azure/app-service/overview-authentication-authorization?WT.mc_id=docs-azuredevtips-micrum).

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:
* An Azure subscription (If you don't have an Azure subscription, create a [free account](https://azure.microsoft.com/free/?WT.mc_id=azure-azuredevtips-micrum) before you begin)
* You'll need the [latest version of Visual Studio 2019](https://visualstudio.microsoft.com/downloads/?WT.mc_id=microsoft-azuredevtips-micrum) with the Azure workload installed
* You need Docker on your PC to develop container-based applications. Download it [here](https://store.docker.com/editions/community/docker-ce-desktop-windows)
* Your local Docker engine needs to be set to run **Windows Containers**
* You need an existing ASP.NET Forms application that runs on the .NET Framework 4.5 or higher

#### 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

<img :src="$withBase('/files/35adddockersupport.png')">

(Adding Docker support in Visual Studio)

2. 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](https://azure.microsoft.com/services/container-registry/?WT.mc_id=azure-azuredevtips-micrum) to store the image but you can also use something like [Docker Hub](https://hub.docker.com/). **Right-click the project file** and click **Publish**. This will start the publish wizard

<img :src="$withBase('/files/35publishtoregistry1.png')">

(Publish wizard in Visual Studio)

3. Choose **"Create a new Azure Container Registry"** and click **Publish**
4. 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

<img :src="$withBase('/files/35publishtoregistry2.png')">

(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](https://portal.azure.com/?WT.mc_id=azure-azuredevtips-micrum)
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**

<img :src="$withBase('/files/35createwebapp.png')">

(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

<img :src="$withBase('/files/35createwebapp2.png')">

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

<img :src="$withBase('/files/35resultwaiting.png')">

(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**.

<img :src="$withBase('/files/35containerlogs.png')">

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

<img :src="$withBase('/files/35result.png')">

(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](https://docs.microsoft.com/azure/app-service/app-service-web-get-started-windows-container?WT.mc_id=docs-azuredevtips-micrum). This give you control and a lot of cloud-only functionality, like [automatic scaling](https://docs.microsoft.com/azure/app-service/manage-scale-up?WT.mc_id=docs-azuredevtips-micrum), [deployment slots](https://docs.microsoft.com/azure/app-service/deploy-staging-slots?WT.mc_id=docs-azuredevtips-micrum), [testing in production](https://www.youtube.com/watch?v=MP8fXgxq6xo) and [easy authentication and authorization](https://docs.microsoft.com/azure/app-service/overview-authentication-authorization?WT.mc_id=docs-azuredevtips-micrum). Go check it out!

0 comments on commit ba645f7

Please sign in to comment.
You can’t perform that action at this time.