|
| 1 | +--- |
| 2 | +title: Quickstart - Create a service connection in Azure Kubernetes Service (AKS) with the Azure CLI |
| 3 | +description: Quickstart showing how to create a service connection in Azure Kubernetes Service (AKS) with the Azure CLI |
| 4 | +author: houk-ms |
| 5 | +ms.author: honc |
| 6 | +ms.service: service-connector |
| 7 | +ms.topic: quickstart |
| 8 | +ms.date: 03/01/2024 |
| 9 | +ms.devlang: azurecli |
| 10 | +ms.custom: devx-track-azurecli |
| 11 | +--- |
| 12 | +# Quickstart: Create a service connection in AKS cluster with the Azure CLI |
| 13 | + |
| 14 | +This quickstart shows you how to connect Azure Kubernetes Service (AKS) to other Cloud resources using Azure CLI and Service Connector. Service Connector lets you quickly connect compute services to cloud services, while managing your connection's authentication and networking settings. |
| 15 | + |
| 16 | +[!INCLUDE [quickstarts-free-trial-note](../../includes/quickstarts-free-trial-note.md)] |
| 17 | + |
| 18 | +[!INCLUDE [azure-cli-prepare-your-environment.md](~/reusable-content/azure-cli/azure-cli-prepare-your-environment.md)] |
| 19 | + |
| 20 | +* This quickstart requires version 2.30.0 or higher of the Azure CLI. If using Azure Cloud Shell, the latest version is already installed. |
| 21 | +* This quickstart assumes that you already have an AKS cluster. If you don't have one yet, [create an AKS cluster](../aks/learn/quick-kubernetes-deploy-cli.md). |
| 22 | +* This quickstart assumes that you already have an Azure Storage account. If you don't have one yet, [create an Azure Storage account](../storage/common/storage-account-create.md). |
| 23 | + |
| 24 | +## Initial set-up |
| 25 | + |
| 26 | +1. If you're using Service Connector for the first time, start by running the command [az provider register](/cli/azure/provider#az-provider-register) to register the Service Connector resource provider. |
| 27 | + |
| 28 | + ```azurecli |
| 29 | + az provider register -n Microsoft.ServiceLinker |
| 30 | + ``` |
| 31 | + |
| 32 | + > [!TIP] |
| 33 | + > You can check if the resource provider has already been registered by running the command `az provider show -n "Microsoft.ServiceLinker" --query registrationState`. If the output is `Registered`, then Service Connector has already been registered. |
| 34 | +
|
| 35 | +1. Optionally, use the Azure CLI command to get a list of supported target services for AKS cluster. |
| 36 | + |
| 37 | + ```azurecli |
| 38 | + az aks connection list-support-types --output table |
| 39 | + ``` |
| 40 | + |
| 41 | +## Create a service connection |
| 42 | + |
| 43 | +### [Using an access key](#tab/Using-access-key) |
| 44 | + |
| 45 | +Run the following Azure CLI command to create a service connection to an Azure Blob Storage with an access key, providing the following information. |
| 46 | + |
| 47 | +```azurecli |
| 48 | +az aks connection create storage-blob --secret |
| 49 | +``` |
| 50 | + |
| 51 | +Provide the following information as prompted: |
| 52 | + |
| 53 | +* **Source compute service resource group name:** the resource group name of the AKS cluster. |
| 54 | +* **AKS cluster name:** the name of your AKS cluster that connects to the target service. |
| 55 | +* **Target service resource group name:** the resource group name of the Blob Storage. |
| 56 | +* **Storage account name:** the account name of your Blob Storage. |
| 57 | + |
| 58 | +> [!NOTE] |
| 59 | +> If you don't have a Blob Storage, you can run `az aks connection create storage-blob --new --secret` to provision a new one and directly get connected to your aks cluster. |
| 60 | +
|
| 61 | +### [Using a workload identity](#tab/Using-Managed-Identity) |
| 62 | + |
| 63 | +> [!IMPORTANT] |
| 64 | +> Using Managed Identity requires you have the permission to [Azure AD role assignment](../active-directory/managed-identities-azure-resources/howto-assign-access-portal.md). If you don't have the permission, your connection creation will fail. You can ask your subscription owner for the permission or use an access key to create the connection. |
| 65 | +
|
| 66 | +Use the Azure CLI command to create a service connection to a Blob Storage with a workload identity, providing the following information: |
| 67 | + |
| 68 | +* **Source compute service resource group name:** the resource group name of the AKS cluster. |
| 69 | +* **AKS cluster name:** the name of your AKS cluster that connects to the target service. |
| 70 | +* **Target service resource group name:** the resource group name of the Blob Storage. |
| 71 | +* **Storage account name:** the account name of your Blob Storage. |
| 72 | +* **User-assigned identity resource ID:** the resource ID of the user assigned identity that is used to create workload identity |
| 73 | + |
| 74 | +```azurecli |
| 75 | +az aks connection create storage-blob \ |
| 76 | + --workload-identity <user-identity-resource-id> |
| 77 | +``` |
| 78 | + |
| 79 | +> [!NOTE] |
| 80 | +> If you don't have a Blob Storage, you can run `az aks connection create storage-blob --new --workload-identity <user-identity-resource-id>"` to provision a new one and get connected to your function app straightaway. |
| 81 | +
|
| 82 | +--- |
| 83 | + |
| 84 | +## View connections |
| 85 | + |
| 86 | +Use the Azure CLI [az aks connection list](/cli/azure/functionapp/connection#az-functionapp-connection-list) command to list connections to your AKS Cluster, providing the following information: |
| 87 | + |
| 88 | +* **Source compute service resource group name:** the resource group name of the AKS cluster. |
| 89 | +* **AKS cluster name:** the name of your AKS cluster that connects to the target service. |
| 90 | + |
| 91 | +```azurecli |
| 92 | +az aks connection list \ |
| 93 | + -g "<your-aks-cluster-resource-group>" \ |
| 94 | + -n "<your-aks-cluster-name>" \ |
| 95 | + --output table |
| 96 | +``` |
| 97 | + |
| 98 | +## Next steps |
| 99 | + |
| 100 | +Go to the following tutorials to start connecting AKS cluster to Azure services with Service Connector. |
| 101 | + |
| 102 | +> [!div class="nextstepaction"] |
| 103 | +> [Tutorial: Connect to Azure Key Vault using CSI driver](./tutorial-python-aks-keyvault-csi-driver.md) |
| 104 | +
|
| 105 | +> [!div class="nextstepaction"] |
| 106 | +> [Tutorial: Connect to Azure Storage using workload identity](./tutorial-python-aks-storage-workload-identity.md) |
0 commit comments