Skip to content

Commit 21658f9

Browse files
committed
fix: update scripts and templates for improved deployments and role assignments
1 parent 4821eda commit 21658f9

16 files changed

Lines changed: 114 additions & 156 deletions

azd-hooks/predeploy.sh

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
#!/bin/bash
1+
#!/usr/bin/env sh
22

33
##########################################################
44
# Ensure Helm and Kustomize support is enabled
@@ -8,7 +8,7 @@ azd config set alpha.aks.kustomize on
88

99
# Check kubelogin and install if not exists
1010
##########################################################
11-
if ! command -v kubelogin &> /dev/null; then
11+
if ! command -v kubelogin >/dev/null 2>&1; then
1212
echo "kubelogin could not be found. Installing kubelogin..."
1313
az aks install-cli
1414
fi

azd-hooks/preprovision.ps1

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,8 @@
11
#!/usr/bin/env pwsh
22

3+
azd config set alpha.aks.helm on
4+
azd config set alpha.aks.kustomize on
5+
36
Write-Host "Ensuring providers/features are registered and Azure CLI extensions are installed"
47

58
az provider register --namespace "Microsoft.ContainerService"
@@ -56,4 +59,9 @@ az provider register -n Microsoft.ContainerService
5659

5760
# add azure cli extensions
5861
az extension add --upgrade --name aks-preview
59-
az extension add --upgrade --name amg
62+
az extension add --upgrade --name amg
63+
64+
# if BUILD_CONTAINERS is set to true, set the DEPLOY_AZURE_CONTAINER_REGISTRY to true
65+
if ($env:BUILD_CONTAINERS -eq "true") {
66+
azd env set DEPLOY_AZURE_CONTAINER_REGISTRY true
67+
}

azd-hooks/preprovision.sh

Lines changed: 18 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,52 +1,55 @@
1-
#!/bin/bash
1+
#!/usr/bin/env sh
2+
3+
azd config set alpha.aks.helm on
4+
azd config set alpha.aks.kustomize on
25

36
echo "Ensuring providers/features are registered and Azure CLI extensions are installed"
47

58
az provider register --namespace "Microsoft.ContainerService"
6-
while [[ $(az provider show --namespace "Microsoft.ContainerService" --query "registrationState" -o tsv) != "Registered" ]]; do
9+
while [ "$(az provider show --namespace "Microsoft.ContainerService" --query "registrationState" -o tsv)" != "Registered" ]; do
710
echo "Waiting for Microsoft.ContainerService provider registration..."
811
sleep 3
912
done
1013

1114
az provider register --namespace "Microsoft.KeyVault"
12-
while [[ $(az provider show --namespace "Microsoft.KeyVault" --query "registrationState" -o tsv) != "Registered" ]]; do
15+
while [ "$(az provider show --namespace "Microsoft.KeyVault" --query "registrationState" -o tsv)" != "Registered" ]; do
1316
echo "Waiting for Microsoft.KeyVault provider registration..."
1417
sleep 3
1518
done
1619

1720
az provider register --namespace "Microsoft.CognitiveServices"
18-
while [[ $(az provider show --namespace "Microsoft.CognitiveServices" --query "registrationState" -o tsv) != "Registered" ]]; do
21+
while [ "$(az provider show --namespace "Microsoft.CognitiveServices" --query "registrationState" -o tsv)" != "Registered" ]; do
1922
echo "Waiting for Microsoft.CognitiveServices provider registration..."
2023
sleep 3
2124
done
2225

2326
az provider register --namespace "Microsoft.ServiceBus"
24-
while [[ $(az provider show --namespace "Microsoft.ServiceBus" --query "registrationState" -o tsv) != "Registered" ]]; do
27+
while [ "$(az provider show --namespace "Microsoft.ServiceBus" --query "registrationState" -o tsv)" != "Registered" ]; do
2528
echo "Waiting for Microsoft.ServiceBus provider registration..."
2629
sleep 3
2730
done
2831

2932
az provider register --namespace "Microsoft.DocumentDB"
30-
while [[ $(az provider show --namespace "Microsoft.DocumentDB" --query "registrationState" -o tsv) != "Registered" ]]; do
33+
while [ "$(az provider show --namespace "Microsoft.DocumentDB" --query "registrationState" -o tsv)" != "Registered" ]; do
3134
echo "Waiting for Microsoft.DocumentDB provider registration..."
3235
sleep 3
3336
done
3437

3538
az provider register --namespace "Microsoft.OperationalInsights"
36-
while [[ $(az provider show --namespace "Microsoft.OperationalInsights" --query "registrationState" -o tsv) != "Registered" ]]; do
39+
while [ "$(az provider show --namespace "Microsoft.OperationalInsights" --query "registrationState" -o tsv)" != "Registered" ]; do
3740
echo "Waiting for Microsoft.OperationalInsights provider registration..."
3841
sleep 3
3942
done
4043

4144
az provider register --namespace "Microsoft.AlertsManagement"
42-
while [[ $(az provider show --namespace "Microsoft.AlertsManagement" --query "registrationState" -o tsv) != "Registered" ]]; do
45+
while [ "$(az provider show --namespace "Microsoft.AlertsManagement" --query "registrationState" -o tsv)" != "Registered" ]; do
4346
echo "Waiting for Microsoft.AlertsManagement provider registration..."
4447
sleep 3
4548
done
4649

4750
echo "Ensuring preview features are registered"
4851
az feature register --namespace "Microsoft.ContainerService" --name "AzureMonitorMetricsControlPlanePreview"
49-
while [[ $(az feature show --namespace "Microsoft.ContainerService" --name "AzureMonitorMetricsControlPlanePreview" --query "properties.state" -o tsv) != "Registered" ]]; do
52+
while [ "$(az feature show --namespace "Microsoft.ContainerService" --name "AzureMonitorMetricsControlPlanePreview" --query "properties.state" -o tsv)" != "Registered" ]; do
5053
echo "Waiting for AzureMonitorMetricsControlPlanePreview feature registration..."
5154
sleep 3
5255
done
@@ -56,4 +59,9 @@ az provider register -n Microsoft.ContainerService
5659

5760
# add azure cli extensions
5861
az extension add --upgrade --name aks-preview
59-
az extension add --upgrade --name amg
62+
az extension add --upgrade --name amg
63+
64+
# if BUILD_CONTAINERS is set to true, set the DEPLOY_AZURE_CONTAINER_REGISTRY to true
65+
if [ "$BUILD_CONTAINERS" = "true" ]; then
66+
azd env set DEPLOY_AZURE_CONTAINER_REGISTRY true
67+
fi

infra/bicep/cosmosdb.bicep

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ param servicePrincipalId string
77
param tags object
88

99
// https://github.com/Azure/bicep-registry-modules/tree/main/avm/res/document-db/database-account
10+
// https://mcr.microsoft.com/v2/bicep/avm/res/document-db/database-account/tags/list
1011
module databaseAccount 'br/public:avm/res/document-db/database-account:0.11.3' = {
1112
name: 'databaseAccountDeployment'
1213
params: {

infra/bicep/kubernetes.bicep

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,8 @@ param configureMonitorSettings bool = false
1111
param tags object
1212

1313
// https://github.com/Azure/bicep-registry-modules/tree/main/avm/res/container-service/managed-cluster
14-
module managedCluster 'br/public:avm/res/container-service/managed-cluster:0.8.3' = {
14+
// https://mcr.microsoft.com/v2/bicep/avm/res/container-service/managed-cluster/tags/list
15+
module managedCluster 'br/public:avm/res/container-service/managed-cluster:0.9.0' = {
1516
name: 'managedClusterDeployment'
1617
params: {
1718
name: 'aks-${nameSuffix}'
@@ -91,6 +92,7 @@ module managedCluster 'br/public:avm/res/container-service/managed-cluster:0.8.3
9192
}
9293

9394
// https://github.com/Azure/bicep-registry-modules/tree/main/avm/res/container-registry/registry
95+
// https://mcr.microsoft.com/v2/bicep/avm/res/container-registry/registry/tags/list
9496
module registry 'br/public:avm/res/container-registry/registry:0.9.1' = if (deployAcr) {
9597
name: 'registryDeployment'
9698
params: {

infra/bicep/main.bicep

Lines changed: 20 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -100,8 +100,8 @@ module aks 'kubernetes.bicep' = {
100100
nameSuffix: name
101101
vmSku: aksNodePoolVMSize
102102
deployAcr: deployAzureContainerRegistry
103-
logsWorkspaceResourceId: deployObservabilityTools ? observability.outputs.logsWorkspaceResourceId : ''
104-
metricsWorkspaceResourceId: deployObservabilityTools ? observability.outputs.metricsWorkspaceResourceId : ''
103+
logsWorkspaceResourceId: deployObservabilityTools ? observability!.outputs.logsWorkspaceResourceId : ''
104+
metricsWorkspaceResourceId: deployObservabilityTools ? observability!.outputs.metricsWorkspaceResourceId : ''
105105
currentUserObjectId: currentUserObjectId
106106
currentIpAddress: currentIpAddress
107107
configureMonitorSettings: deployObservabilityTools
@@ -145,7 +145,7 @@ module servicebus 'servicebus.bicep' = if (deployAzureServiceBus) {
145145
nameSuffix: name
146146
currentUserObjectId: currentUserObjectId
147147
currentIpAddress: currentIpAddress
148-
servicePrincipalId: workloadidentity.outputs.principalId
148+
servicePrincipalId: workloadidentity!.outputs.principalId
149149
tags: tags
150150
}
151151
}
@@ -156,9 +156,9 @@ module cosmosdb 'cosmosdb.bicep' = if (deployAzureCosmosDB) {
156156
params: {
157157
nameSuffix: name
158158
accountKind: cosmosDBAccountKind
159-
identityPrincipalId: workloadidentity.outputs.principalId
159+
identityPrincipalId: workloadidentity!.outputs.principalId
160160
currentIpAddress: currentIpAddress
161-
servicePrincipalId: workloadidentity.outputs.principalId
161+
servicePrincipalId: workloadidentity!.outputs.principalId
162162
tags: tags
163163
}
164164
}
@@ -182,7 +182,7 @@ module openai 'openai.bicep' = if (deployAzureOpenAI) {
182182
location: azureOpenAILocation
183183
currentUserObjectId: currentUserObjectId
184184
currentIpAddress: currentIpAddress
185-
servicePrincipalId: workloadidentity.outputs.principalId
185+
servicePrincipalId: workloadidentity!.outputs.principalId
186186
modelDeployments: modelDeployments
187187
tags: tags
188188
}
@@ -195,28 +195,32 @@ output AZURE_AKS_CLUSTER_NAME string = aks.outputs.name
195195
output AZURE_AKS_NAMESPACE string = k8sNamespace
196196
output AZURE_AKS_CLUSTER_ID string = aks.outputs.id
197197
output AZURE_AKS_OIDC_ISSUER_URL string = aks.outputs.oidcIssuerUrl
198-
output AZURE_OPENAI_ENDPOINT string = deployAzureOpenAI ? openai.outputs.endpoint : ''
198+
output AZURE_OPENAI_ENDPOINT string = deployAzureOpenAI ? openai!.outputs.endpoint : ''
199199
output AZURE_OPENAI_MODEL_NAME string = deployAzureOpenAI ? chatCompletionModelName : ''
200200
output AZURE_OPENAI_DALL_E_MODEL_NAME string = deployAzureOpenAI && deployImageGenerationModel
201201
? imageGenerationModelName
202202
: ''
203203
output AZURE_OPENAI_DALL_E_ENDPOINT string = deployAzureOpenAI && deployImageGenerationModel
204-
? openai.outputs.endpoint
204+
? openai!.outputs.endpoint
205205
: ''
206-
output AZURE_IDENTITY_NAME string = workloadidentity.outputs.name
207-
output AZURE_IDENTITY_CLIENT_ID string = workloadidentity.outputs.clientId
208-
output AZURE_SERVICE_BUS_HOST string = deployAzureServiceBus ? '${servicebus.outputs.name}.servicebus.windows.net' : ''
206+
output AZURE_IDENTITY_NAME string = (deployAzureCosmosDB || deployAzureServiceBus || deployAzureOpenAI)
207+
? workloadidentity!.outputs.name
208+
: ''
209+
output AZURE_IDENTITY_CLIENT_ID string = (deployAzureCosmosDB || deployAzureServiceBus || deployAzureOpenAI)
210+
? workloadidentity!.outputs.clientId
211+
: ''
212+
output AZURE_SERVICE_BUS_HOST string = deployAzureServiceBus ? '${servicebus!.outputs.name}.servicebus.windows.net' : ''
209213
output AZURE_SERVICE_BUS_URI string = deployAzureServiceBus
210-
? 'amqps://${servicebus.outputs.name}.servicebus.windows.net'
214+
? 'amqps://${servicebus!.outputs.name}.servicebus.windows.net'
211215
: ''
212-
output AZURE_COSMOS_DATABASE_NAME string = deployAzureCosmosDB ? cosmosdb.outputs.name : ''
216+
output AZURE_COSMOS_DATABASE_NAME string = deployAzureCosmosDB ? cosmosdb!.outputs.name : ''
213217
output AZURE_COSMOS_DATABASE_URI string = deployAzureCosmosDB && cosmosDBAccountKind == 'MongoDB'
214-
? 'mongodb://${cosmosdb.outputs.name}.mongo.cosmos.azure.com:10255/?retryWrites=false'
218+
? 'mongodb://${cosmosdb!.outputs.name}.mongo.cosmos.azure.com:10255/?retryWrites=false'
215219
: deployAzureCosmosDB && cosmosDBAccountKind == 'GlobalDocumentDB'
216-
? 'https://${cosmosdb.outputs.name}.documents.azure.com:443/'
220+
? 'https://${cosmosdb!.outputs.name}.documents.azure.com:443/'
217221
: ''
218222
output AZURE_COSMOS_DATABASE_LIST_CONNECTIONSTRINGS_URL string = deployAzureCosmosDB
219-
? '${environment().resourceManager}${cosmosdb.outputs.id}/listConnectionStrings?api-version=2021-04-15'
223+
? '${environment().resourceManager}${cosmosdb!.outputs.id}/listConnectionStrings?api-version=2021-04-15'
220224
: ''
221225
output AZURE_DATABASE_API string = cosmosDBAccountKind == 'MongoDB' ? 'mongodb' : 'cosmosdbsql'
222226
output AZURE_CONTAINER_REGISTRY_NAME string = deployAzureContainerRegistry ? aks.outputs.registryName : ''

infra/bicep/main.parameters.json

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -18,30 +18,30 @@
1818
"value": "${AKS_NODE_POOL_VM_SIZE}"
1919
},
2020
"deployAzureContainerRegistry": {
21-
"value": "${DEPLOY_AZURE_CONTAINER_REGISTRY=false}"
21+
"value": "${DEPLOY_AZURE_CONTAINER_REGISTRY}"
2222
},
2323
"deployAzureServiceBus": {
24-
"value": "${DEPLOY_AZURE_SERVICE_BUS=false}"
24+
"value": "${DEPLOY_AZURE_SERVICE_BUS}"
2525
},
2626
"deployObservabilityTools": {
27-
"value": "${DEPLOY_OBSERVABILITY_TOOLS=false}"
27+
"value": "${DEPLOY_OBSERVABILITY_TOOLS}"
2828
},
2929
"deployAzureCosmosDB": {
30-
"value": "${DEPLOY_AZURE_COSMOSDB=false}"
30+
"value": "${DEPLOY_AZURE_COSMOSDB}"
3131
},
3232
"cosmosDBAccountKind": {
3333
"value": "${AZURE_COSMOSDB_ACCOUNT_KIND=GlobalDocumentDB}"
3434
},
3535
"deployAzureOpenAI": {
36-
"value": "${DEPLOY_AZURE_OPENAI=false}"
36+
"value": "${DEPLOY_AZURE_OPENAI}"
3737
},
3838
"azureOpenAILocation": {
3939
"value": "${AZURE_OPENAI_LOCATION}"
4040
},
4141
"deployImageGenerationModel": {
42-
"value": "${DEPLOY_AZURE_OPENAI_DALL_E_MODEL=false}"
42+
"value": "${DEPLOY_AZURE_OPENAI_DALL_E_MODEL}"
4343
},
44-
"source_registry": {
44+
"sourceRegistry": {
4545
"value": "${SOURCE_REGISTRY}"
4646
}
4747
}

infra/bicep/openai.bicep

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,8 @@ param modelDeployments array = []
88
param tags object
99

1010
// https://github.com/Azure/bicep-registry-modules/tree/main/avm/res/cognitive-services/account
11-
module cognitiveServicesAccount 'br/public:avm/res/cognitive-services/account:0.10.1' = {
11+
// https://mcr.microsoft.com/v2/bicep/avm/res/cognitive-services/account/tags/list
12+
module cognitiveServicesAccount 'br/public:avm/res/cognitive-services/account:0.13.1' = {
1213
name: 'accountDeployment'
1314
params: {
1415
name: 'aoai-${nameSuffix}'

infra/bicep/servicebus.bicep

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,8 @@ param servicePrincipalId string
66
param tags object
77

88
// https://github.com/Azure/bicep-registry-modules/tree/main/avm/res/service-bus/namespace
9-
module serviceBusNamespace 'br/public:avm/res/service-bus/namespace:0.13.2' = {
9+
// https://mcr.microsoft.com/v2/bicep/avm/res/service-bus/namespace/tags/list
10+
module serviceBusNamespace 'br/public:avm/res/service-bus/namespace:0.15.0' = {
1011
name: 'namespaceDeployment'
1112
params: {
1213
name: 'sb-${nameSuffix}'

infra/bicep/workloadidentity.bicep

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ type federatedCredential = {
1010
subject: string
1111
}
1212

13-
module userAssignedIdentity 'br/public:avm/res/managed-identity/user-assigned-identity:0.4.0' = {
13+
module userAssignedIdentity 'br/public:avm/res/managed-identity/user-assigned-identity:0.4.1' = {
1414
name: 'userAssignedIdentityDeployment'
1515
params: {
1616
name: 'mi-${nameSuffix}'

0 commit comments

Comments
 (0)