Skip to content

Commit 50c38ba

Browse files
update post deployment scripts for avm deployment
1 parent dcd3799 commit 50c38ba

3 files changed

Lines changed: 103 additions & 9 deletions

File tree

Deployment/resourcedeployment.ps1

Lines changed: 82 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,16 @@
1-
# Copyright (c) Microsoft Corporation.
1+
# Copyright (c) Microsoft Corporation.
22
# Licensed under the MIT license.
33

44
#https://patorjk.com/software/taag
5+
6+
7+
param (
8+
[Parameter(Mandatory=$false)]
9+
[string]$ResourceGroupName
10+
)
11+
12+
Write-Host "DEBUG: ResourceGroupName parameter received: '$ResourceGroupName'" -ForegroundColor Magenta
13+
514
function startBanner() {
615
Write-Host " _____ _ "
716
Write-Host " | __ \ | | "
@@ -195,7 +204,10 @@ function Show-Banner {
195204
}
196205

197206
# Get all environment values
198-
$envValues = azd env get-values --output json | ConvertFrom-Json
207+
if (!$ResourceGroupName) {
208+
$envValues = azd env get-values --output json | ConvertFrom-Json
209+
}
210+
199211
function Get-AzdEnvValueOrDefault {
200212
param (
201213
[Parameter(Mandatory = $true)]
@@ -290,7 +302,7 @@ class DeploymentResult {
290302

291303
}
292304

293-
[void]MapResult() {
305+
[void]MapResultAzd() {
294306

295307
# Replace direct $envValues lookups with function calls
296308
$this.TenantId = Get-AzdEnvValueOrDefault -KeyName "AZURE_TENANT_ID" -Required $true
@@ -335,6 +347,63 @@ class DeploymentResult {
335347
$this.AzAppConfigEndpoint = Get-AzdEnvValueOrDefault -KeyName "AZURE_APP_CONFIG_ENDPOINT"
336348
$this.AzAppConfigName = Get-AzdEnvValueOrDefault -KeyName "AZURE_APP_CONFIG_NAME"
337349
}
350+
351+
[void]MapResultAz([string]$resourceGroupName) {
352+
# Get deployment outputs
353+
$deploymentName=$(az group show --name "$resourceGroupName" --query "tags.DeploymentName" -o tsv)
354+
$deploymentOutputs=$(az deployment group show --resource-group "$resourceGroupName" --name "$deploymentName" --query "properties.outputs" -o json | ConvertFrom-Json)
355+
356+
$this.TenantId = $deploymentOutputs.azurE_TENANT_ID.value
357+
if (!$this.TenantId) {
358+
$this.TenantId = $(az account show --query tenantId -o tsv)
359+
}
360+
361+
$this.SubscriptionId = $(az account show --query id -o tsv)
362+
363+
# Resource Group
364+
$this.ResourceGroupName = $resourceGroupName
365+
$this.ResourceGroupId = $deploymentOutputs.azurE_RESOURCE_GROUP_ID.value
366+
if (!$this.ResourceGroupId) {
367+
Write-Error "Required value 'AZURE_RESOURCE_GROUP_ID' not found in the deployment outputs."
368+
exit 1
369+
}
370+
371+
# Storage Account
372+
$this.StorageAccountName = $deploymentOutputs.storagE_ACCOUNT_NAME.value
373+
374+
# Search Service
375+
$this.AzSearchServiceName = $deploymentOutputs.azurE_SEARCH_SERVICE_NAME.value
376+
$this.AzSearchServicEndpoint = "https://$($this.AzSearchServiceName).search.windows.net"
377+
378+
# AKS
379+
$this.AksName = $deploymentOutputs.azurE_AKS_NAME.value
380+
$this.AksMid = $deploymentOutputs.azurE_AKS_MI_ID.value
381+
382+
# Container Registry
383+
$this.AzContainerRegistryName = $deploymentOutputs.azurE_CONTAINER_REGISTRY_NAME.value
384+
385+
# Cognitive Service - Azure AI Document Intelligence Service
386+
$this.AzCognitiveServiceName = $deploymentOutputs.azurE_COGNITIVE_SERVICE_NAME.value
387+
$this.AzCognitiveServiceEndpoint = $deploymentOutputs.azurE_COGNITIVE_SERVICE_ENDPOINT.value
388+
389+
# Open AI Service
390+
$this.AzOpenAiServiceName = $deploymentOutputs.azurE_OPENAI_SERVICE_NAME.value
391+
$this.AzOpenAiServiceEndpoint = $deploymentOutputs.azurE_OPENAI_SERVICE_ENDPOINT.value
392+
393+
# Cosmos DB
394+
$this.AzCosmosDBName = $deploymentOutputs.azurE_COSMOSDB_NAME.value
395+
396+
# Open AI Service Models
397+
$this.AzGPT4oModelName = $deploymentOutputs.aZ_GPT4O_MODEL_NAME.value
398+
$this.AzGPT4oModelId = $deploymentOutputs.aZ_GPT4O_MODEL_ID.value
399+
$this.AzGPTEmbeddingModelName = $deploymentOutputs.aZ_GPT_EMBEDDING_MODEL_NAME.value
400+
$this.AzGPTEmbeddingModelId = $deploymentOutputs.aZ_GPT_EMBEDDING_MODEL_ID.value
401+
402+
# App Configuration
403+
$this.AzAppConfigEndpoint = $deploymentOutputs.azurE_APP_CONFIG_ENDPOINT.value
404+
$this.AzAppConfigName = $deploymentOutputs.azurE_APP_CONFIG_NAME.value
405+
406+
}
338407
}
339408

340409
function Check-Docker {
@@ -379,7 +448,16 @@ try {
379448
Write-Host "Retrieving the deployment details.....`r`n" -ForegroundColor Yellow
380449

381450
# Map the deployment result to DeploymentResult object from .env file
382-
$deploymentResult.MapResult()
451+
Write-Host "Mapping the deployment details.....`r`n" -ForegroundColor Yellow
452+
Write-Host "Resource Group Name: $ResourceGroupName" -ForegroundColor Yellow
453+
if ($ResourceGroupName) {
454+
Write-Host "Using provided resource group name: $ResourceGroupName" -ForegroundColor Yellow
455+
$deploymentResult.MapResultAz($ResourceGroupName.Trim())
456+
}
457+
else {
458+
Write-Host "Using azd environment." -ForegroundColor Yellow
459+
$deploymentResult.MapResultAzd()
460+
}
383461

384462
LoginAzure $deploymentResult.TenantId $deploymentResult.SubscriptionId
385463

infra/main.bicep

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -115,6 +115,7 @@ resource resourceGroupTags 'Microsoft.Resources/tags@2021-04-01' = {
115115
TemplateName: 'DKM'
116116
Type: enablePrivateNetworking ? 'WAF' : 'Non-WAF'
117117
CreatedBy: createdBy
118+
DeploymentName: deployment().name
118119
}
119120
}
120121
}

infra/main.json

Lines changed: 20 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
"_generator": {
77
"name": "bicep",
88
"version": "0.37.4.10188",
9-
"templateHash": "8418820476800736272"
9+
"templateHash": "9961501715940226850"
1010
}
1111
},
1212
"parameters": {
@@ -66,7 +66,7 @@
6666
},
6767
"gptModelCapacity": {
6868
"type": "int",
69-
"defaultValue": 150,
69+
"defaultValue": 100,
7070
"minValue": 10,
7171
"metadata": {
7272
"description": "Optional. Capacity of the GPT model deployment:"
@@ -183,6 +183,13 @@
183183
},
184184
"description": "Required. Location for AI Foundry deployment. This is the location where the AI Foundry resources will be deployed."
185185
}
186+
},
187+
"createdBy": {
188+
"type": "string",
189+
"defaultValue": "[if(contains(deployer(), 'userPrincipalName'), split(deployer().userPrincipalName, '@')[0], deployer().objectId)]",
190+
"metadata": {
191+
"description": "Optional created by user name"
192+
}
186193
}
187194
},
188195
"variables": {
@@ -285,6 +292,14 @@
285292
"applicationInsightsResourceName": "[format('appi-{0}', variables('solutionSuffix'))]"
286293
},
287294
"resources": {
295+
"resourceGroupTags": {
296+
"type": "Microsoft.Resources/tags",
297+
"apiVersion": "2021-04-01",
298+
"name": "default",
299+
"properties": {
300+
"tags": "[shallowMerge(createArray(parameters('tags'), createObject('TemplateName', 'DKM', 'Type', if(parameters('enablePrivateNetworking'), 'WAF', 'Non-WAF'), 'CreatedBy', parameters('createdBy'), 'DeploymentName', deployment().name)))]"
301+
}
302+
},
288303
"avmPrivateDnsZones": {
289304
"copy": {
290305
"name": "avmPrivateDnsZones",
@@ -39783,8 +39798,8 @@
3978339798
}
3978439799
},
3978539800
"dependsOn": [
39786-
"[format('avmPrivateDnsZones[{0}]', variables('dnsZoneIndex').storageBlob)]",
3978739801
"[format('avmPrivateDnsZones[{0}]', variables('dnsZoneIndex').storageQueue)]",
39802+
"[format('avmPrivateDnsZones[{0}]', variables('dnsZoneIndex').storageBlob)]",
3978839803
"network",
3978939804
"userAssignedIdentity"
3979039805
]
@@ -50479,8 +50494,8 @@
5047950494
"flowType": {
5048050495
"value": "Bluefield"
5048150496
},
50482-
"workspaceResourceId": "[if(parameters('enableMonitoring'), createObject('value', reference('logAnalyticsWorkspace').outputs.resourceId.value), createObject('value', ''))]",
50483-
"diagnosticSettings": "[if(parameters('enableMonitoring'), createObject('value', createArray(createObject('workspaceResourceId', reference('logAnalyticsWorkspace').outputs.resourceId.value))), createObject('value', null()))]"
50497+
"workspaceResourceId": "[if(parameters('enableMonitoring'), if(variables('useExistingLogAnalytics'), createObject('value', parameters('existingLogAnalyticsWorkspaceId')), createObject('value', reference('logAnalyticsWorkspace').outputs.resourceId.value)), createObject('value', ''))]",
50498+
"diagnosticSettings": "[if(parameters('enableMonitoring'), createObject('value', createArray(createObject('workspaceResourceId', if(variables('useExistingLogAnalytics'), parameters('existingLogAnalyticsWorkspaceId'), reference('logAnalyticsWorkspace').outputs.resourceId.value)))), createObject('value', null()))]"
5048450499
},
5048550500
"template": {
5048650501
"$schema": "https://schema.management.azure.com/schemas/2019-04-01/deploymentTemplate.json#",

0 commit comments

Comments
 (0)