@@ -73,6 +73,7 @@ function ValidateVariableIsNullOrEmpty {
7373# Function to prompt for parameters with kind messages
7474function PromptForParameters {
7575 param (
76+ [string ]$tenantId ,
7677 [string ]$subscriptionID ,
7778 [string ]$environmentName ,
7879 [string ]$resourceGroupName ,
@@ -102,6 +103,10 @@ function PromptForParameters {
102103 ' EastUS' , ' EastUS2' , ' SwedenCentral' , ' WestUS3'
103104 )
104105
106+ if (-not $tenantId ) {
107+ Write-Host " Please enter your Azure tenant ID" - ForegroundColor Cyan
108+ $tenantId = Read-Host - Prompt ' > '
109+ }
105110 if (-not $subscriptionID ) {
106111 Write-Host " Please enter your Azure subscription ID to deploy your resources" - ForegroundColor Cyan
107112 $subscriptionID = Read-Host - Prompt ' > '
@@ -137,6 +142,7 @@ function PromptForParameters {
137142 }
138143
139144 return @ {
145+ tenantId = $tenantId
140146 subscriptionID = $subscriptionID
141147 environmentName = $environmentName
142148 resourceGroupName = $resourceGroupName
@@ -147,8 +153,9 @@ function PromptForParameters {
147153}
148154
149155# Prompt for parameters with kind messages
150- $params = PromptForParameters - subscriptionID $subscriptionID - environmentName $environmentName - resourceGroupName $resourceGroupName - location $location - modelLocation $modelLocation - email $email
156+ $params = PromptForParameters - tenantId $tenantId - subscriptionID $subscriptionID - environmentName $environmentName - resourceGroupName $resourceGroupName - location $location - modelLocation $modelLocation - email $email
151157# Assign the parameters to variables
158+ $tenantId = $params.tenantId
152159$subscriptionID = $params.subscriptionID
153160$environmentName = $params.environmentName
154161$resourceGroupName = $params.resourceGroupName
@@ -158,17 +165,24 @@ $email = $params.email
158165
159166function LoginAzure ([string ]$subscriptionID ) {
160167 Write-Host " Log in to Azure.....`r`n " - ForegroundColor Yellow
161- if ($env: CI -eq " true" ){
162-
168+ if ($env: CI -eq " true" ){
163169 az login -- service- principal `
164170 -- username $env: AZURE_CLIENT_ID `
165171 -- password $env: AZURE_CLIENT_SECRET `
166172 -- tenant $env: AZURE_TENANT_ID
167- write-host " CI deployment mode"
173+ Write-Host " CI deployment mode"
168174 }
175+ else {
176+ az login -- tenant $tenantId
177+ if ($LASTEXITCODE -ne 0 ) {
178+ Write-Host " Failed to log in to Azure with tenant ID '$tenantId '. Please check your credentials." - ForegroundColor Red
179+ failureBanner
180+ exit 1
181+ }
169182 else {
170- az login
171- write-host " manual deployment mode"
183+ Write-Host " Logged in to Azure with tenant ID '$tenantId ' successfully." - ForegroundColor Green
184+ }
185+ Write-Host " manual deployment mode"
172186 }
173187 az account set -- subscription $subscriptionID
174188 Write-Host " Switched subscription to '$subscriptionID ' `r`n " - ForegroundColor Yellow
@@ -284,6 +298,7 @@ function DisplayResult([pscustomobject]$jsonString) {
284298 Write-Host " ********************************************************************************" - ForegroundColor Blue
285299 Write-Host " * Deployed Azure Resources Information *" - ForegroundColor Blue
286300 Write-Host " ********************************************************************************" - ForegroundColor Blue
301+ Write-Host " * Tenant Id: " - ForegroundColor Yellow - NoNewline; Write-Host " $tenantId " - ForegroundColor Green
287302 Write-Host " * Subscription Id: " - ForegroundColor Yellow - NoNewline; Write-Host " $subscriptionID " - ForegroundColor Green
288303 Write-Host " * Knowledge Mining Digital Asset resource group: " - ForegroundColor Yellow - NoNewline; Write-Host " $resourcegroupName " - ForegroundColor Green
289304 Write-Host " * Azure Kubernetes Account " - ForegroundColor Yellow - NoNewline; Write-Host " $aksName " - ForegroundColor Green
0 commit comments