Skip to content

Commit d896727

Browse files
feat: Removed unwanted sections from Power shell script
1 parent c0e78db commit d896727

2 files changed

Lines changed: 53 additions & 93 deletions

File tree

Deployment/resourcedeployment.ps1

Lines changed: 45 additions & 85 deletions
Original file line numberDiff line numberDiff line change
@@ -73,7 +73,7 @@ function ValidateVariableIsNullOrEmpty {
7373
# Function to prompt for parameters with kind messages
7474
function PromptForParameters {
7575
param(
76-
[string]$email
76+
[string]$email
7777
)
7878

7979
Clear-Host
@@ -88,7 +88,7 @@ function PromptForParameters {
8888
}
8989

9090
return @{
91-
email = $email
91+
email = $email
9292
}
9393
}
9494

@@ -222,23 +222,19 @@ class DeploymentResult {
222222
[string]$ResourceGroupName
223223
[string]$ResourceGroupId
224224
[string]$StorageAccountName
225-
[string]$StorageAccountConnectionString
226225
[string]$AzSearchServiceName
227226
[string]$AzSearchServicEndpoint
228-
[string]$AzSearchAdminKey
229227
[string]$AksName
230228
[string]$AksMid
231229
[string]$AzContainerRegistryName
232230
[string]$AzCognitiveServiceName
233-
[string]$AzCognitiveServiceKey
234231
[string]$AzCognitiveServiceEndpoint
235232
[string]$AzOpenAiServiceName
236233
[string]$AzGPT4oModelName
237234
[string]$AzGPT4oModelId
238235
[string]$AzGPTEmbeddingModelName
239236
[string]$AzGPTEmbeddingModelId
240237
[string]$AzOpenAiServiceEndpoint
241-
[string]$AzOpenAiServiceKey
242238
[string]$AzCosmosDBName
243239
[string]$AzCosmosDBConnectionString
244240
[string]$AzAppConfigEndpoint
@@ -252,11 +248,9 @@ class DeploymentResult {
252248
$this.ResourceGroupId = ""
253249
# Storage Account
254250
$this.StorageAccountName = ""
255-
$this.StorageAccountConnectionString = ""
256251
# Azure Search
257252
$this.AzSearchServiceName = ""
258253
$this.AzSearchServicEndpoint = ""
259-
$this.AzSearchAdminKey = ""
260254
# AKS
261255
$this.AksName = ""
262256
$this.AksMid = ""
@@ -265,11 +259,9 @@ class DeploymentResult {
265259
# Cognitive Service - Azure AI Intelligence Document Service
266260
$this.AzCognitiveServiceName = ""
267261
$this.AzCognitiveServiceEndpoint = ""
268-
$this.AzCognitiveServiceKey = ""
269262
# Open AI Service
270263
$this.AzOpenAiServiceName = ""
271264
$this.AzOpenAiServiceEndpoint = ""
272-
$this.AzOpenAiServiceKey = ""
273265
# Model - GPT4o
274266
$this.AzGPT4oModelName = ""
275267
$this.AzGPT4oModelId = ""
@@ -377,34 +369,21 @@ try {
377369
# Deploy Azure Resources
378370
Write-Host "Retrieving the deployment details.....`r`n" -ForegroundColor Yellow
379371

380-
# Map the deployment result to DeploymentResult object
372+
# Map the deployment result to DeploymentResult object from .env file
381373
$deploymentResult.MapResult()
374+
382375
# Display the deployment result
383376
DisplayResult($deploymentResult)
384377

385378
LoginAzure $deploymentResult.TenantId $deploymentResult.SubscriptionId
386379

387380
###############################################################
388-
# Step 2 : Get Secrets from Azure resources
389-
Show-Banner -Title "Step 2 : Get Secrets from Azure resources"
381+
# Step 2 : Validate deloyment result
382+
Show-Banner -Title "Step 2 : Validate deloyment result"
390383
###############################################################
391384
# Validate if the Storage Account Name is empty or null
392385
ValidateVariableIsNullOrEmpty -variableValue $deploymentResult.StorageAccountName -variableName "Storage Account Name"
393386

394-
# Get the storage account key
395-
$storageAccountKey = az storage account keys list --account-name $deploymentResult.StorageAccountName --resource-group $deploymentResult.ResourceGroupName --query "[0].value" -o tsv
396-
397-
# Validate if the storage account key is empty or null
398-
ValidateVariableIsNullOrEmpty -variableValue $storageAccountKey -variableName "Storage account key"
399-
400-
## Construct the connection string manually
401-
$storageAccountConnectionString = "DefaultEndpointsProtocol=https;AccountName=$($deploymentResult.StorageAccountName);AccountKey=$storageAccountKey;EndpointSuffix=core.windows.net"
402-
# Validate if the Storage Account Connection String is empty or null
403-
ValidateVariableIsNullOrEmpty -variableValue $storageAccountConnectionString -variableName "Storage Account Connection String"
404-
405-
## Assign the connection string to the deployment result object
406-
$deploymentResult.StorageAccountConnectionString = $storageAccountConnectionString
407-
408387
# Check if ResourceGroupName is valid
409388
ValidateVariableIsNullOrEmpty -variableValue $deploymentResult.ResourceGroupName -variableName "Resource group name"
410389

@@ -422,12 +401,6 @@ try {
422401

423402
# Get MongoDB connection string
424403
$deploymentResult.AzCosmosDBConnectionString = az cosmosdb keys list --name $deploymentResult.AzCosmosDBName --resource-group $deploymentResult.ResourceGroupName --type connection-strings --query "connectionStrings[0].connectionString" -o tsv
425-
# Get Azure Cognitive Service API Key
426-
$deploymentResult.AzCognitiveServiceKey = az cognitiveservices account keys list --name $deploymentResult.AzCognitiveServiceName --resource-group $deploymentResult.ResourceGroupName --query "key1" -o tsv
427-
# Get Azure Search Service Admin Key
428-
$deploymentResult.AzSearchAdminKey = az search admin-key show --service-name $deploymentResult.AzSearchServiceName --resource-group $deploymentResult.ResourceGroupName --query "primaryKey" -o tsv
429-
# Get Azure Open AI Service API Key
430-
$deploymentResult.AzOpenAiServiceKey = az cognitiveservices account keys list --name $deploymentResult.AzOpenAiServiceName --resource-group $deploymentResult.ResourceGroupName --query "key1" -o tsv
431404

432405
Write-Host "Secrets have been retrieved successfully." -ForegroundColor Green
433406

@@ -440,11 +413,7 @@ try {
440413

441414
$aiServicePlaceholders = @{
442415
'{gpt-4o-mini-endpoint}' = $deploymentResult.AzOpenAiServiceEndpoint
443-
'{gpt-4o-mini-apikey}' = $deploymentResult.AzOpenAiServiceKey
444-
'{azureaisearch-apikey}' = $deploymentResult.AzSearchAdminKey
445-
'{documentintelligence-apikey}' = $deploymentResult.AzCognitiveServiceKey
446416
'{cosmosmongo-connection-string}' = $deploymentResult.AzCosmosDBConnectionString
447-
'{azureblobs-connection-string}' = $deploymentResult.StorageAccountConnectionString
448417
'{azureblobs-account}' = $deploymentResult.StorageAccountName
449418
'{azureaisearch-endpoint}' = $deploymentResult.AzSearchServicEndpoint
450419
'{gpt-4o-mini-modelname}' = $deploymentResult.AzGPT4oModelId
@@ -453,12 +422,7 @@ try {
453422
'{azureopenaiembedding-endpoint}' = $deploymentResult.AzOpenAiServiceEndpoint
454423
'{azureopenaitext-endpoint}' = $deploymentResult.AzOpenAiServiceEndpoint
455424
'{azureopenaitext-deployment}' = $deploymentResult.AzGPT4oModelId
456-
'{gpt-4o-key}' = $deploymentResult.AzOpenAiServiceKey
457-
'{textembedding-key}' = $deploymentResult.AzOpenAiServiceKey
458-
'{azureopenaiembedding-apikey}' = $deploymentResult.AzOpenAiServiceKey
459-
'{azureopenaitext-apikey}' = $deploymentResult.AzOpenAiServiceKey
460425
'{textembedding-modelname}' = $deploymentResult.AzGPTEmbeddingModelName
461-
'{azureaidocintel-apikey}' = $deploymentResult.AzCognitiveServiceKey
462426
'{cosmosmongo-chat-history-collection}' = "ChatHistory"
463427
'{cosmosmongo-chat-history-database}' = "DPS"
464428
'{cosmosmongo-document-manager-collection}' = "Documents"
@@ -467,7 +431,6 @@ try {
467431
'{documentintelligence-endpoint}' = $deploymentResult.AzCognitiveServiceEndpoint
468432
'{azureblobs-container}' = "smemory"
469433
'{azurequeues-account}' = $deploymentResult.StorageAccountName
470-
'{azurequeues-connection-string}' = $deploymentResult.StorageAccountConnectionString
471434
'{gpt-4o-modelname}' = $deploymentResult.AzGPT4oModelName
472435
'{azureopenaiembedding-deployment}' = $deploymentResult.AzGPTEmbeddingModelName
473436
'{kernelmemory-endpoint}' = "http://kernelmemory-service"
@@ -477,43 +440,43 @@ try {
477440
$aiServiceConfigTemplate = Get-Content -Path .\appconfig\aiservice\appconfig.jsonl -Raw
478441
$aiServiceConfigTemplate = Invoke-PlaceholdersReplacement $aiServiceConfigTemplate $aiServicePlaceholders
479442

480-
## Save the updated AI service configuration file
481-
$aiServiceConfigPath = ".\appconfig\aiservice\appsettings.dev.jsonl"
482-
$aiServiceConfigTemplate | Set-Content -Path $aiServiceConfigPath -Force
483-
Write-Host "Knowledge Mining Solution Accelerator Service Application Configuration file has been updated successfully." -ForegroundColor Green
484-
485-
## Set error action preference to silently continue
486-
$ErrorActionPreference = "SilentlyContinue"
487-
## Get the current script directory dynamically
488-
$scriptDirectory = Split-Path -Parent $MyInvocation.MyCommand.Definition
489-
490-
## Construct the relative path to the JSON file
491-
$filePath = Join-Path $scriptDirectory ".\appconfig\aiservice\appsettings.dev.jsonl"
492-
493-
## Other variables
494-
$appConfigName = $deploymentResult.AzAppConfigName
495-
496-
## Output the file path for verification
497-
#write-host "Using file path: $filePath"
498-
499-
## Execute the az appconfig kv import command using PowerShell
500-
az appconfig kv import `
501-
--name $appConfigName `
502-
--source file `
503-
--path $filePath `
504-
--format json `
505-
--separator "," `
506-
--content-type "application/x-ndjson" `
507-
--yes
508-
509-
## Check if the file exists and delete it
510-
if (Test-Path $aiServiceConfigPath) {
511-
Remove-Item $aiServiceConfigPath -Force
512-
#Write-Host "File '$aiServiceConfigPath' has been deleted."
513-
} else {
514-
Write-Host "File '$aiServiceConfigPath' does not exist."
515-
}
516-
$ErrorActionPreference = "Continue"
443+
# ## Save the updated AI service configuration file
444+
# $aiServiceConfigPath = ".\appconfig\aiservice\appsettings.dev.jsonl"
445+
# $aiServiceConfigTemplate | Set-Content -Path $aiServiceConfigPath -Force
446+
# Write-Host "Knowledge Mining Solution Accelerator Service Application Configuration file has been updated successfully." -ForegroundColor Green
447+
448+
# ## Set error action preference to silently continue
449+
# $ErrorActionPreference = "SilentlyContinue"
450+
# ## Get the current script directory dynamically
451+
# $scriptDirectory = Split-Path -Parent $MyInvocation.MyCommand.Definition
452+
453+
# ## Construct the relative path to the JSON file
454+
# $filePath = Join-Path $scriptDirectory ".\appconfig\aiservice\appsettings.dev.jsonl"
455+
456+
# ## Other variables
457+
# $appConfigName = $deploymentResult.AzAppConfigName
458+
459+
# ## Output the file path for verification
460+
# #write-host "Using file path: $filePath"
461+
462+
# ## Execute the az appconfig kv import command using PowerShell
463+
# az appconfig kv import `
464+
# --name $appConfigName `
465+
# --source file `
466+
# --path $filePath `
467+
# --format json `
468+
# --separator "," `
469+
# --content-type "application/x-ndjson" `
470+
# --yes
471+
472+
# ## Check if the file exists and delete it
473+
# if (Test-Path $aiServiceConfigPath) {
474+
# Remove-Item $aiServiceConfigPath -Force
475+
# #Write-Host "File '$aiServiceConfigPath' has been deleted."
476+
# } else {
477+
# Write-Host "File '$aiServiceConfigPath' does not exist."
478+
# }
479+
# $ErrorActionPreference = "Continue"
517480

518481

519482
######################################################################################################################
@@ -646,9 +609,7 @@ try {
646609

647610
# Validate if the FQDN is null or empty
648611
ValidateVariableIsNullOrEmpty -variableValue $fqdn -variableName "FQDN"
649-
650-
# 7. Assign the role for aks system assigned managed identity to App Configuration Data Reader role with the scope of Resourcegroup
651-
Write-Host "Assign the role for aks system assigned managed identity to App Configuration Data Reader role" -ForegroundColor Green
612+
652613
# Ensure that the required fields are not null or empty
653614
ValidateVariableIsNullOrEmpty -variableValue $deploymentResult.ResourceGroupName -variableName "Resource group name"
654615

@@ -676,6 +637,7 @@ try {
676637
ValidateVariableIsNullOrEmpty -variableValue $deploymentResult.ResourceGroupId -variableName "ResourceGroupId"
677638

678639
# Assign the role for aks system assigned managed identity to App Configuration Data Reader role with the scope of Resourcegroup
640+
Write-Host "Assign the role for aks system assigned managed identity to App Configuration Data Reader role" -ForegroundColor Green
679641
az role assignment create --assignee $systemAssignedIdentity --role "App Configuration Data Reader" --scope $deploymentResult.ResourceGroupId
680642

681643
# Assign the role for aks system assigned managed identity to Azure blob storage Data Contributor role with the scope of Storage Account
@@ -702,7 +664,6 @@ try {
702664
Write-Host "Assign the role for aks system assigned managed identity to App Cognitive Services User role" -ForegroundColor Green
703665
az role assignment create --assignee $systemAssignedIdentity --role "Cognitive Services User" --scope "/subscriptions/$($deploymentResult.SubscriptionId)/resourceGroups/$($deploymentResult.ResourceGroupName)/providers/Microsoft.CognitiveServices/accounts/$($deploymentResult.AzCognitiveServiceName)"
704666

705-
706667
# 8. Update aks nodepools to updated new role
707668
try {
708669
Write-Host "Upgrading node pools..." -ForegroundColor Cyan
@@ -711,7 +672,6 @@ try {
711672
Write-Host "Upgrading node pool: $nodePool" -ForegroundColor Cyan
712673
Write-Host "Node pool $nodePool upgrade initiated." -ForegroundColor Green
713674
az aks nodepool upgrade --resource-group $deploymentResult.ResourceGroupName --cluster-name $deploymentResult.AksName --name $nodePool
714-
715675
}
716676
}
717677
catch {

infra/main.bicep

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -461,6 +461,10 @@ module avmAppConfig 'br/public:avm/res/app-configuration/configuration-store:0.6
461461
name: 'KernelMemory:Services:AzureBlobs:Container'
462462
value: 'smemory'
463463
}
464+
{
465+
name: 'KernelMemory:Services:AzureOpenAIEmbedding:Auth'
466+
value: 'AzureIdentity'
467+
}
464468
{
465469
name: 'KernelMemory:Services:AzureOpenAIEmbedding:Deployment'
466470
value: embedding.deploymentName
@@ -469,6 +473,10 @@ module avmAppConfig 'br/public:avm/res/app-configuration/configuration-store:0.6
469473
name: 'KernelMemory:Services:AzureOpenAIEmbedding:Endpoint'
470474
value: avmOpenAi.outputs.endpoint
471475
}
476+
{
477+
name: 'KernelMemory:Services:AzureOpenAIText:Auth'
478+
value: 'AzureIdentity'
479+
}
472480
{
473481
name: 'KernelMemory:Services:AzureOpenAIText:Deployment'
474482
value: chatGpt.deploymentName
@@ -599,11 +607,6 @@ module avmSearchSearchServices 'br/public:avm/res/search/search-service:0.9.1' =
599607
managedIdentities: { userAssignedResourceIds: [userAssignedIdentity!.outputs.resourceId] }
600608
replicaCount: 1
601609
partitionCount: 1
602-
authOptions: {
603-
aadOrApiKey: {
604-
aadAuthFailureMode: 'http401WithBearerChallenge'
605-
}
606-
}
607610
roleAssignments: [
608611
{
609612
roleDefinitionIdOrName: 'Search Index Data Contributor' // Cognitive Search Contributor
@@ -616,7 +619,6 @@ module avmSearchSearchServices 'br/public:avm/res/search/search-service:0.9.1' =
616619
principalType: 'ServicePrincipal'
617620
}
618621
]
619-
disableLocalAuth: false
620622
semanticSearch: 'free'
621623
// secretsExportConfiguration: {
622624
// keyVaultResourceId: keyvault.outputs.resourceId
@@ -654,7 +656,6 @@ module avmOpenAi 'br/public:avm/res/cognitive-services/account:0.13.2' = {
654656
tags: tags
655657
enableTelemetry: enableTelemetry
656658
customSubDomainName: openAiAccountName
657-
disableLocalAuth: false
658659
managedIdentities: {
659660
systemAssigned: true
660661
}
@@ -714,7 +715,6 @@ module documentIntelligence 'br/public:avm/res/cognitive-services/account:0.13.2
714715
tags: tags
715716
sku: 'S0'
716717
customSubDomainName: docIntelAccountName
717-
disableLocalAuth: false
718718
managedIdentities: {
719719
systemAssigned: true
720720
}

0 commit comments

Comments
 (0)