|
1 | | -# Copyright (c) Microsoft Corporation. |
| 1 | +# Copyright (c) Microsoft Corporation. |
2 | 2 | # Licensed under the MIT license. |
3 | 3 |
|
4 | 4 | #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 | + |
5 | 14 | function startBanner() { |
6 | 15 | Write-Host " _____ _ " |
7 | 16 | Write-Host " | __ \ | | " |
@@ -195,7 +204,10 @@ function Show-Banner { |
195 | 204 | } |
196 | 205 |
|
197 | 206 | # 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 | + |
199 | 211 | function Get-AzdEnvValueOrDefault { |
200 | 212 | param ( |
201 | 213 | [Parameter(Mandatory = $true)] |
@@ -290,7 +302,7 @@ class DeploymentResult { |
290 | 302 |
|
291 | 303 | } |
292 | 304 |
|
293 | | - [void]MapResult() { |
| 305 | + [void]MapResultAzd() { |
294 | 306 |
|
295 | 307 | # Replace direct $envValues lookups with function calls |
296 | 308 | $this.TenantId = Get-AzdEnvValueOrDefault -KeyName "AZURE_TENANT_ID" -Required $true |
@@ -335,6 +347,63 @@ class DeploymentResult { |
335 | 347 | $this.AzAppConfigEndpoint = Get-AzdEnvValueOrDefault -KeyName "AZURE_APP_CONFIG_ENDPOINT" |
336 | 348 | $this.AzAppConfigName = Get-AzdEnvValueOrDefault -KeyName "AZURE_APP_CONFIG_NAME" |
337 | 349 | } |
| 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 | + } |
338 | 407 | } |
339 | 408 |
|
340 | 409 | function Check-Docker { |
@@ -379,7 +448,16 @@ try { |
379 | 448 | Write-Host "Retrieving the deployment details.....`r`n" -ForegroundColor Yellow |
380 | 449 |
|
381 | 450 | # 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 | + } |
383 | 461 |
|
384 | 462 | LoginAzure $deploymentResult.TenantId $deploymentResult.SubscriptionId |
385 | 463 |
|
|
0 commit comments