|
| 1 | +--- |
| 2 | +title: "Deploy Arc-enabled workloads in an Extended Zone: ContainerApps" |
| 3 | +description: Learn how to deploy arc-enabled ContainerApps in an Extended Zone. |
| 4 | +author: svaldes |
| 5 | +ms.author: svaldes |
| 6 | +ms.service: azure-extended-zones |
| 7 | +ms.topic: how-to |
| 8 | +ms.date: 05/02/2025 |
| 9 | + |
| 10 | +# Customer intent: As a cloud administrator and Azure Extended Zones user, I want a quick method to deploy PaaS services via Arc in an Azure Extended Zone. |
| 11 | +--- |
| 12 | + |
| 13 | +# Deploy Arc-enabled workloads in an Extended Zone: ContainerApps |
| 14 | + |
| 15 | +In this article, you'll learn how to deploy an Arc-enabled ContainerApp in an Extended Zone. Refer to [What is Azure Extended Zones? | Services](/azure/extended-zones/overview#services) for currently supported PaaS workloads. |
| 16 | +Feel free to explore [Container Apps on Azure Arc Overview | Microsoft Learn](/azure/container-apps/azure-arc-overview) to become more familiar with Container Apps on Azure Arc. |
| 17 | + |
| 18 | +## Prerequisites |
| 19 | + |
| 20 | +- [An Azure account](https://azure.microsoft.com/free/?WT.mc_id=A261C142F) with an active subscription. |
| 21 | +- Install the [Azure CLI](/cli/azure/install-azure-cli). |
| 22 | +- Access to a public or private container registry, such as the [Azure Container Registry](/azure/container-registry/). |
| 23 | +- [An Azure Arc-enabled Kubernetes cluster set up in Extended Zones](/azure/extended-zones/arc-enabled-workloads-arc-enabled-aks-cluster). |
| 24 | +> [!NOTE] |
| 25 | +> Use the intended Extended Location as your location variable. |
| 26 | +
|
| 27 | +## Getting started |
| 28 | +If you're already familiar with the subject, you may skip this paragraph. Here are important topics you may want read before you proceed with creation: |
| 29 | +- [Requirements and limitations](/azure/container-apps/azure-arc-overview) of the public preview. Of particular importance are the cluster requirements. |
| 30 | +- [Overview of Azure Arc-enabled data services](/azure/azure-arc/data/overview) |
| 31 | +- [Connectivity modes and requirements](/azure/azure-arc/data/connectivity) |
| 32 | +- [Storage configuration and Kubernetes storage concepts](/azure/azure-arc/data/storage-configuration) |
| 33 | +- [Kubernetes resource model](https://github.com/kubernetes/design-proposals-archive/blob/main/scheduling/resources.md#resource-quantities) |
| 34 | + |
| 35 | +### Create Container Apps on Arc-enabled AKS in Extended Zones |
| 36 | + |
| 37 | +Now that the Arc-enabled AKS cluster is created, we can proceed to using the following PowerShell script to create our Container App on an AKS cluster in an Extended Zone and connect it to the Azure Arc-enabled Kubernetes. |
| 38 | + |
| 39 | +> [!NOTE] |
| 40 | +> Make sure to transfer the parameters from the Arc-enabled AKS steps correctly into the script. |
| 41 | + |
| 42 | +```powershell |
| 43 | +# . "./CreateArcEnabledAksOnEZ.ps1" |
| 44 | +
|
| 45 | +# Create a container app on an AKS cluster in an edge zone and connect it to Azure Arc-enabled Kubernetes |
| 46 | +function CreateContainerAppOnArcEnabledAksEz { |
| 47 | + param( |
| 48 | + [string] $AKSClusterResourceGroupName, |
| 49 | + [string] $location = "westus", |
| 50 | + [string] $AKSName, |
| 51 | + [string] $edgeZone, |
| 52 | + [int] $nodeCount = 2, |
| 53 | + [string] $vmSize = "standard_nv12ads_a10_v5", |
| 54 | + [string] $ArcResourceGroupName, |
| 55 | + [string] $CONNECTED_ENVIRONMENT_NAME, |
| 56 | + [string] $CUSTOM_LOCATION_NAME, |
| 57 | + [string] $SubscriptionId, |
| 58 | + [string] $ACRName, |
| 59 | + [string] $imageName, |
| 60 | + [switch] $Debug |
| 61 | + ) |
| 62 | +
|
| 63 | + try { |
| 64 | + # Set the subscription |
| 65 | + az account set --subscription $SubscriptionId |
| 66 | +
|
| 67 | + # Create the Arc-enabled EZ AKS cluster |
| 68 | + createArcEnabledAksOnEz -SubscriptionId $SubscriptionId -AKSClusterResourceGroupName $AKSClusterResourceGroupName -location $location -AKSName $AKSName -edgeZone $edgeZone -nodeCount $nodeCount -vmSize $vmSize -ArcResourceGroupName $ArcResourceGroupName -Debug:$Debug |
| 69 | +
|
| 70 | + # Install container apps extension |
| 71 | + $CLUSTER_NAME = "$ArcResourceGroupName-cluster" # Name of the connected cluster resource |
| 72 | + $EXTENSION_NAME="appenv-ext" |
| 73 | + $NAMESPACE="app-ns" |
| 74 | + az k8s-extension create ` |
| 75 | + --resource-group $ArcResourceGroupName ` |
| 76 | + --name $EXTENSION_NAME ` |
| 77 | + --cluster-type connectedClusters ` |
| 78 | + --cluster-name $CLUSTER_NAME ` |
| 79 | + --extension-type 'Microsoft.App.Environment' ` |
| 80 | + --release-train stable ` |
| 81 | + --auto-upgrade-minor-version true ` |
| 82 | + --scope cluster ` |
| 83 | + --release-namespace $NAMESPACE ` |
| 84 | + --configuration-settings "Microsoft.CustomLocation.ServiceAccount=default" ` |
| 85 | + --configuration-settings "appsNamespace=${NAMESPACE}" ` |
| 86 | + --configuration-settings "clusterName=${CONNECTED_ENVIRONMENT_NAME}" ` |
| 87 | + --configuration-settings "envoy.annotations.service.beta.kubernetes.io/azure-load-balancer-resource-group=${AKSClusterResourceGroupName}" |
| 88 | + |
| 89 | + # Save id property of the Container Apps extension for later |
| 90 | + $EXTENSION_ID=$(az k8s-extension show ` |
| 91 | + --cluster-type connectedClusters ` |
| 92 | + --cluster-name $CLUSTER_NAME ` |
| 93 | + --resource-group $ArcResourceGroupName ` |
| 94 | + --name $EXTENSION_NAME ` |
| 95 | + --query id ` |
| 96 | + --output tsv) |
| 97 | +
|
| 98 | + # Wait for extension to fully install before proceeding |
| 99 | + az resource wait --ids $EXTENSION_ID --custom "properties.provisioningState!='Pending'" --api-version "2020-07-01-preview" |
| 100 | + |
| 101 | + $CONNECTED_CLUSTER_ID=$(az connectedk8s show --resource-group $ArcResourceGroupName --name $CLUSTER_NAME --query id --output tsv) |
| 102 | + az customlocation create ` |
| 103 | + --resource-group $ArcResourceGroupName ` |
| 104 | + --name $CUSTOM_LOCATION_NAME ` |
| 105 | + --host-resource-id $CONNECTED_CLUSTER_ID ` |
| 106 | + --namespace $NAMESPACE ` |
| 107 | + --cluster-extension-ids $EXTENSION_ID |
| 108 | +
|
| 109 | + # DEBUG: Test custom location creation |
| 110 | + if ($Debug) { |
| 111 | + Write-Debug az customlocation show --resource-group $ArcResourceGroupName --name $CUSTOM_LOCATION_NAME |
| 112 | + } |
| 113 | +
|
| 114 | + # Save id property of the custom location for later |
| 115 | + $CUSTOM_LOCATION_ID=$(az customlocation show ` |
| 116 | + --resource-group $ArcResourceGroupName ` |
| 117 | + --name $CUSTOM_LOCATION_NAME ` |
| 118 | + --query id ` |
| 119 | + --output tsv) |
| 120 | +
|
| 121 | + # Create container Apps connected environment |
| 122 | + az containerapp connected-env create ` |
| 123 | + --resource-group $ArcResourceGroupName ` |
| 124 | + --name $CONNECTED_ENVIRONMENT_NAME ` |
| 125 | + --custom-location $CUSTOM_LOCATION_ID ` |
| 126 | + --location eastus |
| 127 | +
|
| 128 | + # DEBUG: validate that the connected environment is successfully created |
| 129 | + if ($Debug) { |
| 130 | + Write-Debug az containerapp connected-env show --resource-group $ArcResourceGroupName --name $CONNECTED_ENVIRONMENT_NAME |
| 131 | + } |
| 132 | +
|
| 133 | + # Create a new resource group for the container app |
| 134 | + $myResourceGroup="${imageName}-resource-group" |
| 135 | + az group create --name $myResourceGroup --location eastus |
| 136 | +
|
| 137 | + # Get the custom location id |
| 138 | + $customLocationId=$(az customlocation show --resource-group $ArcResourceGroupName --name $CUSTOM_LOCATION_NAME --query id --output tsv) |
| 139 | + |
| 140 | + # Get info about the connected environment |
| 141 | + $myContainerApp="${imageName}-container-app" |
| 142 | + $myConnectedEnvironment=$(az containerapp connected-env list --custom-location $customLocationId -o tsv --query '[].id') |
| 143 | +
|
| 144 | + # create acr and group |
| 145 | + az group create --name $ArcResourceGroupName --location eastus |
| 146 | + az acr create --resource-group $ArcResourceGroupName --name $ACRName --sku Basic |
| 147 | +
|
| 148 | + # Wait for the ACR to be created |
| 149 | + Start-Sleep -Seconds 10 |
| 150 | +
|
| 151 | + # login to acr and get login server |
| 152 | + az acr login --name $ACRName |
| 153 | + $ACRLoginServer = $(az acr show --name $ACRName --query loginServer --output tsv) |
| 154 | +
|
| 155 | + # DEBUG: Test ACR login |
| 156 | + if ($Debug) { |
| 157 | + Write-Debug az acr show --name $ACRName |
| 158 | + Write-Debug az acr repository list --name $ACRName --output table |
| 159 | + } |
| 160 | +
|
| 161 | + # Build and push docker image |
| 162 | + cd .\DemoApp |
| 163 | + docker build -t ${imageName} . |
| 164 | + docker tag ${imageName} ${ACRLoginServer}/${imageName}:latest |
| 165 | + docker push ${ACRLoginServer}/${imageName}:latest |
| 166 | + cd .. |
| 167 | +
|
| 168 | + # Enable admin user in ACR and get password |
| 169 | + az acr update -n $ACRName --admin-enabled true |
| 170 | + $password = $(az acr credential show --name ${ACRName} --query passwords[0].value --output tsv) |
| 171 | +
|
| 172 | + # Create container app |
| 173 | + az containerapp create ` |
| 174 | + --resource-group $myResourceGroup ` |
| 175 | + --name $myContainerApp ` |
| 176 | + --environment $myConnectedEnvironment ` |
| 177 | + --environment-type connected ` |
| 178 | + --registry-server ${ACRLoginServer} ` |
| 179 | + --registry-username ${ACRName} ` |
| 180 | + --registry-password $password ` |
| 181 | + --image "${ACRLoginServer}/${imageName}:latest" ` |
| 182 | + --target-port 80 ` |
| 183 | + --ingress 'external' ` |
| 184 | + |
| 185 | + # Open the container app in a browser |
| 186 | + az containerapp browse --resource-group $myResourceGroup --name $myContainerApp |
| 187 | + } |
| 188 | + catch { |
| 189 | + # Catch any error |
| 190 | + Write-Error "An error occurred" |
| 191 | + Write-Error $Error[0] |
| 192 | + } |
| 193 | +} |
| 194 | +
|
| 195 | +CreateContainerAppOnArcEnabledAksEz -AKSClusterResourceGroupName "my-aks-cluster-group" ` |
| 196 | + -location "westus" ` |
| 197 | + -AKSName "my-aks-cluster"` |
| 198 | + -edgeZone "losangeles" ` |
| 199 | + -nodeCount 2 ` |
| 200 | + -vmSize "standard_nv12ads_a10_v5" ` |
| 201 | + -ArcResourceGroupName "myArcResourceGroup" ` |
| 202 | + -CONNECTED_ENVIRONMENT_NAME "myConnectedEnvironment" ` |
| 203 | + -CUSTOM_LOCATION_NAME "myCustomLocation" ` |
| 204 | + -SubscriptionId "<your subscription>"` |
| 205 | + -ACRName "containerappezacr" ` |
| 206 | + -imageName "myimage" |
| 207 | +``` |
| 208 | + |
| 209 | + |
| 210 | +## Clean up resources |
| 211 | + |
| 212 | +When no longer needed, delete **my-aks-cluster-group** resource group and all of the resources it contains using the [az group delete](/cli/azure/group#az-group-delete) command. |
| 213 | + |
| 214 | +```powershell |
| 215 | +az group delete --name my-aks-cluster-group |
| 216 | +``` |
| 217 | + |
| 218 | +## Related content |
| 219 | + |
| 220 | +- [Create an Arc-enabled AKS cluster in an Extended Zone](/azure/extended-zones/arc-enabled-workloads-arc-enabled-aks-cluster) |
| 221 | +- [Deploy Arc-enabled workloads in an Extended Zone: PostgreSQL](/azure/extended-zones/arc-enabled-workloads-postgre-sql) |
| 222 | +- [Deploy Arc-enabled workloads in an Extended Zone: ManagedSQL](/azure/extended-zones/arc-enabled-workloads-managed-sql) |
| 223 | +- [Deploy an AKS cluster in an Extended Zone](deploy-aks-cluster.md) |
| 224 | +- [Deploy a storage account in an Extended Zone](create-storage-account.md) |
| 225 | +- [Frequently asked questions](faq.md) |
0 commit comments