Create an App Service app on Azure Arc (Preview)

In this quickstart, you create an App Service app to an Azure Arc-enabled Kubernetes cluster (Preview). This scenario supports Linux apps only, and you can use a built-in language stack or a custom container.

Prerequisites

Add Azure CLI extensions

Launch the Bash environment in Azure Cloud Shell.

Because these CLI commands are not yet part of the core CLI set, add them with the following commands:

az extension add --upgrade --yes --name customlocation
az extension remove --name appservice-kube
az extension add --upgrade --yes --name appservice-kube

1. Create a resource group

Run the following command.

az group create --name myResourceGroup --location eastus 

2. Get the custom location

Get the following information about the custom location from your cluster administrator (see Create a custom location).

customLocationGroup="<resource-group-containing-custom-location>"
customLocationName="<name-of-custom-location>"

Get the custom location ID for the next step.

customLocationId=$(az customlocation show \
    --resource-group $customLocationGroup \
    --name $customLocationName \
    --query id \
    --output tsv)

3. Create an app

The following example creates a Node.js app. Replace <app-name> with a name that's unique within your cluster (valid characters are a-z, 0-9, and -).

Supported runtimes:

Description Runtime Value for CLI
.NET Core 3.1 DOTNETCORE|3.1
.NET 5.0 DOTNETCORE|6.0
Node JS 12 NODE|12-lts
Node JS 14 NODE|14-lts
Python 3.6 PYTHON|3.6
Python 3.7 PYTHON|3.7
Python 3.8 PYTHON|3.8
PHP 7.3 PHP|7.3
PHP 7.4 PHP|7.4
Java 8 JAVA|8-jre8
Java 11 JAVA|11-java11
Tomcat 8.5 TOMCAT|8.5-jre8
Tomcat 8.5 TOMCAT|8.5-java11
Tomcat 9.0 TOMCAT|9.0-jre8
Tomcat 9.0 TOMCAT|9.0-java11
 az webapp create \
    --resource-group myResourceGroup \
    --name <app-name> \
    --custom-location $customLocationId \
    --runtime 'NODE|14-lts'

4. Deploy some code

Note

az webapp up is not supported during the public preview.

Get a sample Node.js app using Git and deploy it using ZIP deploy. Replace <app-name> with your web app name.

git clone https://github.com/Azure-Samples/nodejs-docs-hello-world
cd nodejs-docs-hello-world
zip -r package.zip .
az webapp config appsettings set --resource-group myResourceGroup --name <app-name> --settings SCM_DO_BUILD_DURING_DEPLOYMENT=true
az webapp deploy --resource-group myResourceGroup --name <app-name> --src-path package.zip

5. Get diagnostic logs using Log Analytics

Note

To use Log Analytics, you should've previously enabled it when installing the App Service extension. If you installed the extension without Log Analytics, skip this step.

Navigate to the Log Analytics workspace that's configured with your App Service extension, then click Logs in the left navigation. Run the following sample query to show logs over the past 72 hours. Replace <app-name> with your web app name. If there's an error when running a query, try again in 10-15 minutes (there may be a delay for Log Analytics to start receiving logs from your application).

let StartTime = ago(72h);
let EndTime = now();
AppServiceConsoleLogs_CL
| where TimeGenerated between (StartTime .. EndTime)
| where AppName_s =~ "<app-name>"

The application logs for all the apps hosted in your Kubernetes cluster are logged to the Log Analytics workspace in the custom log table named AppServiceConsoleLogs_CL.

Log_s contains application logs for a given App Service and AppName_s contains the App Service app name. In addition to logs you write via your application code, the Log_s column also contains logs on container startup, shutdown, and Function Apps.

You can learn more about log queries in getting started with Kusto.

(Optional) Deploy a custom container

To create a custom containerized app, run az webapp create with --deployment-container-image-name. For a private repository, add --docker-registry-server-user and --docker-registry-server-password.

For example, try:

az webapp create \
    --resource-group myResourceGroup \
    --name <app-name> \
    --custom-location $customLocationId \
    --deployment-container-image-name mcr.microsoft.com/appsvc/staticsite:latest

To update the image after the app is create, see Change the Docker image of a custom container

Next steps