Skip to content

Commit 7831ff5

Browse files
authored
Merge pull request #274351 from wchigit/add-aks-cli
Add CLI docs for AKS service connector support
2 parents 257f892 + 9c04b72 commit 7831ff5

File tree

5 files changed

+147
-8
lines changed

5 files changed

+147
-8
lines changed

.openpublishing.redirection.json

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -4000,11 +4000,6 @@
40004000
"redirect_url":"/azure/reliability/reliability-containers",
40014001
"redirect_document_id":false
40024002
},
4003-
{
4004-
"source_path_from_root":"/articles/service-connector/quickstart-cli-aks-connection.md",
4005-
"redirect_url":"/azure/service-connector/quickstart-portal-aks-connection",
4006-
"redirect_document_id":false
4007-
},
40084003
{
40094004
"source_path_from_root":"/articles/aks/generation-2-vm-windows.md",
40104005
"redirect_url":"/azure/aks/generation-2-vm",
Lines changed: 106 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,106 @@
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: 05/06/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 [Microsoft Entra ID 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)

articles/service-connector/toc.yml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,8 @@ items:
3737
items:
3838
- name: Azure portal
3939
href: quickstart-portal-aks-connection.md
40+
- name: Azure CLI
41+
href: quickstart-cli-aks-connection.md
4042
- name: Azure Spring Apps
4143
expanded: false
4244
items:

articles/service-connector/tutorial-python-aks-keyvault-csi-driver.md

Lines changed: 18 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -78,7 +78,9 @@ Learn how to connect to Azure Key Vault using CSI driver in an Azure Kubernetes
7878
7979
## Create a service connection in AKS with Service Connector (preview)
8080
81-
Create a service connection between an AKS cluster and an Azure Key Vault using the Azure portal.
81+
Create a service connection between an AKS cluster and an Azure Key Vault using the Azure portal or the Azure CLI.
82+
83+
### [Portal](#tab/azure-portal)
8284
8385
1. Open your **Kubernetes service** in the Azure portal and select **Service Connector** from the left menu.
8486
@@ -97,6 +99,21 @@ Create a service connection between an AKS cluster and an Azure Key Vault using
9799
98100
:::image type="content" source="./media/aks-tutorial/kubernetes-resources.png" alt-text="Screenshot of the Azure portal, viewing kubernetes resources created by Service Connector.":::
99101
102+
### [Azure CLI](#tab/azure-cli)
103+
104+
Run the following Azure CLI command to create a service connection to an Azure Key Vault.
105+
106+
```azurecli
107+
az aks connection create keyvault --enable-csi
108+
```
109+
110+
Provide the following information as prompted:
111+
112+
* **Source compute service resource group name:** the resource group name of the AKS cluster.
113+
* **AKS cluster name:** the name of your AKS cluster that connects to the target service.
114+
* **Target service resource group name:** the resource group name of the Azure Key Vault.
115+
* **Key vault name:** the Azure Key Vault that is connected.
116+
100117
---
101118

102119
## Test the connection

articles/service-connector/tutorial-python-aks-storage-workload-identity.md

Lines changed: 21 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -97,7 +97,9 @@ Learn how to create a pod in an AKS cluster, which talks to an Azure storage acc
9797
9898
## Create service connection with Service Connector (preview)
9999
100-
Create a service connection between an AKS cluster and an Azure storage account using the Azure portal.
100+
Create a service connection between an AKS cluster and an Azure storage account using the Azure portal or the Azure CLI.
101+
102+
### [Portal](#tab/azure-portal)
101103
102104
1. Open your **Kubernetes service** in the Azure portal and select **Service Connector** from the left menu.
103105
@@ -122,8 +124,25 @@ Create a service connection between an AKS cluster and an Azure storage account
122124
| **User assigned managed identity** | `<MyIdentity>` | A user assigned managed identity is needed to enable workload identity. |
123125
124126
1. Once the connection has been created, the Service Connector page displays information about the new connection.
127+
:::image type="content" source="./media/aks-tutorial/kubernetes-resources.png" alt-text="Screenshot of the Azure portal, viewing kubernetes resources created by Service Connector.":::
128+
129+
130+
### [Azure CLI](#tab/azure-cli)
131+
132+
Run the following Azure CLI command to create a service connection to the Azure storage account, providing the following information:
133+
134+
```azurecli
135+
az aks connection create storage-blob \
136+
--workload-identity <user-identity-resource-id>
137+
```
138+
139+
Provide the following information as prompted:
125140

126-
:::image type="content" source="./media/aks-tutorial/kubernetes-resources.png" alt-text="Screenshot of the Azure portal, viewing kubernetes resources created by Service Connector.":::
141+
* **Source compute service resource group name:** the resource group name of the AKS cluster.
142+
* **AKS cluster name:** the name of your AKS cluster that connects to the target service.
143+
* **Target service resource group name:** the resource group name of the Azure storage account.
144+
* **Storage account name:** the Azure storage account that is connected.
145+
* **User-assigned identity resource ID:** the resource ID of the user-assigned identity used to create the workload identity.
127146

128147
---
129148

0 commit comments

Comments
 (0)