Azure App Service provides pre-defined application stacks on Windows like ASP.NET or Node.js, running on IIS. The preconfigured Windows environment locks down the operating system from administrative access, software installations, changes to the global assembly cache, and so on (see Operating system functionality on Azure App Service). However, using a custom Windows container in App Service lets you make OS changes that your app needs, so it’s easy to migrate on-premises app that requires custom OS and software configuration. This tutorial demonstrates how to migrate to App Service an ASP.NET app that uses custom fonts installed in the Windows font library. You deploy a custom-configured Windows image from Visual Studio to Azure Container Registry, and then run it in App Service.
To complete this tutorial:
Set up the app locally
Download the sample
In this step, you set up the local .NET project.
The sample project contains a simple ASP.NET application that uses a custom font that is installed into the Windows font library. It’s not necessary to install fonts, but it’s an example of an app that is integrated with the underlying OS. To migrate such an app to App Service, you either rearchitect your code to remove the integration, or migrate it as-is in a custom Windows container.
Install the font
In Windows Explorer, navigate to custom-font-win-container-master/CustomFontSample, right-click FrederickatheGreat-Regular.ttf, and select Install.
This font is publicly available from Google Fonts.
Run the app
Open the custom-font-win-container/CustomFontSample.sln file in Visual Studio.
Ctrl+F5 to run the app without debugging. The app is displayed in your default browser.
Because it uses an installed font, the app can’t run in the App Service sandbox. However, you can deploy it using a Windows container instead, because you can install the font in the Windows container.
Configure Windows container
In Solution Explorer, right-click the CustomFontSample project and select Add > Container Orchestration Support.
Select Docker Compose > OK.
Your project is now set up to run in a Windows container. A Dockerfile is added to the CustomFontSample project, and a docker-compose project is added to the solution.
From the Solution Explorer, open Dockerfile.
You need to use a supported parent image. Change the parent image by replacing the
FROM line with the following code:
At the end of the file, add the following line and save the file:
You can find InstallFont.ps1 in the CustomFontSample project. It’s a simple script that installs the font. You can find a more complex version of the script in the Script Center.
Publish to Azure Container Registry
Open publish wizard
In the Solution Explorer, right-click the CustomFontSample project and select Publish.
Create registry and publish
In the publish wizard, select Container Registry > Create New Azure Container Registry > Publish.
Sign in with Azure account
In the Create a new Azure Container Registry dialog, select Add an account, and sign in to your Azure subscription. If you’re already signed in, select the account containing the desired subscription from the dropdown.
Configure the registry
Configure the new container registry based on the suggested values in the following table. When finished, click Create.
|Setting||Suggested value||For more information|
|DNS Prefix||Keep the generated registry name, or change it to another unique name.|
|Resource Group||Click New, type myResourceGroup, and click OK.|
|Registry Location||West Europe|
A terminal window is opened and displays the image deployment progress. Wait for the deployment to complete.
Sign in to Azure
Sign in to the Azure portal at https://portal.azure.com.
Create a web app
From the left menu, select Create a resource > Web > Web App for Containers.
Configure the new web app
In the create interface, configure the settings according to the following table:
|Setting||Suggested value||For more information|
|App Name||Type a unique name.||The URL of the web app is
|Resource Group||Select Use existing and type myResourceGroup.|
Configure App Service plan
Click App Service plan/Location > Create new. Give the new plan a name, select West Europe as the location, and click OK.
Click Configure container > Azure Container Registry. Select the registry, image, and tag you created earlier in Publish to Azure Container Registry, and click OK.
Complete app creation
Click Create and wait for Azure to create the required resources.
Browse to the web app
When the Azure operation is complete, a notification box is displayed.
Click Go to resource.
In the app page, click the link under URL.
A new browser page is opened to the following page:
Wait a few minutes and try again, until you get the homepage with the beautiful font you expect:
Congratulations! You’ve migrated an ASP.NET application to Azure App Service in a Windows container.
See container start-up logs
It may take some time for the Windows container to load. To see the progress, navigate to the following URL by replacing <app_name> with the name of your app.
The streamed logs looks like this:
۱۴/۰۹/۲۰۱۸ ۲۳:۱۶:۱۹٫۸۸۹ INFO - Site: fonts-win-container - Creating container for image: customfontsample20180914115836.azurecr.io/customfontsample:latest. ۱۴/۰۹/۲۰۱۸ ۲۳:۱۶:۱۹٫۹۲۸ INFO - Site: fonts-win-container - Create container for image: customfontsample20180914115836.azurecr.io/customfontsample:latest succeeded. Container Id 329ecfedbe370f1d99857da7352a7633366b878607994ff1334461e44e6f5418 ۱۴/۰۹/۲۰۱۸ ۲۳:۱۷:۲۳٫۴۰۵ INFO - Site: fonts-win-container - Start container succeeded. Container: 329ecfedbe370f1d99857da7352a7633366b878607994ff1334461e44e6f5418 ۱۴/۰۹/۲۰۱۸ ۲۳:۱۷:۲۸٫۶۳۷ INFO - Site: fonts-win-container - Container ready ۱۴/۰۹/۲۰۱۸ ۲۳:۱۷:۲۸٫۶۳۷ INFO - Site: fonts-win-container - Configuring container ۱۴/۰۹/۲۰۱۸ ۲۳:۱۸:۰۳٫۸۲۳ INFO - Site: fonts-win-container - Container ready ۱۴/۰۹/۲۰۱۸ ۲۳:۱۸:۰۳٫۸۲۳ INFO - Site: fonts-win-container - Container start-up and configuration completed successfully