Skip to content

Commit 213e928

Browse files
Merge pull request #401 from microsoft/dev
fix: Enhance Deployment Script for Tenant ID Prompt and Fix Chatroom UI Reset Bug
2 parents 897737d + a198f19 commit 213e928

File tree

3 files changed

+26
-6
lines changed

3 files changed

+26
-6
lines changed

.github/workflows/CI.yml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -130,6 +130,7 @@ jobs:
130130
run: |
131131
cd Deployment
132132
$input = @"
133+
${{ secrets.AZURE_TENANT_ID }}
133134
${{ secrets.AZURE_SUBSCRIPTION_ID }}
134135
${{ env.ENVIRONMENT_NAME }}
135136
@@ -146,6 +147,7 @@ jobs:
146147
AZURE_TENANT_ID: ${{ secrets.AZURE_TENANT_ID }}
147148
AZURE_CLIENT_ID: ${{ secrets.AZURE_CLIENT_ID }}
148149
AZURE_CLIENT_SECRET: ${{ secrets.AZURE_CLIENT_SECRET }}
150+
149151
- name: Cleanup Resource Group
150152
if: always() # Ensures this step runs even if the deployment fails
151153
shell: pwsh

App/frontend-app/src/components/chat/chatRoom.tsx

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -124,6 +124,8 @@ export function ChatRoom({ searchResultDocuments, selectedDocuments, chatWithDoc
124124

125125
const makeApiRequest = async (question: string) => {
126126
setTextAreaValue("");
127+
//Force Textarea re-render to reset internal showCount
128+
setTextareaKey(prev => prev + 1);
127129
setDisableSources(true);
128130
setIsLoading(true);
129131

@@ -249,6 +251,7 @@ export function ChatRoom({ searchResultDocuments, selectedDocuments, chatWithDoc
249251
console.error("Error parsing response body:", error);
250252
}
251253
} catch (error) {
254+
console.error("Error in makeApiRequest:", error);
252255
} finally {
253256
setIsLoading(false);
254257
setTimeout(() => {

Deployment/resourcedeployment.ps1

Lines changed: 21 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -73,6 +73,7 @@ function ValidateVariableIsNullOrEmpty {
7373
# Function to prompt for parameters with kind messages
7474
function 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

159166
function 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

Comments
 (0)