Note
Access to this page requires authorization. You can try signing in or changing directories.
Access to this page requires authorization. You can try changing directories.
Important
Azure App Service on Arc enabled Kubernetes will be retired on March 31, 2026. From September 30, 2025, customers will no longer be able to install the extension. We request you migrate to other solutions such as Azure Container Apps on Arc enabled Kubernetes, migrating also allows you to take advantage of Logic Apps Hybrid for your integration workloads.
If you have an Azure Arc-enabled Kubernetes cluster, you can use it to create an App Service enabled custom location and deploy web apps, function apps, and logic apps to it.
Azure Arc-enabled Kubernetes lets you make your on-premises or cloud Kubernetes cluster visible to App Service, Functions, and Logic Apps in Azure. You can create an app and deploy to it just like another Azure region.
Prerequisites
- If you don't have an Azure account, sign up today for a free account.
- Review the requirements and limitations of the public preview. Of particular importance are the cluster requirements.
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 connectedk8s
az extension add --upgrade --yes --name k8s-extension
az extension add --upgrade --yes --name customlocation
az provider register --namespace Microsoft.ExtendedLocation --wait
az provider register --namespace Microsoft.Web --wait
az provider register --namespace Microsoft.KubernetesConfiguration --wait
az extension remove --name appservice-kube
az extension add --upgrade --yes --name appservice-kube
Create a connected cluster
Note
This tutorial uses Azure Kubernetes Service (AKS) to provide concrete instructions for setting up an environment from scratch. However, for a production workload, you will likely not want to enable Azure Arc on an AKS cluster as it is already managed in Azure. The steps will help you get started understanding the service, but for production deployments, they should be viewed as illustrative, not prescriptive. See Quickstart: Connect an existing Kubernetes cluster to Azure Arc for general instructions on creating an Azure Arc-enabled Kubernetes cluster.
To create a connected cluster:
- Create a cluster in Azure Kubernetes Service with a public IP address. Replace - <group-name>with the resource group name you want.- AKS_CLUSTER_GROUP_NAME="<group-name>" # Name of resource group for the AKS cluster AKS_NAME="${aksClusterGroupName}-aks" # Name of the AKS cluster RESOURCE_LOCATION="eastus" # "eastus" or "westeurope" az group create -g $AKS_CLUSTER_GROUP_NAME -l $RESOURCE_LOCATION az aks create --resource-group $AKS_CLUSTER_GROUP_NAME --name $AKS_NAME --enable-aad --generate-ssh-keys
- Get the kubeconfig file and test your connection to the cluster. By default, the kubeconfig file is saved to - ~/.kube/config.- az aks get-credentials --resource-group $AKS_CLUSTER_GROUP_NAME --name $AKS_NAME --admin kubectl get ns
- Create a resource group to contain your Azure Arc resources. Replace - <group-name>with the resource group name you want.- GROUP_NAME="<group-name>" # Name of resource group for the connected cluster az group create -g $GROUP_NAME -l $RESOURCE_LOCATION
- Connect the cluster you created to Azure Arc. - CLUSTER_NAME="${GROUP_NAME}-cluster" # Name of the connected cluster resource az connectedk8s connect --resource-group $GROUP_NAME --name $CLUSTER_NAME
- Validate the connection with the following command. It should show the - provisioningStateproperty as- Succeeded. If not, run the command again after a minute.- az connectedk8s show --resource-group $GROUP_NAME --name $CLUSTER_NAME
Create a Log Analytics workspace
While a Log Analytic workspace is not required to run App Service in Azure Arc, it's how developers can get application logs for their apps that are running in the Azure Arc-enabled Kubernetes cluster.
- For simplicity, create the workspace now. - WORKSPACE_NAME="$GROUP_NAME-workspace" # Name of the Log Analytics workspace az monitor log-analytics workspace create \ --resource-group $GROUP_NAME \ --workspace-name $WORKSPACE_NAME
- Run the following commands to get the encoded workspace ID and shared key for an existing Log Analytics workspace. You need them in the next step. - LOG_ANALYTICS_WORKSPACE_ID=$(az monitor log-analytics workspace show \ --resource-group $GROUP_NAME \ --workspace-name $WORKSPACE_NAME \ --query customerId \ --output tsv) LOG_ANALYTICS_WORKSPACE_ID_ENC=$(printf %s $LOG_ANALYTICS_WORKSPACE_ID | base64 -w0) # Needed for the next step LOG_ANALYTICS_KEY=$(az monitor log-analytics workspace get-shared-keys \ --resource-group $GROUP_NAME \ --workspace-name $WORKSPACE_NAME \ --query primarySharedKey \ --output tsv) LOG_ANALYTICS_KEY_ENC=$(printf %s $LOG_ANALYTICS_KEY | base64 -w0) # Needed for the next step
Install the App Service extension
To install the App Service extension:
- Set the following environment variables for the desired name of the App Service extension, the cluster namespace in which resources should be provisioned, and the name for the App Service Kubernetes environment. Choose a unique name for - <kube-environment-name>, because it is part of the domain name for app created in the App Service Kubernetes environment.- EXTENSION_NAME="appservice-ext" # Name of the App Service extension NAMESPACE="appservice-ns" # Namespace in your cluster to install the extension and provision resources KUBE_ENVIRONMENT_NAME="<kube-environment-name>" # Name of the App Service Kubernetes environment resource
- Install the App Service extension to your Azure Arc-connected cluster, with Log Analytics enabled. Again, while Log Analytics is not required, you can't add it to the extension later, so it's easier to do it now. - az k8s-extension create \ --resource-group $GROUP_NAME \ --name $EXTENSION_NAME \ --cluster-type connectedClusters \ --cluster-name $CLUSTER_NAME \ --extension-type 'Microsoft.Web.Appservice' \ --release-train stable \ --auto-upgrade-minor-version true \ --scope cluster \ --release-namespace $NAMESPACE \ --configuration-settings "Microsoft.CustomLocation.ServiceAccount=default" \ --configuration-settings "appsNamespace=${NAMESPACE}" \ --configuration-settings "clusterName=${KUBE_ENVIRONMENT_NAME}" \ --configuration-settings "keda.enabled=true" \ --configuration-settings "buildService.storageClassName=default" \ --configuration-settings "buildService.storageAccessMode=ReadWriteOnce" \ --configuration-settings "customConfigMap=${NAMESPACE}/kube-environment-config" \ --configuration-settings "envoy.annotations.service.beta.kubernetes.io/azure-load-balancer-resource-group=${aksClusterGroupName}" \ --configuration-settings "logProcessor.appLogs.destination=log-analytics" \ --config-protected-settings "logProcessor.appLogs.logAnalyticsConfig.customerId=${LOG_ANALYTICS_WORKSPACE_ID_ENC}" \ --config-protected-settings "logProcessor.appLogs.logAnalyticsConfig.sharedKey=${LOG_ANALYTICS_KEY_ENC}"- Note - To install the extension without Log Analytics integration, remove the last three - --configuration-settingsparameters from the command.- The following table describes the various - --configuration-settingsparameters when running the command:- Parameter - Description - Microsoft.CustomLocation.ServiceAccount- The service account that should be created for the custom location that is created. It is recommended that this be set to the value - default.- appsNamespace- The namespace to provision the app definitions and pods. Must match that of the extension release namespace. - clusterName- The name of the App Service Kubernetes environment that is created against this extension. - keda.enabled- Whether KEDA should be installed on the Kubernetes cluster. Accepts - trueor- false.- buildService.storageClassName- The name of the storage class for the build service to store build artifacts. A value like - defaultspecifies a class named- default, and not any class that is marked as default. Default is a valid storage class for AKS and AKS on Azure Local but it may not be for other distributions/platforms.- buildService.storageAccessMode- The access mode to use with the named storage class. Accepts - ReadWriteOnceor- ReadWriteMany.- customConfigMap- The name of the config map that will be set by the App Service Kubernetes environment. Currently, it must be - <namespace>/kube-environment-config, replacing- <namespace>with the value of- appsNamespace.- envoy.annotations.service.beta.kubernetes.io/azure-load-balancer-resource-group- The name of the resource group in which the Azure Kubernetes Service cluster resides. Valid and required only when the underlying cluster is Azure Kubernetes Service. - logProcessor.appLogs.destination- Optional. Accepts - log-analyticsor- none, choosing none disables platform logs.- logProcessor.appLogs.logAnalyticsConfig.customerId- Required only when - logProcessor.appLogs.destinationis set to- log-analytics. The base64-encoded Log analytics workspace ID. This parameter should be configured as a protected setting.- logProcessor.appLogs.logAnalyticsConfig.sharedKey- Required only when - logProcessor.appLogs.destinationis set to- log-analytics. The base64-encoded Log analytics workspace shared key. This parameter should be configured as a protected setting.
- Save the - idproperty of the App Service extension for later.- EXTENSION_ID=$(az k8s-extension show \ --cluster-type connectedClusters \ --cluster-name $CLUSTER_NAME \ --resource-group $GROUP_NAME \ --name $EXTENSION_NAME \ --query id \ --output tsv)
- Wait for the extension to fully install before proceeding. You can have your terminal session wait until this complete by running the following command: - az resource wait --ids $EXTENSION_ID --custom "properties.installState!='Pending'" --api-version "2020-07-01-preview"
You can use kubectl to see the pods created in your Kubernetes cluster:
kubectl get pods -n $NAMESPACE
You can learn more about these pods and their role in the system from Pods created by the App Service extension.
Create a custom location
The custom location in Azure is used to assign the App Service Kubernetes environment.
- Set the following environment variables for the desired name of the custom location and for the ID of the Azure Arc-connected cluster. - CUSTOM_LOCATION_NAME="my-custom-location" # Name of the custom location CONNECTED_CLUSTER_ID=$(az connectedk8s show --resource-group $GROUP_NAME --name $CLUSTER_NAME --query id --output tsv)
- Create the custom location: - az customlocation create \ --resource-group $GROUP_NAME \ --name $CUSTOM_LOCATION_NAME \ --host-resource-id $CONNECTED_CLUSTER_ID \ --namespace $NAMESPACE \ --cluster-extension-ids $EXTENSION_ID- Note - If you experience issues creating a custom location on your cluster, you may need to enable the custom location feature on your cluster. This is required if logged into the CLI using a Service Principal or if you are logged in with a Microsoft Entra user with restricted permissions on the cluster resource. 
- Validate that the custom location is successfully created with the following command. The output should show the - provisioningStateproperty as- Succeeded. If not, run it again after a minute.- az customlocation show --resource-group $GROUP_NAME --name $CUSTOM_LOCATION_NAME
- Save the custom location ID for the next step. - CUSTOM_LOCATION_ID=$(az customlocation show \ --resource-group $GROUP_NAME \ --name $CUSTOM_LOCATION_NAME \ --query id \ --output tsv)
Create the App Service Kubernetes environment
Before you can start creating apps on the custom location, you need an App Service Kubernetes environment.
- Create the App Service Kubernetes environment: - az appservice kube create \ --resource-group $GROUP_NAME \ --name $KUBE_ENVIRONMENT_NAME \ --custom-location $CUSTOM_LOCATION_ID
- Validate that the App Service Kubernetes environment is successfully created with the following command. The output should show the - provisioningStateproperty as- Succeeded. If not, run it again after a minute.- az appservice kube show --resource-group $GROUP_NAME --name $KUBE_ENVIRONMENT_NAME
