Skip to content

Commit ad1416a

Browse files
committed
fix: several changes to handle all azd deployment options (more below)
feat: bring back azd-hooks and preprovision script for azure provider registration and cli extension installation chore: remove azure-bicep.yaml file and add azure-build-from-source.yaml with bicep options commented chore: introduce azure-build-from-source.yaml for building images from source and deploying with kustomize (for e2e testing) refactor: revert azure.yaml to deploy with helm (better for non-e2e testing deployments) docs: enhance azd.md documentation for clarity on deployment options and environment variables fix: modify bicep parameters to default to false for observability tools and azure services chore: upgrade terraform provider versions in .terraform.lock.hcl for improved stability fix: update terraform main.tf and outputs.tf to correctly handle source registry and outputs
1 parent d7113aa commit ad1416a

18 files changed

Lines changed: 846 additions & 303 deletions

.github/workflows/test-e2e-main.yaml

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -51,17 +51,19 @@ jobs:
5151
- name: Turn on Helm support for azd
5252
run: azd config set alpha.aks.helm on
5353

54+
- name: Swap azd config files to build from source
55+
run: |
56+
mv azure.yaml azure.yaml.bak
57+
mv azure-build-from-source.yaml azure.yaml
58+
5459
- name: Provision and deploy
5560
id: provision_deploy
5661
continue-on-error: true
5762
run: |
5863
azd env new ${{ vars.AZURE_ENV_NAME }}
59-
azd env set AKS_NODE_POOL_VM_SIZE Standard_D2_v4
60-
azd env set BUILD_CONTAINERS false
6164
azd env set DEPLOY_AZURE_CONTAINER_REGISTRY true
6265
azd env set DEPLOY_AZURE_OPENAI true
6366
azd env set AZURE_OPENAI_LOCATION ${{ vars.AZURE_LOCATION }}
64-
azd env set DEPLOY_AZURE_OPENAI_DALL_E_MODEL false
6567
azd env set DEPLOY_AZURE_SERVICE_BUS true
6668
azd env set DEPLOY_AZURE_COSMOSDB true
6769
azd env set AZURE_COSMOSDB_ACCOUNT_KIND MongoDB

.github/workflows/test-e2e-pr.yml

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -102,14 +102,17 @@ jobs:
102102
- name: Turn on Kustomize support
103103
run: azd config set alpha.aks.kustomize on
104104

105+
- name: Swap azd config files to build from source
106+
run: |
107+
mv azure.yaml azure.yaml.bak
108+
mv azure-build-from-source.yaml azure.yaml
109+
105110
- name: Provision resources and deploy app
106111
run: |
107112
azd env new ${{ vars.AZURE_ENV_NAME }}
108-
azd env set AKS_NODE_POOL_VM_SIZE Standard_D2_v4
109113
azd env set DEPLOY_AZURE_CONTAINER_REGISTRY true
110114
azd env set DEPLOY_AZURE_OPENAI true
111115
azd env set AZURE_OPENAI_LOCATION ${{ vars.AZURE_LOCATION }}
112-
azd env set DEPLOY_AZURE_OPENAI_DALL_E_MODEL false
113116
azd env set DEPLOY_AZURE_SERVICE_BUS true
114117
azd env set DEPLOY_AZURE_COSMOSDB true
115118
azd env set AZURE_COSMOSDB_ACCOUNT_KIND MongoDB

azd-hooks/postdeploy.ps1

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
#!/usr/bin/env pwsh
2+
3+
############################################
4+
# Delete custom-values.yaml
5+
############################################
6+
Remove-Item -Path custom-values.yaml -ErrorAction SilentlyContinue

azd-hooks/postdeploy.sh

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
#!/bin/bash
2+
3+
############################################
4+
# Delete custom-values.yaml
5+
############################################
6+
rm custom-values.yaml

azd-hooks/postprovision.ps1

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
#!/usr/bin/env pwsh
2+
3+
$services=@("ai-service", "makeline-service", "order-service", "product-service", "store-admin", "store-front", "virtual-customer", "virtual-worker")
4+
5+
if (($env:DEPLOY_AZURE_CONTAINER_REGISTRY -like "true") -and ($env:BUILD_CONTAINERS -like "true")) {
6+
echo "Build container images"
7+
foreach ($service in $services) {
8+
echo "Building aks-store-demo/${service}:latest"
9+
az acr build --registry $env:AZURE_CONTAINER_REGISTRY_NAME --image aks-store-demo/${service}:latest ./src/${service}/
10+
}
11+
}
12+
elseif (($env:DEPLOY_AZURE_CONTAINER_REGISTRY -like "true") -and ($env:BUILD_CONTAINERS -like "false")) {
13+
echo "Import container images"
14+
foreach ($service in $services) {
15+
echo "Importing aks-store-demo/${service}:latest"
16+
az acr import --name $env:AZURE_CONTAINER_REGISTRY_NAME --source ghcr.io/azure-samples/aks-store-demo/${service}:latest --image aks-store-demo/${service}:latest
17+
}
18+
}
19+
else {
20+
echo "No BUILD_CONTAINERS variable set, skipping container build/import"
21+
}
22+

azd-hooks/postprovision.sh

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
#!/bin/bash
2+
3+
services=("ai-service" "makeline-service" "order-service" "product-service" "store-admin" "store-front" "virtual-customer" "virtual-worker")
4+
5+
if [ "$DEPLOY_AZURE_CONTAINER_REGISTRY" == "true" ] && [ "$BUILD_CONTAINERS" == "true" ]; then
6+
echo "Build container images"
7+
for service in "${services[@]}"; do
8+
echo "Building aks-store-demo/${service}:latest"
9+
az acr build --registry ${AZURE_CONTAINER_REGISTRY_NAME} --image aks-store-demo/${service}:latest ./src/${service}/
10+
done
11+
elif [ "$DEPLOY_AZURE_CONTAINER_REGISTRY" == "true" ] && ([ -z "$BUILD_CONTAINERS" ] || [ "$BUILD_CONTAINERS" == "false" ]); then
12+
echo "Import container images"
13+
for service in "${services[@]}"; do
14+
echo "Importing aks-store-demo/${service}:latest"
15+
az acr import --name ${AZURE_CONTAINER_REGISTRY_NAME} --source ghcr.io/azure-samples/aks-store-demo/${service}:latest --image aks-store-demo/${service}:latest
16+
done
17+
else
18+
echo "No BUILD_CONTAINERS variable set, skipping container build/import"
19+
fi

azd-hooks/predeploy.ps1

Lines changed: 136 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,136 @@
1+
#!/usr/bin/env pwsh
2+
3+
##########################################################
4+
# Ensure Helm and Kustomize support is enabled
5+
##########################################################
6+
azd config set alpha.aks.helm on
7+
azd config set alpha.aks.kustomize on
8+
9+
##########################################################
10+
# Check kubelogin and install if not exists
11+
##########################################################
12+
if (-not (Get-Command kubelogin -ErrorAction SilentlyContinue)) {
13+
az aks install-cli
14+
}
15+
16+
###########################################################
17+
# Create the custom-values.yaml file
18+
###########################################################
19+
@"
20+
namespace: ${env:AZURE_AKS_NAMESPACE}
21+
"@ | Out-File -FilePath custom-values.yaml -Encoding utf8
22+
23+
###########################################################
24+
# Add Azure Managed Identity and set to use AzureAD auth
25+
###########################################################
26+
if (![string]::IsNullOrEmpty($env:AZURE_IDENTITY_CLIENT_ID) -and ![string]::IsNullOrEmpty($env:AZURE_IDENTITY_NAME)) {
27+
@"
28+
useAzureAd: true
29+
managedIdentityName: $($env:AZURE_IDENTITY_NAME)
30+
managedIdentityClientId: $($env:AZURE_IDENTITY_CLIENT_ID)
31+
"@ | Out-File -FilePath custom-values.yaml -Append -Encoding utf8
32+
}
33+
34+
###########################################################
35+
# Add base images
36+
###########################################################
37+
@"
38+
namespace: ${env:AZURE_AKS_NAMESPACE}
39+
productService:
40+
image:
41+
repository: ${env:SOURCE_REGISTRY}/aks-store-demo/product-service
42+
storeAdmin:
43+
image:
44+
repository: ${env:SOURCE_REGISTRY}/aks-store-demo/store-admin
45+
storeFront:
46+
image:
47+
repository: ${env:SOURCE_REGISTRY}/aks-store-demo/store-front
48+
virtualCustomer:
49+
image:
50+
repository: ${env:SOURCE_REGISTRY}/aks-store-demo/virtual-customer
51+
virtualWorker:
52+
image:
53+
repository: ${env:SOURCE_REGISTRY}/aks-store-demo/virtual-worker
54+
"@ | Out-File -FilePath custom-values.yaml -Append -Encoding utf8
55+
56+
###########################################################
57+
# Add ai-service if Azure OpenAI endpoint is provided
58+
###########################################################
59+
if ($env:AZURE_OPENAI_ENDPOINT) {
60+
@"
61+
aiService:
62+
image:
63+
repository: ${env:SOURCE_REGISTRY}/aks-store-demo/ai-service
64+
create: true
65+
modelDeploymentName: ${env:AZURE_OPENAI_MODEL_NAME}
66+
openAiEndpoint: ${env:AZURE_OPENAI_ENDPOINT}
67+
useAzureOpenAi: true
68+
"@ | Out-File -FilePath custom-values.yaml -Append -Encoding utf8
69+
70+
# If DALL-E model endpoint and name exist
71+
if ($env:AZURE_OPENAI_DALL_E_ENDPOINT -and $env:AZURE_OPENAI_DALL_E_MODEL_NAME) {
72+
@"
73+
openAiDalleEndpoint: ${env:AZURE_OPENAI_DALL_E_ENDPOINT}
74+
openAiDalleModelName: ${env:AZURE_OPENAI_DALL_E_MODEL_NAME}
75+
"@ | Out-File -FilePath custom-values.yaml -Append -Encoding utf8
76+
}
77+
}
78+
79+
###########################################################
80+
# Add order-service
81+
###########################################################
82+
@"
83+
orderService:
84+
image:
85+
repository: ${env:SOURCE_REGISTRY}/aks-store-demo/order-service
86+
"@ | Out-File -FilePath custom-values.yaml -Append -Encoding utf8
87+
88+
# Add Azure Service Bus to order-service if provided
89+
if ($env:AZURE_SERVICE_BUS_HOST) {
90+
@"
91+
queueHost: ${env:AZURE_SERVICE_BUS_HOST}
92+
"@ | Out-File -FilePath custom-values.yaml -Append -Encoding utf8
93+
}
94+
95+
###########################################################
96+
# Add makeline-service
97+
###########################################################
98+
@"
99+
makelineService:
100+
image:
101+
repository: ${env:SOURCE_REGISTRY}/aks-store-demo/makeline-service
102+
"@ | Out-File -FilePath custom-values.yaml -Append -Encoding utf8
103+
104+
# Add Azure Service Bus to makeline-service if provided
105+
# (Parity with bash: check URI presence but write HOST value)
106+
if ($env:AZURE_SERVICE_BUS_URI) {
107+
@"
108+
orderQueueHost: ${env:AZURE_SERVICE_BUS_HOST}
109+
"@ | Out-File -FilePath custom-values.yaml -Append -Encoding utf8
110+
}
111+
112+
# Add Azure Cosmos DB to makeline-service if provided
113+
if ($env:AZURE_COSMOS_DATABASE_URI) {
114+
@"
115+
orderDBApi: ${env:AZURE_DATABASE_API}
116+
orderDBUri: ${env:AZURE_COSMOS_DATABASE_URI}
117+
"@ | Out-File -FilePath custom-values.yaml -Append -Encoding utf8
118+
}
119+
120+
###########################################################
121+
# Do not deploy RabbitMQ when using Azure Service Bus
122+
###########################################################
123+
if ($env:AZURE_SERVICE_BUS_HOST) {
124+
@"
125+
useRabbitMQ: false
126+
"@ | Out-File -FilePath custom-values.yaml -Append -Encoding utf8
127+
}
128+
129+
###########################################################
130+
# Do not deploy MongoDB when using Azure Cosmos DB
131+
###########################################################
132+
if ($env:AZURE_COSMOS_DATABASE_URI) {
133+
@"
134+
useMongoDB: false
135+
"@ | Out-File -FilePath custom-values.yaml -Append -Encoding utf8
136+
}

azd-hooks/predeploy.sh

Lines changed: 138 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,138 @@
1+
#!/bin/bash
2+
3+
##########################################################
4+
# Ensure Helm and Kustomize support is enabled
5+
##########################################################
6+
azd config set alpha.aks.helm on
7+
azd config set alpha.aks.kustomize on
8+
9+
# Check kubelogin and install if not exists
10+
##########################################################
11+
if ! command -v kubelogin &> /dev/null; then
12+
echo "kubelogin could not be found. Installing kubelogin..."
13+
az aks install-cli
14+
fi
15+
16+
##########################################################
17+
# Create the custom-values.yaml file
18+
##########################################################
19+
cat << EOF > custom-values.yaml
20+
namespace: ${AZURE_AKS_NAMESPACE}
21+
EOF
22+
23+
###########################################################
24+
# Add Azure Managed Identity and set to use AzureAD auth
25+
###########################################################
26+
if [ -n "${AZURE_IDENTITY_CLIENT_ID}" ] && [ -n "${AZURE_IDENTITY_NAME}" ]; then
27+
cat << EOF >> custom-values.yaml
28+
useAzureAd: true
29+
managedIdentityName: ${AZURE_IDENTITY_NAME}
30+
managedIdentityClientId: ${AZURE_IDENTITY_CLIENT_ID}
31+
EOF
32+
fi
33+
34+
##########################################################
35+
# Add base images
36+
##########################################################
37+
cat << EOF >> custom-values.yaml
38+
namespace: ${AZURE_AKS_NAMESPACE}
39+
productService:
40+
image:
41+
repository: ${SOURCE_REGISTRY}/aks-store-demo/product-service
42+
storeAdmin:
43+
image:
44+
repository: ${SOURCE_REGISTRY}/aks-store-demo/store-admin
45+
storeFront:
46+
image:
47+
repository: ${SOURCE_REGISTRY}/aks-store-demo/store-front
48+
virtualCustomer:
49+
image:
50+
repository: ${SOURCE_REGISTRY}/aks-store-demo/virtual-customer
51+
virtualWorker:
52+
image:
53+
repository: ${SOURCE_REGISTRY}/aks-store-demo/virtual-worker
54+
EOF
55+
56+
###########################################################
57+
# Add ai-service if Azure OpenAI endpoint is provided
58+
###########################################################
59+
60+
if [ -n "${AZURE_OPENAI_ENDPOINT}" ]; then
61+
cat << EOF >> custom-values.yaml
62+
aiService:
63+
image:
64+
repository: ${SOURCE_REGISTRY}/aks-store-demo/ai-service
65+
create: true
66+
modelDeploymentName: ${AZURE_OPENAI_MODEL_NAME}
67+
openAiEndpoint: ${AZURE_OPENAI_ENDPOINT}
68+
useAzureOpenAi: true
69+
EOF
70+
71+
# If DALL-E model endpoint and name exists
72+
if [ -n "${AZURE_OPENAI_DALL_E_ENDPOINT}" ] && [ -n "${AZURE_OPENAI_DALL_E_MODEL_NAME}" ]; then
73+
cat << EOF >> custom-values.yaml
74+
openAiDalleEndpoint: ${AZURE_OPENAI_DALL_E_ENDPOINT}
75+
openAiDalleModelName: ${AZURE_OPENAI_DALL_E_MODEL_NAME}
76+
EOF
77+
fi
78+
fi
79+
80+
###########################################################
81+
# Add order-service
82+
###########################################################
83+
84+
cat << EOF >> custom-values.yaml
85+
orderService:
86+
image:
87+
repository: ${SOURCE_REGISTRY}/aks-store-demo/order-service
88+
EOF
89+
90+
# Add Azure Service Bus to order-service if provided
91+
if [ -n "${AZURE_SERVICE_BUS_HOST}" ]; then
92+
cat << EOF >> custom-values.yaml
93+
queueHost: ${AZURE_SERVICE_BUS_HOST}
94+
EOF
95+
fi
96+
97+
###########################################################
98+
# Add makeline-service
99+
###########################################################
100+
101+
cat << EOF >> custom-values.yaml
102+
makelineService:
103+
image:
104+
repository: ${SOURCE_REGISTRY}/aks-store-demo/makeline-service
105+
EOF
106+
107+
# Add Azure Service Bus to makeline-service if provided
108+
if [ -n "${AZURE_SERVICE_BUS_URI}" ]; then
109+
cat << EOF >> custom-values.yaml
110+
orderQueueHost: ${AZURE_SERVICE_BUS_HOST}
111+
EOF
112+
fi
113+
114+
# Add Azure Cosmos DB to makeline-service if provided
115+
if [ -n "${AZURE_COSMOS_DATABASE_URI}" ]; then
116+
cat << EOF >> custom-values.yaml
117+
orderDBApi: ${AZURE_DATABASE_API}
118+
orderDBUri: ${AZURE_COSMOS_DATABASE_URI}
119+
EOF
120+
fi
121+
122+
###########################################################
123+
# Do not deploy RabbitMQ when using Azure Service Bus
124+
###########################################################
125+
if [ -n "${AZURE_SERVICE_BUS_HOST}" ]; then
126+
cat << EOF >> custom-values.yaml
127+
useRabbitMQ: false
128+
EOF
129+
fi
130+
131+
###########################################################
132+
# Do not deploy MongoDB when using Azure Cosmos DB
133+
###########################################################
134+
if [ -n "${AZURE_COSMOS_DATABASE_URI}" ]; then
135+
cat << EOF >> custom-values.yaml
136+
useMongoDB: false
137+
EOF
138+
fi

0 commit comments

Comments
 (0)