Skip to content

Commit c90a84f

Browse files
Refactor AKS managed identity retrieval to improve error handling
1 parent cd879f3 commit c90a84f

1 file changed

Lines changed: 2 additions & 5 deletions

File tree

Deployment/resourcedeployment.ps1

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -496,14 +496,11 @@ class DeploymentResult {
496496
$this.AzAppConfigEndpoint = "https://$($this.AzAppConfigName).azconfig.io"
497497

498498
# Get AKS managed identity
499-
$aksMid = az aks show --name $this.AksName --resource-group $resourceGroupName --query "identity.principalId" -o tsv 2>$null
500-
if ($LASTEXITCODE -ne 0 -or [string]::IsNullOrWhiteSpace($aksMid)) {
499+
$this.AksMid = az aks show --name $this.AksName --resource-group $resourceGroupName --query "identity.principalId" -o tsv 2>$null
500+
if ($LASTEXITCODE -ne 0 -or [string]::IsNullOrWhiteSpace($this.AksMid)) {
501501
Write-Host "Warning: Failed to retrieve AKS managed identity for '$($this.AksName)' in resource group '$resourceGroupName'.`n`tThe AKS cluster may not exist or you may not have sufficient permissions." -ForegroundColor Yellow
502502
$this.AksMid = $null
503503
}
504-
else {
505-
$this.AksMid = $aksMid
506-
}
507504

508505
Write-Host "Successfully reconstructed resource names from SolutionSuffix '$solutionSuffix'" -ForegroundColor Green
509506
}

0 commit comments

Comments
 (0)