Edit

Deploy Managed Instance on Azure App Service

Managed Instance on Azure App Service combines the simplicity of platform as a service with the flexibility of infrastructure-level control. Managed Instance is designed for applications that require OS customization, private networking, and secure integration with Azure services.

Important

Managed Instance is generally available for Windows web apps in select regions and is limited to Pv4 and Pmv4 pricing plans. Microsoft will add more regions over time. Managed Instance doesn't support Linux and containers.

In this quickstart, you complete the following steps:

  1. Use Azure Developer CLI to deploy sample resources.
  2. Create a Managed Instance on Azure App Service.
  3. Deploy a sample app.
  4. Verify the deployment.

Prerequisites

  • Azure account: You need an Azure account with an active subscription. If you don't already have one, you can create an account for free.

  • Managed identity

  • Quickstart: Upload, download, and list blobs with the Azure portal

  • Optional configuration (install) script: This quickstart uses a PowerShell script named Install.ps1 in a compressed .zip file to install fonts. Configuration scripts aren't mandatory for Managed Instance. Use a configuration script when your application requires dependencies, operating system-level roles, features, or configuration, or persistent changes that would otherwise be lost after an instance restart. Use RDP for diagnostics rather than persistent configuration.

Deploy sample resources

You can quickly deploy all the necessary resources in this quickstart by using Azure Developer CLI (AZD). The AZD template used in this quickstart is from Azure samples.

mkdir managed-instance-quickstart
cd managed-instance-quickstart
azd init --template https://github.com/Azure-Samples/managed-instance-azure-app-service-quickstart.git .
azd env set AZURE_LOCATION northeurope
azd up

The azd up command does the following actions:

  1. Creates a user-assigned managed identity.
  2. Creates an Azure Storage Blob.
  3. Assigns the managed identity to the storage container and Managed Instance plan.
  4. Grants Storage-Blob-Data-Contributor access on the storage container.
  5. Compresses included fonts and Install.ps1 into scripts.zip.
  6. Upload scripts.zip to the storage container.

Note

The configuration script package (scripts.zip) deployed with the sample resources contains Install.ps1, which copies Microsoft Aptos font files into C:\Windows\Fonts. The sample app you deploy uses these fonts.

The following PowerShell code is the configuration (install) script used in the template.

# Install.ps1 - Copy and register fonts on Managed Instance
Write-Host "Installing custom fonts on Managed Instance..." -ForegroundColor Green

# Copy all TTF and OTF fonts to Windows Fonts folder and register them
Get-ChildItem -Recurse -Include *.ttf, *.otf | ForEach-Object {
    $FontFullName = $_.FullName
    $FontName = $_.BaseName + " (TrueType)"
    $Destination = "$env:windir\Fonts\$($_.Name)"

    Write-Host "Installing font: $($_.Name)"
    Copy-Item $FontFullName -Destination $Destination -Force
    New-ItemProperty -Path "HKLM:\SOFTWARE\Microsoft\Windows NT\CurrentVersion\Fonts" -Name $FontName -PropertyType String -Value $_.Name -Force | Out-Null
}

Write-Host "Font installation completed." -ForegroundColor Green

The final output of azd up should look similar to the following example.

=== Deployment Complete ===
Storage Account: stgpjqep6fdlfv6
Container Name: scripts
Managed Identity Client name: id-gpjqep6fdlfv6
Resource Group: rg-managed-instance

The values for Storage Account, Container Name, Managed Identity Client name, Resource Group, and Script URI are used later.

Deploy a Managed Instance plan

Follow these steps to create a Managed Instance plan and deploy an app to it:

  1. Sign in to the Azure portal.
  2. Select + Create a resource.
  3. Search for managed instance
  4. Select Web App (for Managed Instance) in the results.
  5. Select Create to start the create process.
  6. On the Basic tab, provide the following details.

Project details

Setting Value
Subscription Your Azure subscription
Resource Group rg-managed-instance

App details

Setting Value
Name contoso-mi-app
Runtime stack ASPNET V4.8
Region A region near you

Pricing plans

Setting Value
Windows Plan Use default plan or create new (for example, 'contoso-mi-plan')
Pricing plans* Select a pricing plan. If Pv4 or Pmv4 isn't visible in pricing plans, confirm region availability or request more quota.

On the Advanced tab, provide the following details.

Configuration (install) script

Setting Value
Storage Account Use default plan or create new (for example, 'contoso-mi-plan')
Container scripts
Zip file scripts.zip
Value Verify the .zip URL is correct
Identity Select the managed identity that was created earlier
  • Select Review + create and then select Create.

Deploy a sample app to Managed Instance

In this step, you use Cloud Shell to deploy a sample app that was included in the AZD template to Managed Instance.

  • The following command deploys the web app to your Managed Instance plan. Update <app-name> and <resource-group> with your values.
az webapp deploy \
  --resource-group "<resource-group-name>" \
  --name "<app-name>" \
  --src-path app.zip \
  --type zip

Browse to the app

To browse to the created app, select the default domain in the Overview page.

The .NET app is running on a Managed Instance plan. The app uses fonts from C:\Windows\Fonts directory.

Screenshot that shows the sample app using C:\Windows\Fonts\Aptos.TTF.

Manage the Managed Instance plan

To manage your web app, go to the Azure portal, and search for and select App Services.

On the App Services page, select the name of your web app.

On the Overview page, select the name of your App Service plan. Under Current App Service plan, select the plan name.

In the left menu under Settings, select Configuration to view the configuration details.

Clean up resources

In the preceding steps, you created Azure resources in a resource group. If you don't expect to need these resources in the future, you can delete them by deleting the resource group.

  1. From your web app's Overview page in the Azure portal, select the myResourceGroup link under Resource group.
  2. On the resource group page, make sure that the listed resources are the ones you want to delete.
  3. Select Delete resource group, type myResourceGroup in the text box, and then select Delete.
  4. Confirm again by selecting Delete.