Skip to content

Commit 4b1cbf5

Browse files
Merge pull request #311397 from v-thpra/tjp-lf-servconnect-005
Q&M: Light Freshness - Service Connector - TJP005
2 parents 82197fe + e68e241 commit 4b1cbf5

1 file changed

Lines changed: 35 additions & 35 deletions

File tree

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

Lines changed: 35 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
---
22
title: "Tutorial: Connect AKS to Azure OpenAI with Service Connector and Workload Identity"
33
titleSuffix: Service Connector
4-
description: "Complete step-by-step guide: Connect Azure Kubernetes Service (AKS) to Azure OpenAI using Service Connector with workload identity authentication"
4+
description: "Complete step-by-step guide: Connect Azure Kubernetes Service (AKS) to Azure OpenAI using Service Connector with workload identity authentication."
55
#customer intent: As a developer, I want to connect my AKS resource to Azure OpenAI.
66
author: maud-lv
77
ms.author: malev
@@ -11,23 +11,23 @@ keywords: "azure openai aks, kubernetes openai, service connector, workload iden
1111
ms.update-cycle: 180-days
1212
ms.collection: ce-skilling-ai-copilot
1313
ms.topic: tutorial
14-
ms.date: 09/30/2025
14+
ms.date: 02/04/2026
1515
---
1616

1717
# Tutorial: Connect AKS to Azure OpenAI
1818

19-
This tutorial shows you how to connect your Azure Kubernetes Service (AKS) applications to Azure OpenAI using Service Connector with workload identity authentication. You'll establish credential-free connections by deploying a sample Python application that communicates with the Azure OpenAI.
19+
This tutorial shows you how to connect your Azure Kubernetes Service (AKS) applications to Azure OpenAI using Service Connector with workload identity authentication. You then establish and test your credential-free connections by deploying a sample Python application that communicates with the Azure OpenAI.
2020

21-
You'll complete the following tasks:
21+
In this tutorial, you:
2222

2323
> [!div class="checklist"]
2424
>
25-
> * Create an AKS cluster and Azure OpenAI resource with GPT-4 model
26-
> * Configure Service Connector to establish the connection with workload identity
27-
> * Clone a sample application
28-
> * Build and push container images to Azure Container Registry
29-
> * Deploy the application to AKS and verify the connection
30-
> * Clean up resources
25+
> * Create an AKS cluster and Azure OpenAI resource with GPT-4 model.
26+
> * Configure Service Connector to establish the connection with workload identity.
27+
> * Clone a sample application.
28+
> * Build and push container images to Azure Container Registry.
29+
> * Deploy the application to AKS and verify the connection.
30+
> * Clean up resources.
3131
3232
## Prerequisites
3333

@@ -60,15 +60,15 @@ You start this tutorial by creating several Azure resources.
6060
--generate-ssh-keys
6161
```
6262
63-
1. Connect to the cluster using the [az aks get-credentials](/cli/azure/aks#az-aks-get-credentials) command.
63+
1. Connect to the cluster using the [`az aks get-credentials`](/cli/azure/aks#az-aks-get-credentials) command.
6464
6565
```azurecli
6666
az aks get-credentials \
6767
--resource-group MyResourceGroup \
6868
--name MyAKSCluster
6969
```
7070
71-
1. Create an Azure OpenAI resource using the [az cognitiveservices account create](/cli/azure/cognitiveservices/account#az-cognitiveservices-account-create) command. Optionally refer to [this tutorial](/azure/ai-services/openai/how-to/create-resource) for more instructions. Azure OpenAI is the target service that the AKS cluster will connect to.
71+
1. Create an Azure OpenAI resource using the [`az cognitiveservices account create`](/cli/azure/cognitiveservices/account#az-cognitiveservices-account-create) command. Optionally refer to [this tutorial](/azure/ai-services/openai/how-to/create-resource) for more instructions. Azure OpenAI is the target service that the AKS cluster connects to.
7272
7373
```azurecli
7474
az cognitiveservices account create \
@@ -81,7 +81,7 @@ You start this tutorial by creating several Azure resources.
8181
--subscription <SubscriptionID>
8282
```
8383
84-
1. Deploy a model with the [az cognitiveservices deployment create](/cli/azure/cognitiveservices/account/deployment#az-cognitiveservices-account-deployment-create) command. The model is used in the sample application to test the connection.
84+
1. Deploy a model with the [`az cognitiveservices deployment create`](/cli/azure/cognitiveservices/account/deployment#az-cognitiveservices-account-deployment-create) command. The model is used in the sample application to test the connection.
8585
8686
```azurecli-interactive
8787
az cognitiveservices account deployment create \
@@ -95,7 +95,7 @@ You start this tutorial by creating several Azure resources.
9595
--capacity 1
9696
```
9797
98-
1. Create an Azure Container Registry (ACR) to store the containerized sample application. Use the [az acr create](/cli/azure/acr#az-acr-create) command, or refer to [this tutorial](/azure/container-registry/container-registry-get-started-portal).
98+
1. To store the containerized sample application, create an Azure Container Registry (ACR). Use the [`az acr create`](/cli/azure/acr#az-acr-create) command, or refer to [this tutorial](/azure/container-registry/container-registry-get-started-portal).
9999
100100
```azurecli-interactive
101101
az acr create \
@@ -104,7 +104,7 @@ You start this tutorial by creating several Azure resources.
104104
--sku Standard
105105
```
106106
107-
1. Enable anonymous pull using [az acr update](/cli/azure/acr#az-acr-update) command so that the AKS cluster can consume the images in the registry.
107+
1. Enable anonymous pull using the [`az acr update`](/cli/azure/acr#az-acr-update) command so that the AKS cluster can consume the images in the registry.
108108
109109
```azurecli-interactive
110110
az acr update \
@@ -113,7 +113,7 @@ You start this tutorial by creating several Azure resources.
113113
--anonymous-pull-enabled
114114
```
115115
116-
1. Create a user-assigned managed identity with the [az identity create](/cli/azure/identity#az-identity-create) command, or by referring to [this tutorial](/entra/identity/managed-identities-azure-resources/how-manage-user-assigned-managed-identities). When the connection is created, the user-assigned managed identity is used to enable the [workload identity](/entra/workload-id/workload-identities-overview) for AKS workloads.
116+
1. Create a user-assigned managed identity with the [`az identity create`](/cli/azure/identity#az-identity-create) command, or by referring to [this tutorial](/entra/identity/managed-identities-azure-resources/how-manage-user-assigned-managed-identities). When the connection is created, the user-assigned managed identity is used to enable the [workload identity](/entra/workload-id/workload-identities-overview) for AKS workloads.
117117
118118
```azurecli
119119
az identity create \
@@ -131,35 +131,35 @@ Refer to the [AKS service connection quickstart](quickstart-portal-aks-connectio
131131
132132
1. Basics tab:
133133
134-
| Setting | Example value | Description |
135-
|---------------------|-------------------| ------------------------------------------------------------------------------------------|
136-
| **Kubernetes namespace** | *default* | The Kubernetes namespace. |
137-
| **Service type** | *OpenAI Service* | The target service type. |
138-
| **Connection name** | *openai_conn* | Use the connection name provided by Service Connector or choose your own connection name. |
139-
| **Subscription** | *My Subscription* | The Azure subscription containing your Azure OpenAI resource. |
140-
| **OpenAI** | *MyOpenAI* | The target Azure OpenAI resource you want to connect to. |
141-
| **Client type** | *Python* | The programming language or framework for the connection configuration. |
134+
| Setting | Example value | Description |
135+
|---------------------|-------------------| ------------------------------------------------------------------------------------------|
136+
| **Kubernetes namespace** | *default* | The Kubernetes namespace. |
137+
| **Service type** | *OpenAI Service* | The target service type. |
138+
| **Connection name** | *openai_conn* | Use the connection name provided by Service Connector or choose your own connection name. |
139+
| **Subscription** | *My Subscription* | The Azure subscription containing your Azure OpenAI resource. |
140+
| **OpenAI** | *MyOpenAI* | The target Azure OpenAI resource you want to connect to. |
141+
| **Client type** | *Python* | The programming language or framework for the connection configuration. |
142142
143143
1. Authentication tab:
144144
145-
| Authentication Setting | Example value | Description |
146-
|--------------------------------|---------------------|-------------------------------------------------------------------------|
147-
| **Authentication type** | *Workload Identity* | The authentication method to connect the app to Azure OpenAI. Workload identity is recommended for enhanced security. Alternative methods include connection string and service principal, and require credential management considerations. |
148-
| **Subscription** | *My Subscription* | The subscription that contains the user-assigned managed identity. |
149-
| **User assigned managed identity** | *myidentity* | The user-assigned managed identity that enables workload identity authentication for the AKS cluster. |
145+
| Authentication Setting | Example value | Description |
146+
|--------------------------------|---------------------|-------------------------------------------------------------------------|
147+
| **Authentication type** | *Workload Identity* | The authentication method to connect the app to Azure OpenAI. Workload identity is recommended for enhanced security. Alternative methods include connection string and service principal, and require credential management considerations. |
148+
| **Subscription** | *My Subscription* | The subscription that contains the user-assigned managed identity. |
149+
| **User assigned managed identity** | *MyIdentity* | The user-assigned managed identity that enables workload identity authentication for the AKS cluster. |
150150
151151
Once the connection is created, you can view its details in the **Service Connector** pane.
152152
153153
### [Azure CLI](#tab/azure-cli)
154154
155-
Create a service connection from AKS to the Azure OpenAI resource by running the [az aks connection create cognitiveservices](/cli/azure/aks/connection/create#az-aks-connection-create-cognitiveservices) command in the Azure CLI.
155+
Create a service connection from AKS to the Azure OpenAI resource by running the [`az aks connection create cognitiveservices`](/cli/azure/aks/connection/create#az-aks-connection-create-cognitiveservices) command in the Azure CLI.
156156
157157
```azurecli
158158
az aks connection create cognitiveservices \
159159
--workload-identity <user-identity-resource-id>
160160
```
161161

162-
When using the above command, Service Connector prompts you to specify the AKS resource group, AKS cluster name, target service resource group, cognitive service account name, and user-assigned identity resource ID step by step.
162+
When you use the preceding command, Service Connector prompts you step by step to specify: the AKS resource group, AKS cluster name, target service resource group, cognitive service account name, and user-assigned identity resource ID.
163163

164164
Alternatively, you can provide the complete command directly:
165165

@@ -195,13 +195,13 @@ az aks connection create cognitiveservices \
195195

196196
## Build and push container images to Azure Container Registry
197197

198-
1. Build and push the images to your container registry using the Azure CLI [az acr build](/cli/azure/acr#az_acr_build) command.
198+
1. Build and push the images to your container registry using the Azure CLI [`az acr build`](/cli/azure/acr#az_acr_build) command.
199199

200200
```azurecli-interactive
201201
az acr build --registry myregistry --image sc-demo-openai-identity:latest ./
202202
```
203203
204-
1. View the images in your container registry using the [az acr repository list](/cli/azure/acr/repository#az_acr_repository_list) command.
204+
1. View the images in your container registry using the [`az acr repository list`](/cli/azure/acr/repository#az_acr_repository_list) command.
205205
206206
```azurecli-interactive
207207
az acr repository list --name myregistry --output table
@@ -211,11 +211,11 @@ az aks connection create cognitiveservices \
211211
212212
1. Replace the placeholders in the `pod.yaml` file in the `azure-openai-workload-identity` folder.
213213
214-
* Replace `<YourContainerImage>` with the name of the image you built earlier. For example `<myregistry>.azurecr.io/<sc-demo-openai-identity>:<latest>`.
214+
* Replace `<YourContainerImage>` with the name of the image you built earlier. For example, `<myregistry>.azurecr.io/<sc-demo-openai-identity>:<latest>`.
215215
* Replace `<ServiceAccountCreatedByServiceConnector>` with the service account name. It can be found in the Azure portal, in the **Service Connector** pane.
216216
* Replace `<SecretCreatedByServiceConnector>` with the secret name. It can be found in the Azure portal, in the **Service Connector** pane.
217217
218-
1. Deploy the pod to your cluster with the `kubectl apply` command, which creates a pod named `sc-demo-openai-identity` in the default namespace of your AKS cluster. Install `kubectl` locally using the [az aks install-cli](/cli/azure/aks#az_aks_install_cli) command if it isn't installed.
218+
1. Deploy the pod to your cluster with the `kubectl apply` command, which creates a pod named `sc-demo-openai-identity` in the default namespace of your AKS cluster. Install `kubectl` locally using the [`az aks install-cli`](/cli/azure/aks#az_aks_install_cli) command if it isn't installed.
219219
220220
```Bash
221221
kubectl apply -f pod.yaml

0 commit comments

Comments
 (0)