Deploy and test Products
Build the Java app, deploy it to AKS and confirm an uploaded manual reaches Blob Storage.
Requires
- The software checks have passed, and Docker is running in Linux container mode.
- Azure CLI is signed in to your lab subscription, and your active roles let you create resources and assign roles.
- Your lab region offers the AKS node size and your subscription has capacity for it. Check both in the quota step.
Products is the upload and chat UI. Start it on AKS, then test the upload directly. Products uses private PostgreSQL for the product record and Blob Storage for the file. Its background message pump also connects to Service Bus.
Clone Products
Create a working folder for the app checkouts and deployment files. Clone Products here or use your existing checkout in this folder.
New-Item -ItemType Directory -Path "$HOME\ai200-lab" -Force | Out-Null
Set-Location -LiteralPath "$HOME\ai200-lab"
mkdir -p "$HOME/ai200-lab"
cd "$HOME/ai200-lab"
git clone https://github.com/tuba-labs/ai200-workshop1-products.git
Open the annotated Dockerfile in your ai200-workshop1-products checkout. Find where Maven builds products.jar inside Docker and where Docker copies it into the Java runtime image.
Add this line below the second FROM and choose your own title. LABEL records metadata in the final image that you can check after the build.
LABEL org.opencontainers.image.title="Products workshop"
Create the resource group
The group keeps the lab's resources together for cleanup. Review the cost estimate before deploying.
Save the lab settings in lab.properties in your lab folder. Use the subscription you selected in Chapter 03. You can copy its ID from this command.
az account show --query id --output tsv
Replace raglab2026 below with your own unique prefix before running the commands. Use 9 to 14 lowercase letters and digits, starting with a letter. For example, raglab2026 produces raglab2026-rg and the storage account raglab2026st. Storage and registry names must be unique across Azure. Azure naming rules.
Create lab.properties in your editor with these settings. Replace YOUR_SUBSCRIPTION_ID and use your chosen prefix and region. For an existing lab, enter the values you used to create it. Use plain KEY=value lines with LF line endings for Bash. Store passwords in Key Vault.
STEM=raglab2026
SUBSCRIPTION=YOUR_SUBSCRIPTION_ID
LOCATION=swedencentral
PRODUCTS_IMAGE_TAG=workshop-v1
Load the lab settings
Run this from the lab folder whenever you open a terminal for the workshop. The commands read the file and derive the group name and its cleanup tag. Check the printed settings before continuing.
$lab = Get-Content -LiteralPath ./lab.properties -Raw | ConvertFrom-StringData
$STEM = $lab.STEM
$SUBSCRIPTION = $lab.SUBSCRIPTION
$LOCATION = $lab.LOCATION
$PRODUCTS_IMAGE_TAG = $lab.PRODUCTS_IMAGE_TAG
$GROUP = "$STEM-rg"
$WORKSHOP_ID = "products-rag-$STEM"
echo "lab.Count=$($lab.Count)"
echo "STEM=$STEM"
echo "SUBSCRIPTION=$SUBSCRIPTION"
echo "LOCATION=$LOCATION"
echo "PRODUCTS_IMAGE_TAG=$PRODUCTS_IMAGE_TAG"
echo "GROUP=$GROUP"
echo "WORKSHOP_ID=$WORKSHOP_ID"
. ./lab.properties
GROUP="$STEM-rg"
WORKSHOP_ID="products-rag-$STEM"
echo "STEM=$STEM"
echo "SUBSCRIPTION=$SUBSCRIPTION"
echo "LOCATION=$LOCATION"
echo "PRODUCTS_IMAGE_TAG=$PRODUCTS_IMAGE_TAG"
echo "GROUP=$GROUP"
echo "WORKSHOP_ID=$WORKSHOP_ID"
To pick up where you left off, reload your settings and return to the same section. Rerun the lookup commands your next command needs, such as the registry lookup or the Service IP lookup. Keep your downloaded YAML templates, TLS files, and kubeconfig in the lab folder.
az group exists checks whether the name is already in use. --subscription selects the subscription to check.
az group exists --subscription "$SUBSCRIPTION" --name "$GROUP" --output tsv
When the name check prints false, create a resource group for the Products services. --tags records the workshop-id that cleanup checks. If the name check prints true for a different lab, choose a new prefix.
az group create --subscription "$SUBSCRIPTION" --name "$GROUP" --location "$LOCATION" --tags "workshop-id=$WORKSHOP_ID" --output table
Check AKS capacity
The AKS node uses the Standard_D4ds_v5 VM size. az vm list-skus --all includes restricted sizes so you can see whether this size is available in your region. az vm list-usage shows how much of each regional vCPU quota your subscription has used.
az vm list-skus --subscription "$SUBSCRIPTION" --location "$LOCATION" --resource-type virtualMachines --size Standard_D4ds_v5 --all --query "[?name=='Standard_D4ds_v5'].{Size:name,Family:family,Restrictions:restrictions}" --output json
az vm list-usage --subscription "$SUBSCRIPTION" --location "$LOCATION" --query "[?name.value=='cores' || name.value=='standardDDSv5Family'].{Quota:name.localizedValue,Used:currentValue,Limit:limit}" --output table
Look for at least eight free vCPUs (Limit minus Used) in both Total Regional vCPUs and Standard DDSv5 Family vCPUs. The node needs four vCPUs, and an upgrade can temporarily use four more. If either quota is short, request more quota before starting AKS.
Request more AKS quota
Azure applies both quotas to each VM. A VM family with a limit of zero blocks node creation even when the region has available vCPUs.
For the quota that needs an increase, request a total limit of its Used count plus eight. With zero used, request a limit of eight.
Request the VM-family quota with Azure CLI
CLI quota requests use the Microsoft.Quota provider. Register it once in your subscription. --wait holds the prompt until registration finishes. Quota provider registration
az provider register --subscription "$SUBSCRIPTION" --namespace Microsoft.Quota --wait
az quota update requests a new limit for Standard DDSv5 Family vCPUs. --scope identifies your subscription's Compute region, and --resource-type dedicated selects standard VM quota. In --limit-object, replace 8 with your calculated total. Azure CLI can install its quota extension on first use. Azure CLI quota reference
az quota update --resource-name standardDDSv5Family --scope "/subscriptions/$SUBSCRIPTION/providers/Microsoft.Compute/locations/$LOCATION" --limit-object value=8 --resource-type dedicated
Request either quota in the Azure portal
Open Quotas → Compute and filter to the lab subscription and region. Select the quota that needs more vCPUs, choose New Quota Request → Enter a new limit, and submit the new limit. Open Azure Quotas
After approval, repeat the quota check to confirm both limits have at least eight free vCPUs.
See the resource group and quotas in the Azure portal
Open Resource groups in the Azure portal and select the group you created. Check the subscription and location in Overview and the workshop-id under Tags. Azure portal · Resource group screenshot
The Compute quota view shows the same usage and limits as az vm list-usage. Compute quotas screenshot
Deploy the shared services
Save the complete foundation.bicep template in ai200-lab. A Bicep file describes the Azure resources you want to deploy. When you pass a local .bicep file to --template-file, Azure CLI compiles it on your machine into an Azure Resource Manager (ARM) JSON template. You can use any .bicep filename. The example uses foundation.bicep, and --name foundation names the deployment in Azure. Azure receives the compiled template and your parameter values, then deploys the shared network and services for Products in your resource group.
Read the key parts of the foundation template
Deployment inputs
The deployment command supplies the region as location, your resource name prefix as stem, and your Entra user object ID as operatorId.
targetScope = 'resourceGroup'
param location string
@minLength(9)
@maxLength(14)
param stem string
// Use the signed-in Entra user's object ID for the role assignments below.
param operatorId string
Network and private DNS
AKS, Functions, and PostgreSQL use separate subnets. The NAT gateway handles outbound traffic. The DNS link below connects the private PostgreSQL zone to the virtual network so apps can resolve the database hostname.
resource link 'Microsoft.Network/privateDnsZones/virtualNetworkLinks@2024-06-01' = {
parent: dns
name: 'workshop'
location: 'global'
properties: { registrationEnabled: false, virtualNetwork: { id: network.id } }
}
Managed identities
The AKS cluster identity gets Network Contributor on the lab resource group so it can use the virtual network, NAT gateway, and public IP. Products gets its own managed identity for access to app services.
resource identities 'Microsoft.ManagedIdentity/userAssignedIdentities@2024-11-30' = [for suffix in identityNames: {
name: '${stem}-${suffix}'
location: location
}]
Container registry
You push the Products image to this registry so AKS can pull it. Use your prefix to predict the registry name from name below.
resource acr 'Microsoft.ContainerRegistry/registries@2025-11-01' = {
name: '${stem}acr'
location: location
sku: { name: 'Basic' }
properties: { adminUserEnabled: false }
}
Blob Storage for manuals
Products uploads manuals to this private container. ProductsEmbedder reads the same files when indexing them.
resource manuals 'Microsoft.Storage/storageAccounts/blobServices/containers@2026-09-01' = {
parent: blobService
name: 'manuals'
properties: { publicAccess: 'None' }
}
Secrets and settings
Key Vault stores passwords. App Configuration holds endpoints and other settings that Products loads at startup.
resource vault 'Microsoft.KeyVault/vaults@2026-05-15' = {
name: '${stem}-kv'
resource config 'Microsoft.AppConfiguration/configurationStores@2024-06-01' = {
name: '${stem}-cfg'
Operator access
The template gives the Entra user specified by operatorId three roles. Key Vault Secrets Officer lets you manage secrets in the lab vault. App Configuration Data Owner lets you manage settings in the lab store. Storage Blob Data Reader lets you list and read blobs in the lab storage account.
The assignment below uses the role ID for Key Vault Secrets Officer. Its scope: vault applies the permission to the lab vault. Azure built-in roles catalog
resource vaultOperator 'Microsoft.Authorization/roleAssignments@2022-04-01' = {
name: guid(vault.id, operatorId, 'secrets-officer')
scope: vault
properties: {
principalId: operatorId
roleDefinitionId: subscriptionResourceId('Microsoft.Authorization/roleDefinitions', 'b86a8fe4-44ce-4948-aee5-eccb2c155cd7')
}
}
Deployment output
The deployment returns the App Configuration endpoint. You'll use it as APP_CONFIG_ENDPOINT in the Products manifest so the app can find its settings.
output configEndpoint string = config.properties.endpoint
Look up your Entra user object ID. The template uses it to let you manage secrets and settings and read uploaded manuals.
$OPERATOR_ID = az ad signed-in-user show --query id --output tsv
echo "OPERATOR_ID=$OPERATOR_ID"
OPERATOR_ID=$(az ad signed-in-user show --query id --output tsv)
echo "OPERATOR_ID=$OPERATOR_ID"
az deployment group create deploys the template to the group chosen by --resource-group. --parameters supplies the Bicep inputs. includeWorkerIdentities=false creates the AKS and Products identities here. Later chapters create their own identities. Continue when the command prints Succeeded.
az deployment group create --subscription "$SUBSCRIPTION" --resource-group "$GROUP" --name foundation --template-file foundation.bicep --parameters "location=$LOCATION" "stem=$STEM" "operatorId=$OPERATOR_ID" includeWorkerIdentities=false --query properties.provisioningState --output tsv
To check the name you predicted, open your resource group in the Azure portal and find the container registry in Overview. For the full list of resources, select Deployments → foundation. Deployment history screenshots
Store the passwords in Key Vault
az keyvault secret list lists the lab vault's secret entries. The query prints their names. Reuse any values already in your lab vault.
az keyvault secret list --subscription "$SUBSCRIPTION" --vault-name "$STEM-kv" --query '[].name' --output table
For each missing secret, generate a password in a temporary file. The Aa1! prefix supplies the character types PostgreSQL expects, and OpenSSL adds random characters.
On Windows, use the OpenSSL included with Git for Windows.
$OPENSSL = Join-Path (git --exec-path) '../../../usr/bin/openssl.exe'
$SECRET_FILE = (New-TemporaryFile).FullName
echo "OPENSSL=$OPENSSL"
echo "SECRET_FILE=$SECRET_FILE"
& $OPENSSL rand -hex 32 | ForEach-Object { Set-Content -LiteralPath $SECRET_FILE -Value "Aa1!$_" -NoNewline -Encoding Ascii }
SECRET_FILE=$(mktemp)
echo "SECRET_FILE=$SECRET_FILE"
openssl rand -hex 32 | sed 's/^/Aa1!/' | tr -d '\n' > "$SECRET_FILE"
Pick the command for the missing secret. --file reads the password from your temporary file, and --output none suppresses the command's response. Generate a fresh password before storing the second secret.
az keyvault secret set --subscription "$SUBSCRIPTION" --vault-name "$STEM-kv" --name postgres-password --file "$SECRET_FILE" --output none
az keyvault secret set --subscription "$SUBSCRIPTION" --vault-name "$STEM-kv" --name products-password --file "$SECRET_FILE" --output none
Remove the temporary file after each upload attempt. Run the list command again to confirm both names appear.
Remove-Item -LiteralPath $SECRET_FILE
rm -- "$SECRET_FILE"
Start PostgreSQL and AKS
Save database.bicep and compute.bicep in ai200-lab. The commands read the PostgreSQL secret from Key Vault and write it into a temporary parameter file for Bicep's pgPassword input.
$DB_PARAMETERS = (New-TemporaryFile).FullName
$dbPassword = az keyvault secret show --subscription $SUBSCRIPTION --vault-name "$STEM-kv" --name postgres-password --query value --output tsv
[IO.File]::WriteAllText($DB_PARAMETERS, (@{ pgPassword = @{ value = $dbPassword } } | ConvertTo-Json -Compress))
echo "DB_PARAMETERS=$DB_PARAMETERS"
echo "dbPassword length=$($dbPassword.Length)"
Remove-Variable dbPassword
DB_PARAMETERS=$(mktemp)
az keyvault secret show --subscription "$SUBSCRIPTION" --vault-name "$STEM-kv" --name postgres-password --query value --output json | jq '{pgPassword:{value:.}}' > "$DB_PARAMETERS"
echo "DB_PARAMETERS=$DB_PARAMETERS"
Deploy PostgreSQL with the Standard_B2s size. --parameters supplies the password from the temporary file and the region, prefix, and size from the command line. --no-wait returns the prompt after submission, while Azure creates the server.
az deployment group create --subscription "$SUBSCRIPTION" --resource-group "$GROUP" --name database --template-file database.bicep --parameters "$DB_PARAMETERS" "location=$LOCATION" "stem=$STEM" postgresSku=Standard_B2s --no-wait
Remove the temporary parameter file after the command returns.
Remove-Item -LiteralPath $DB_PARAMETERS
rm -- "$DB_PARAMETERS"
Deploy AKS with the VM size you checked above. aksNodes=1 requests one node, and --no-wait lets you build the image while Azure creates the cluster. AKS capacity check
az deployment group create --subscription "$SUBSCRIPTION" --resource-group "$GROUP" --name compute --template-file compute.bicep --parameters "location=$LOCATION" "stem=$STEM" aksVmSize=Standard_D4ds_v5 aksNodes=1 --no-wait
Build and push the Products image
az acr show reads registry details. Its loginServer value is the hostname to put in the image tag. Use PRODUCTS_IMAGE_TAG from lab.properties. For a new build, change the tag in that file, reload the settings, and use the new image reference in the Products manifest.
$ACR_HOST = az acr show --subscription $SUBSCRIPTION --resource-group $GROUP --name "${STEM}acr" --query loginServer --output tsv
echo "ACR_HOST=$ACR_HOST"
ACR_HOST=$(az acr show --subscription "$SUBSCRIPTION" --resource-group "$GROUP" --name "${STEM}acr" --query loginServer --output tsv)
echo "ACR_HOST=$ACR_HOST"
docker build --platform linux/amd64 --tag "$ACR_HOST/products:$PRODUCTS_IMAGE_TAG" ./ai200-workshop1-products
Run this after the build succeeds. Find org.opencontainers.image.title under Config.Labels and check that it matches your title.
docker image inspect "$ACR_HOST/products:$PRODUCTS_IMAGE_TAG"
az acr login signs Docker in to your registry. Then push the tagged image for AKS to pull.
az acr login --subscription "$SUBSCRIPTION" --name "${STEM}acr"
docker push "$ACR_HOST/products:$PRODUCTS_IMAGE_TAG"
Connect to the AKS cluster
az deployment group list reads deployment records in the lab group. The query shows each deployment name and its provisioning state so you can see when PostgreSQL and AKS are ready.
az deployment group list --subscription "$SUBSCRIPTION" --resource-group "$GROUP" --query '[].{Deployment:name,State:properties.provisioningState}' --output table
Continue when both database (PostgreSQL) and compute (AKS) show Succeeded. Rerun the check while Azure is still deploying.
az aks get-credentials writes the cluster address and authentication configuration that kubectl needs. --file ./kubeconfig saves it in your lab folder. --overwrite-existing refreshes a same-named cluster entry on a rerun.
az aks get-credentials --subscription "$SUBSCRIPTION" --resource-group "$GROUP" --name "$STEM-aks" --file ./kubeconfig --overwrite-existing
Expect a message like Merged "your-stem-aks" as current context in .../kubeconfig. A context selects a cluster and the credentials to use with it. This message confirms the local file was updated.
Use --kubeconfig ./kubeconfig so kubectl uses the lab file. The node listing verifies that kubectl can reach the cluster. az postgres flexible-server parameter show reads the azure.extensions setting. Continue when a node is Ready and PostgreSQL reports VECTOR.
kubectl --kubeconfig ./kubeconfig get nodes
az postgres flexible-server parameter show --subscription "$SUBSCRIPTION" --resource-group "$GROUP" --server-name "$STEM-pg" --name azure.extensions --query value --output tsv
Create the Service Bus queues for Products
Products starts polling for replies when it runs. Give it a Service Bus namespace and two queues. It sends questions to chat-requests and reads answers from chat-replies. ProductsChat uses these same queues in Chapter 06.
resource bus 'Microsoft.ServiceBus/namespaces@2026-01-01' = {
name: '${stem}-bus'
location: location
sku: { name: 'Standard', tier: 'Standard' }
properties: { disableLocalAuth: true, minimumTlsVersion: '1.2' }
}
resource queues 'Microsoft.ServiceBus/namespaces/queues@2026-01-01' = [for queue in ['chat-requests', 'chat-replies']: {
parent: bus
name: queue
Save products.bicep in ai200-lab and deploy it. Look for Succeeded before assigning queue permissions.
az deployment group create --subscription "$SUBSCRIPTION" --resource-group "$GROUP" --name products --template-file products.bicep --parameters "location=$LOCATION" "stem=$STEM" --query properties.provisioningState --output tsv
Give Products access to its services
Assign Azure RBAC roles so the AKS kubelet can pull the image and the Products managed identity can access its services. In az role assignment create, --assignee-object-id selects the recipient, --role names the role that grants the permissions, and --scope selects the resource they apply to. Managed identities use --assignee-principal-type ServicePrincipal. Azure built-in roles catalog
| Role | Access granted in this lab |
|---|---|
AcrPull | The AKS kubelet can pull images from the lab container registry. |
App Configuration Data Reader | Products can read connection settings from the App Configuration store. |
Key Vault Secrets User | Products can read the PostgreSQL and sign-in passwords from the lab vault. |
Storage Blob Data Contributor | Products can read, write, and delete blobs in manuals. It uses this access to store uploads. |
Azure Service Bus Data Sender | Products can send questions to chat-requests. |
Azure Service Bus Data Receiver | Products can receive and acknowledge answers on chat-replies. |
az identity show reads the Products principal ID. az deployment group show reads the compute deployment outputs for the kubelet's object ID and the AKS issuer URL. SCOPE is the shared start of the resource IDs used in the role assignments.
$SCOPE = "/subscriptions/$SUBSCRIPTION/resourceGroups/$GROUP/providers"
$PRINCIPAL_ID = az identity show --subscription $SUBSCRIPTION --resource-group $GROUP --name "$STEM-products" --query principalId --output tsv
$KUBELET_ID = az deployment group show --subscription $SUBSCRIPTION --resource-group $GROUP --name compute --query properties.outputs.kubeletObjectId.value --output tsv
$ISSUER = az deployment group show --subscription $SUBSCRIPTION --resource-group $GROUP --name compute --query properties.outputs.issuer.value --output tsv
echo "SCOPE=$SCOPE"
echo "PRINCIPAL_ID=$PRINCIPAL_ID"
echo "KUBELET_ID=$KUBELET_ID"
echo "ISSUER=$ISSUER"
SCOPE="/subscriptions/$SUBSCRIPTION/resourceGroups/$GROUP/providers"
PRINCIPAL_ID=$(az identity show --subscription "$SUBSCRIPTION" --resource-group "$GROUP" --name "$STEM-products" --query principalId --output tsv)
KUBELET_ID=$(az deployment group show --subscription "$SUBSCRIPTION" --resource-group "$GROUP" --name compute --query properties.outputs.kubeletObjectId.value --output tsv)
ISSUER=$(az deployment group show --subscription "$SUBSCRIPTION" --resource-group "$GROUP" --name compute --query properties.outputs.issuer.value --output tsv)
echo "SCOPE=$SCOPE"
echo "PRINCIPAL_ID=$PRINCIPAL_ID"
echo "KUBELET_ID=$KUBELET_ID"
echo "ISSUER=$ISSUER"
Give the kubelet permission to pull the image from the registry.
az role assignment create --subscription "$SUBSCRIPTION" --assignee-object-id "$KUBELET_ID" --assignee-principal-type ServicePrincipal --role AcrPull --scope "$SCOPE/Microsoft.ContainerRegistry/registries/${STEM}acr" --output none
Create a federated credential so the Pod can authenticate as the Products managed identity. --issuer identifies the AKS token issuer, --subject identifies the products service account in the products namespace, and --audiences names Microsoft Entra token exchange.
az identity federated-credential create --subscription "$SUBSCRIPTION" --resource-group "$GROUP" --identity-name "$STEM-products" --name workshop --issuer "$ISSUER" --subject system:serviceaccount:products:products --audiences api://AzureADTokenExchange --output none
Assign the five service roles to the Products identity at their resource scopes.
az role assignment create --subscription "$SUBSCRIPTION" --assignee-object-id "$PRINCIPAL_ID" --assignee-principal-type ServicePrincipal --role 'App Configuration Data Reader' --scope "$SCOPE/Microsoft.AppConfiguration/configurationStores/$STEM-cfg" --output none
az role assignment create --subscription "$SUBSCRIPTION" --assignee-object-id "$PRINCIPAL_ID" --assignee-principal-type ServicePrincipal --role 'Key Vault Secrets User' --scope "$SCOPE/Microsoft.KeyVault/vaults/$STEM-kv" --output none
az role assignment create --subscription "$SUBSCRIPTION" --assignee-object-id "$PRINCIPAL_ID" --assignee-principal-type ServicePrincipal --role 'Storage Blob Data Contributor' --scope "$SCOPE/Microsoft.Storage/storageAccounts/${STEM}st/blobServices/default/containers/manuals" --output none
az role assignment create --subscription "$SUBSCRIPTION" --assignee-object-id "$PRINCIPAL_ID" --assignee-principal-type ServicePrincipal --role 'Azure Service Bus Data Sender' --scope "$SCOPE/Microsoft.ServiceBus/namespaces/$STEM-bus/queues/chat-requests" --output none
az role assignment create --subscription "$SUBSCRIPTION" --assignee-object-id "$PRINCIPAL_ID" --assignee-principal-type ServicePrincipal --role 'Azure Service Bus Data Receiver' --scope "$SCOPE/Microsoft.ServiceBus/namespaces/$STEM-bus/queues/chat-replies" --output none
Point Products to its services
Read the PostgreSQL server's fullyQualifiedDomainName to use as the database host in App Configuration.
$PG_HOST = az postgres flexible-server show --subscription $SUBSCRIPTION --resource-group $GROUP --name "$STEM-pg" --query fullyQualifiedDomainName --output tsv
echo "PG_HOST=$PG_HOST"
PG_HOST=$(az postgres flexible-server show --subscription "$SUBSCRIPTION" --resource-group "$GROUP" --name "$STEM-pg" --query fullyQualifiedDomainName --output tsv)
echo "PG_HOST=$PG_HOST"
az appconfig kv set writes a setting. --auth-mode login uses your Azure sign-in and --label workshop marks the rag: keys the apps load. --yes confirms the write. Keep the two passwords in Key Vault.
az appconfig kv set --subscription "$SUBSCRIPTION" --name "$STEM-cfg" --auth-mode login --label workshop --key rag:pg-host --value "$PG_HOST" --yes --output none
az appconfig kv set --subscription "$SUBSCRIPTION" --name "$STEM-cfg" --auth-mode login --label workshop --key rag:pg-database --value "products" --yes --output none
az appconfig kv set --subscription "$SUBSCRIPTION" --name "$STEM-cfg" --auth-mode login --label workshop --key rag:pg-user --value "workshopadmin" --yes --output none
az appconfig kv set --subscription "$SUBSCRIPTION" --name "$STEM-cfg" --auth-mode login --label workshop --key rag:blob-endpoint --value "https://${STEM}st.blob.core.windows.net" --yes --output none
az appconfig kv set --subscription "$SUBSCRIPTION" --name "$STEM-cfg" --auth-mode login --label workshop --key rag:servicebus-host --value "$STEM-bus.servicebus.windows.net" --yes --output none
az appconfig kv set --subscription "$SUBSCRIPTION" --name "$STEM-cfg" --auth-mode login --label workshop --key rag:key-vault-uri --value "https://$STEM-kv.vault.azure.net" --yes --output none
The first Pod startup runs V1__products_and_messages.sql through Flyway. That creates the product table and the vector(1536) schema the Function will use.
How identity, settings and secrets connect
| Mechanism | Workshop use |
|---|---|
| Key Vault | PostgreSQL and Products sign-in passwords |
| App Configuration | Endpoints, model names, retrieval count, chunk size |
| ConfigMap | Non-secret App Configuration endpoint/label |
| Kubernetes Secret | Endpoint TLS certificate/private key |
| Environment variables | Bootstrap settings and SDK identity metadata |
| Managed/workload identity | Short-lived tokens; Azure roles grant access separately |
Bootstrap and federation
Applications start with APP_CONFIG_ENDPOINT and label workshop. App Configuration provides service settings and the vault URI. Key Vault supplies passwords. AKS requires the service-account annotation azure.workload.identity/client-id, Pod label azure.workload.identity/use: "true" and a federated credential matching issuer, subject and audience. See products.yaml.
Deploy Products
Create the namespace and restricted Service
The Products Service uses an Azure load balancer for incoming HTTPS connections. loadBalancerSourceRanges limits which public source addresses can reach the Service. Kubernetes expects CIDR notation here, and /32 matches exactly one IPv4 address.
Save a fresh copy of service.yaml in ai200-lab. Open it to see the products namespace and the Service that uses it. Find the ${ALLOWED_CIDR} placeholder in loadBalancerSourceRanges.
Run the command from the network you will use to open Products. Check that ALLOWED_CIDR shows your public IPv4 address with /32 attached.
$ALLOWED_CIDR = curl.exe -4 --fail --silent --show-error --max-time 15 https://api.ipify.org | ForEach-Object { "$_/32" }
echo "ALLOWED_CIDR=$ALLOWED_CIDR"
ALLOWED_CIDR=$(curl -4 --fail --silent --show-error --max-time 15 https://api.ipify.org | awk '{print $0 "/32"}')
echo "ALLOWED_CIDR=$ALLOWED_CIDR"
Apply the template to create the namespace and request a public IP for the Service. PowerShell reads the template with Get-Content -Raw and fills the placeholder with .Replace(). Bash uses sed for the same substitution. kubectl apply -f - reads the result from the pipe. CI/CD pipelines can use this same sequence to reuse a template with different deployment values. kubectl apply reference
sed \
-e "s|\${ALLOWED_CIDR}|$ALLOWED_CIDR|g" \
'./service.yaml' |
kubectl --kubeconfig ./kubeconfig apply -f -
(Get-Content -LiteralPath './service.yaml' -Raw).
Replace('${ALLOWED_CIDR}', $ALLOWED_CIDR) |
kubectl --kubeconfig ./kubeconfig apply -f -
Template service.yaml
Configure TLS for the Service IP
Watch the Products Service to see when Azure assigns its public IP.
kubectl --kubeconfig ./kubeconfig -n products get service products --watch
The EXTERNAL-IP column shows <pending> while Azure assigns the address. As soon as it shows an IP address, press Ctrl+C to stop watching. Read the assigned address into PRODUCTS_IP so the certificate matches the address you'll open in the browser.
$PRODUCTS_IP = kubectl --kubeconfig ./kubeconfig -n products get service products -o 'jsonpath={.status.loadBalancer.ingress[0].ip}'
echo "PRODUCTS_IP=$PRODUCTS_IP"
PRODUCTS_IP=$(kubectl --kubeconfig ./kubeconfig -n products get service products -o 'jsonpath={.status.loadBalancer.ingress[0].ip}')
echo "PRODUCTS_IP=$PRODUCTS_IP"
Find the OpenSSL included with Git for Windows.
$OPENSSL = Join-Path (git --exec-path) '../../../usr/bin/openssl.exe'
echo "OPENSSL=$OPENSSL"
Create a two-day self-signed certificate with the IP in its Subject Alternative Name. On a rerun, reuse your existing files while the certificate is valid for this IP.
& $OPENSSL req -x509 -newkey rsa:2048 -noenc -days 2 -subj '/CN=Products workshop' -addext "subjectAltName=IP:$PRODUCTS_IP" -keyout tls.key -out tls.crt
(umask 077; openssl req -x509 -newkey rsa:2048 -noenc -days 2 -subj '/CN=Products workshop' -addext "subjectAltName=IP:$PRODUCTS_IP" -keyout tls.key -out tls.crt)
Create or update the Kubernetes Secret that the Pod mounts for HTTPS.
kubectl --kubeconfig ./kubeconfig -n products create secret tls products-tls --cert=tls.crt --key=tls.key --dry-run=client --output yaml | kubectl --kubeconfig ./kubeconfig apply -f -
Print the certificate's SHA-256 fingerprint for your browser check.
& $OPENSSL x509 -in tls.crt -noout -fingerprint -sha256
openssl x509 -in tls.crt -noout -fingerprint -sha256
Apply the Products manifest
Save a fresh copy of products.yaml in ai200-lab. Read the client ID and App Configuration endpoint. Use the image tag from lab.properties and ACR_HOST from the image build. If you reopened your terminal, rerun that registry lookup. Check the four printed values.
$PRODUCTS_CLIENT_ID = az identity show --subscription "$SUBSCRIPTION" --resource-group "$GROUP" --name "$STEM-products" --query clientId --output tsv
$APP_CONFIG_ENDPOINT = az deployment group show --subscription "$SUBSCRIPTION" --resource-group "$GROUP" --name foundation --query properties.outputs.configEndpoint.value --output tsv
$IMAGE_TAG = $PRODUCTS_IMAGE_TAG
echo "PRODUCTS_CLIENT_ID=$PRODUCTS_CLIENT_ID"
echo "APP_CONFIG_ENDPOINT=$APP_CONFIG_ENDPOINT"
echo "ACR_HOST=$ACR_HOST"
echo "IMAGE_TAG=$IMAGE_TAG"
PRODUCTS_CLIENT_ID=$(az identity show --subscription "$SUBSCRIPTION" --resource-group "$GROUP" --name "$STEM-products" --query clientId --output tsv)
APP_CONFIG_ENDPOINT=$(az deployment group show --subscription "$SUBSCRIPTION" --resource-group "$GROUP" --name foundation --query properties.outputs.configEndpoint.value --output tsv)
IMAGE_TAG="$PRODUCTS_IMAGE_TAG"
echo "PRODUCTS_CLIENT_ID=$PRODUCTS_CLIENT_ID"
echo "APP_CONFIG_ENDPOINT=$APP_CONFIG_ENDPOINT"
echo "ACR_HOST=$ACR_HOST"
echo "IMAGE_TAG=$IMAGE_TAG"
Apply the template using the values above. The service account identifies the Pod to Azure, the ConfigMap tells Products where to read settings, and the image reference tells AKS which build to pull.
sed \
-e "s|\${ACR_HOST}|$ACR_HOST|g" \
-e "s|\${APP_CONFIG_ENDPOINT}|$APP_CONFIG_ENDPOINT|g" \
-e "s|\${IMAGE_TAG}|$IMAGE_TAG|g" \
-e "s|\${PRODUCTS_CLIENT_ID}|$PRODUCTS_CLIENT_ID|g" \
'./products.yaml' |
kubectl --kubeconfig ./kubeconfig apply -f -
(Get-Content -LiteralPath './products.yaml' -Raw).
Replace('${ACR_HOST}', $ACR_HOST).
Replace('${APP_CONFIG_ENDPOINT}', $APP_CONFIG_ENDPOINT).
Replace('${IMAGE_TAG}', $IMAGE_TAG).
Replace('${PRODUCTS_CLIENT_ID}', $PRODUCTS_CLIENT_ID) |
kubectl --kubeconfig ./kubeconfig apply -f -
Template products.yaml
After replacing the certificate on a running deployment, restart Products to load it.
Test the Products upload
Wait for Flyway and the readiness probe.
kubectl --kubeconfig ./kubeconfig -n products rollout status deployment/products --timeout=600s
Check the HTTPS endpoint using your certificate. Look for UP.
curl.exe --fail --cacert tls.crt "https://$PRODUCTS_IP/actuator/health/readiness"
curl --fail --cacert tls.crt "https://$PRODUCTS_IP/actuator/health/readiness"
Get the sign-in password
Open https:// followed by the load balancer IP. Compare the fingerprint before accepting the self-signed certificate. Sign in as participant using the password from Key Vault.
az keyvault secret show --subscription "$SUBSCRIPTION" --vault-name "$STEM-kv" --name products-password --query value --output tsv
In the upload form, enter Products upload test in Product name. Choose harbor-travel-kettle.txt in Product manual, then click Upload product. Open /api/products on the same Products site and find that name. Compare its blobName with the paths in Blob Storage.
az storage blob list lists blobs in manuals. --auth-mode login uses your Azure sign-in, and the query displays the blob paths.
az storage blob list --subscription "$SUBSCRIPTION" --account-name "${STEM}st" --container-name manuals --auth-mode login --query '[].name' --output table
UP, Products shows your new record, and its blob exists. A fresh upload shows waiting. This test file predates the event subscription, so the next chapter uses a new upload to test indexing. Continue to Deploy and test ProductsEmbedder.Deployment, Service and probe basics
products.yamldefines the Deployment that keeps one Java Pod running. The service account and Pod labels enable workload identity. The startup probe allows time for initialization, readiness checks the database, and liveness checks the process.service.yamlcreates the namespace and the LoadBalancer Service that sends traffic from port 443 to port 8443 on ready Products Pods. Access is restricted to your public IPv4 /32.
Connect to PostgreSQL over JDBC
Use a local JDBC client such as IntelliJ IDEA to check the row Products wrote. PostgreSQL is private to the Azure virtual network. A temporary Pod passes PostgreSQL traffic through to the server, and kubectl port-forward makes that connection available on your computer's loopback address. PostgreSQL private access · Kubernetes port forwarding
Look up the PostgreSQL hostname.
$PG_HOST = az postgres flexible-server show --subscription $SUBSCRIPTION --resource-group $GROUP --name "$STEM-pg" --query fullyQualifiedDomainName --output tsv
echo "PG_HOST=$PG_HOST"
PG_HOST=$(az postgres flexible-server show --subscription "$SUBSCRIPTION" --resource-group "$GROUP" --name "$STEM-pg" --query fullyQualifiedDomainName --output tsv)
echo "PG_HOST=$PG_HOST"
Start the temporary TCP proxy in AKS and wait for it to be ready.
kubectl --kubeconfig ./kubeconfig -n products run postgres-proxy --image=docker.io/alpine/socat:1.8.0.3 --restart=Never --command -- socat 'TCP-LISTEN:5432,bind=127.0.0.1,fork,reuseaddr' "TCP:${PG_HOST}:5432"
kubectl --kubeconfig ./kubeconfig -n products wait --for=condition=Ready pod/postgres-proxy --timeout=120s
Read the PostgreSQL password from Key Vault for your client.
az keyvault secret show --subscription "$SUBSCRIPTION" --vault-name "$STEM-kv" --name postgres-password --query value --output tsv
Leave the port forward running while you use your client. If the terminal closes, run this command again from your lab folder to reconnect.
kubectl --kubeconfig ./kubeconfig -n products port-forward --address 127.0.0.1 pod/postgres-proxy 15432:5432
Use jdbc:postgresql://127.0.0.1:15432/products?sslmode=require as the JDBC URL, workshopadmin as the user, and the Key Vault secret as the password.
In IntelliJ IDEA, open View → Tool Windows → Database, then choose + → Data Source → PostgreSQL. Keep the default connection type and fill in URL, User, and Password with those values. Download the driver if prompted and select Test Connection. IntelliJ PostgreSQL connection settings
Open a query console for the data source. Run this query and look for Products upload test with its Blob Storage path.
SELECT name, blob_name FROM public.products WHERE name = 'Products upload test';
Disconnect your client, press Ctrl+C in the forwarding terminal, and delete the temporary Pod.
kubectl --kubeconfig ./kubeconfig -n products delete pod postgres-proxy
Inspect and restart the Deployment
Find one ready Pod, the load balancer IP, Flyway startup and the probe settings.
kubectl --kubeconfig ./kubeconfig -n products get deployment,pods,service
kubectl --kubeconfig ./kubeconfig -n products logs deployment/products --tail=50
kubectl --kubeconfig ./kubeconfig -n products describe pod -l app=products
Restart Products and wait for the replacement Pod.
kubectl --kubeconfig ./kubeconfig -n products rollout restart deployment/products
kubectl --kubeconfig ./kubeconfig -n products rollout status deployment/products --timeout=300s
Stop here and delete the lab
Use this cleanup when you're ending the workshop after Products. Deleting the lab resource group removes the cluster, PostgreSQL database and its contents, storage, and other services in the group.
In a new terminal, load the lab settings first. Check that the group name, subscription ID in id, and workshop-id tag match GROUP, SUBSCRIPTION, and WORKSHOP_ID.
az group show --subscription "$SUBSCRIPTION" --name "$GROUP" --output json
Review the resources Azure will delete with this group.
az resource list --subscription "$SUBSCRIPTION" --resource-group "$GROUP" --query '[].{Name:name,Type:type}' --output table
If you created AKS, look up its node resource group before deleting the lab. Azure removes the node group with the cluster. Note the printed name for the final check.
$NODE_GROUP = az aks show --subscription "$SUBSCRIPTION" --resource-group "$GROUP" --name "$STEM-aks" --query nodeResourceGroup --output tsv
echo "NODE_GROUP=$NODE_GROUP"
NODE_GROUP=$(az aks show --subscription "$SUBSCRIPTION" --resource-group "$GROUP" --name "$STEM-aks" --query nodeResourceGroup --output tsv)
echo "NODE_GROUP=$NODE_GROUP"
When the group and resource list match your lab, submit the deletion and confirm at the Azure CLI prompt. --no-wait returns while Azure deletes the resources. Azure CLI reference
az group delete --subscription "$SUBSCRIPTION" --name "$GROUP" --no-wait
Confirm the groups are gone
Repeat the group check until it prints false.
az group exists --subscription "$SUBSCRIPTION" --name "$GROUP" --output tsv
If you looked up a node group, check it too. Use the recorded name for NODE_GROUP if you reopened your terminal.
az group exists --subscription "$SUBSCRIPTION" --name "$NODE_GROUP" --output tsv
Soft delete and local cleanup
Key Vault has seven days of soft delete retention and App Configuration has one day. After you confirm Azure cleanup, remove the locally generated kubeconfig and TLS files from ai200-lab. Keep the application clones if you want to revisit the code.