From b1bf49feb4e8350a36a9a134f125b7aa92bb10a2 Mon Sep 17 00:00:00 2001 From: Aria Amini Date: Mon, 10 Mar 2025 20:13:01 -0400 Subject: [PATCH 1/2] Make scenario active --- scenarios/metadata.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/scenarios/metadata.json b/scenarios/metadata.json index aae5ef4df..3ed32c58b 100644 --- a/scenarios/metadata.json +++ b/scenarios/metadata.json @@ -932,7 +932,7 @@ } }, { - "status": "inactive", + "status": "active", "key": "AksOpenAiTerraform/README.md", "title": "How to deploy and run an Azure OpenAI ChatGPT application on AKS via Terraform", "description": "This article shows how to deploy an AKS cluster and Azure OpenAI Service via Terraform and how to deploy a ChatGPT-like application in Python.", From fa919a935d890d7ed82679fc797f4d27c80dd320 Mon Sep 17 00:00:00 2001 From: Aria Amini Date: Thu, 13 Mar 2025 14:12:19 -0400 Subject: [PATCH 2/2] Fix bugs --- scenarios/AksOpenAiTerraform/README.md | 10 ++++++---- .../AksOpenAiTerraform/magic8ball/requirements.txt | 4 ++-- scenarios/AksOpenAiTerraform/terraform/main.tf | 2 +- scenarios/AksOpenAiTerraform/terraform/outputs.tf | 4 ++++ 4 files changed, 13 insertions(+), 7 deletions(-) diff --git a/scenarios/AksOpenAiTerraform/README.md b/scenarios/AksOpenAiTerraform/README.md index d6a9fbfcc..3977ca25a 100644 --- a/scenarios/AksOpenAiTerraform/README.md +++ b/scenarios/AksOpenAiTerraform/README.md @@ -12,7 +12,7 @@ ms.custom: innovation-engine, linux-related-content Run terraform to provision all the Azure resources required to setup your new OpenAI website. ```bash # Terraform parses TF_VAR_* as vars (Ex: TF_VAR_name -> name) -export TF_VAR_location="westus3" +export TF_VAR_location=$REGION export TF_VAR_kubernetes_version="1.30.9" export TF_VAR_model_name="gpt-4o-mini" export TF_VAR_model_version="2024-07-18" @@ -27,7 +27,8 @@ terraform -chdir=terraform apply -auto-approve In order to use the kubectl to run commands on the newly created cluster, you must first login. ```bash RESOURCE_GROUP=$(terraform -chdir=terraform output -raw resource_group_name) -az aks get-credentials --admin --name AksCluster --resource-group $RESOURCE_GROUP --subscription $SUBSCRIPTION_ID +AKS_CLUSTER_NAME=$(terraform -chdir=terraform output -raw aks_cluster_name) +az aks get-credentials --admin --name $AKS_CLUSTER_NAME --resource-group $RESOURCE_GROUP --subscription $SUBSCRIPTION_ID ``` # Install Helm Charts @@ -55,8 +56,9 @@ helm upgrade --install cert-manager jetstack/cert-manager \ Apply/Deploy Manifest File ```bash export IMAGE="aamini8/magic8ball:latest" -# Uncomment below to manually build docker image yourself instead of using pre-built image. +# (Uncomment below to manually build docker image yourself instead of using pre-built image.) # docker build -t ./magic8ball --push + export HOSTNAME=$(terraform -chdir=terraform output -raw hostname) export WORKLOAD_IDENTITY_CLIENT_ID=$(terraform -chdir=terraform output -raw workload_identity_client_id) export AZURE_OPENAI_DEPLOYMENT=$(terraform -chdir=terraform output -raw openai_deployment) @@ -66,6 +68,6 @@ envsubst < quickstart-app.yml | kubectl apply -f - ## Wait for host to be ready ```bash -kubectl wait --for=condition=Ready certificate/tls-secret +kubectl wait --for=condition=Ready --timeout=5m certificate/tls-secret echo "Visit: https://$HOSTNAME" ``` \ No newline at end of file diff --git a/scenarios/AksOpenAiTerraform/magic8ball/requirements.txt b/scenarios/AksOpenAiTerraform/magic8ball/requirements.txt index b32480fe0..89cd420f5 100644 --- a/scenarios/AksOpenAiTerraform/magic8ball/requirements.txt +++ b/scenarios/AksOpenAiTerraform/magic8ball/requirements.txt @@ -1,3 +1,3 @@ streamlit~=1.40.1 -azure-identity~=1.20.0 -openai~=1.65.2 \ No newline at end of file +azure-identity~=1.21.0 +openai~=1.66.2 \ No newline at end of file diff --git a/scenarios/AksOpenAiTerraform/terraform/main.tf b/scenarios/AksOpenAiTerraform/terraform/main.tf index cf95667e4..037b78f70 100644 --- a/scenarios/AksOpenAiTerraform/terraform/main.tf +++ b/scenarios/AksOpenAiTerraform/terraform/main.tf @@ -47,7 +47,7 @@ resource "azurerm_resource_group" "main" { # Kubernetes ############################################################################### resource "azurerm_kubernetes_cluster" "main" { - name = "AksCluster" + name = "AksCluster-${local.random_id}" location = var.location resource_group_name = azurerm_resource_group.main.name diff --git a/scenarios/AksOpenAiTerraform/terraform/outputs.tf b/scenarios/AksOpenAiTerraform/terraform/outputs.tf index 2411dcba1..4d58c75ac 100644 --- a/scenarios/AksOpenAiTerraform/terraform/outputs.tf +++ b/scenarios/AksOpenAiTerraform/terraform/outputs.tf @@ -2,6 +2,10 @@ output "resource_group_name" { value = azurerm_resource_group.main.name } +output "aks_cluster_name" { + value = azurerm_kubernetes_cluster.main.name +} + output "workload_identity_client_id" { value = azurerm_user_assigned_identity.workload.client_id }