Skip to content

Commit c5ec982

Browse files
fix: update post-deployment scripts to install Python dependencies for the user and enhance README instructions
1 parent 1eddf56 commit c5ec982

4 files changed

Lines changed: 33 additions & 34 deletions

File tree

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -204,9 +204,9 @@ When Deployment is complete:
204204
1. Run the post-deployment setup script to configure the Function App client key and create PostgreSQL tables (if applicable). Open [Azure Cloud Shell](https://shell.azure.com) (Bash) and run:
205205

206206
```bash
207+
az login
207208
git clone https://github.com/Azure-Samples/chat-with-your-data-solution-accelerator.git
208209
cd chat-with-your-data-solution-accelerator
209-
pip install -r scripts/data_scripts/requirements.txt
210210
bash scripts/post_deployment_setup.sh "<your-resource-group-name>"
211211
```
212212

docs/AVMPostDeploymentGuide.md

Lines changed: 3 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -12,26 +12,13 @@ Ensure you have a **Deployed Infrastructure** - A successful Chat with your data
1212

1313
## Post Deployment Steps
1414

15-
### Step 1: Run Post-Deployment Setup Script
16-
17-
Run the post-deployment script to configure the Function App client key and create PostgreSQL tables (if applicable). Open [Azure Cloud Shell](https://shell.azure.com) (Bash) and run:
18-
19-
```bash
20-
git clone https://github.com/Azure-Samples/chat-with-your-data-solution-accelerator.git
21-
cd chat-with-your-data-solution-accelerator
22-
pip install -r scripts/data_scripts/requirements.txt
23-
bash scripts/post_deployment_setup.sh "<your-resource-group-name>"
24-
```
25-
26-
> **Note:** The script auto-discovers all resources in the resource group. It handles private networking (WAF) deployments by temporarily enabling public access, performing the setup, then restoring the original state.
27-
28-
### Step 2: Configure App Authentication
15+
### Step 1: Configure App Authentication
2916

3017
1. After deployment is complete, navigate to your Azure App Service in the Azure portal
3118
2. Follow the detailed instructions in [Set Up Authentication in Azure App Service](./azure_app_service_auth_setup.md) to add authentication to your web app
3219
3. This will ensure only authorized users can access your application
3320

34-
### Step 3: Access and Configure the Admin Site
21+
### Step 2: Access and Configure the Admin Site
3522

3623
1. **Navigate to the admin site** using the following URL pattern:
3724
```
@@ -49,7 +36,7 @@ bash scripts/post_deployment_setup.sh "<your-resource-group-name>"
4936
- Wait for the documents to be processed and indexed
5037
- Verify successful ingestion through the admin interface
5138

52-
### Step 4: Access the Chat Application
39+
### Step 3: Access the Chat Application
5340

5441
1. **Navigate to the main chat application** using this URL pattern:
5542
```

scripts/post_deployment_setup.ps1

Lines changed: 11 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -107,9 +107,10 @@ else {
107107
$existingAssignment = az role assignment list --assignee $currentUserOid --role $kvSecretsUserRoleId --scope $kvResourceId --query "[0].id" -o tsv 2>$null
108108
if (-not $existingAssignment) {
109109
Write-Host "✓ Assigning 'Key Vault Secrets User' role to current user on Key Vault..."
110-
az role assignment create --assignee-object-id $currentUserOid --assignee-principal-type User --role $kvSecretsUserRoleId --scope $kvResourceId | Out-Null
110+
$roleOutput = az role assignment create --assignee-object-id $currentUserOid --assignee-principal-type User --role $kvSecretsUserRoleId --scope $kvResourceId 2>&1 | Out-String
111111
if ($LASTEXITCODE -ne 0) {
112-
Write-Warning "⚠ Failed to assign Key Vault Secrets User role. You may not have Owner/User Access Administrator permissions."
112+
Write-Warning "⚠ Failed to assign Key Vault Secrets User role."
113+
Write-Warning " $roleOutput"
113114
} else {
114115
Write-Host "✓ Role assigned. Waiting 30s for propagation..."
115116
Start-Sleep -Seconds 30
@@ -127,9 +128,9 @@ else {
127128
if ($kvPublicAccess -eq "Disabled") {
128129
Write-Host "Key Vault has public access disabled (private networking detected)."
129130
Write-Host "✓ Temporarily enabling public access on Key Vault '$keyVaultName'..."
130-
az keyvault update --name $keyVaultName --resource-group $ResourceGroupName --public-network-access Enabled | Out-Null
131+
$kvOutput = az keyvault update --name $keyVaultName --resource-group $ResourceGroupName --public-network-access Enabled 2>&1 | Out-String
131132
if ($LASTEXITCODE -ne 0) {
132-
Write-Error "✗ Failed to enable public access on Key Vault. Cannot proceed."
133+
Write-Error "✗ Failed to enable public access on Key Vault. Cannot proceed.`n $kvOutput"
133134
exit 1
134135
}
135136
$resourcesToRestore += @{ type = "keyvault"; name = $keyVaultName }
@@ -198,10 +199,10 @@ else {
198199
if ($pgPublicAccess -eq "Disabled") {
199200
Write-Host "PostgreSQL has public access disabled (private networking detected)."
200201
Write-Host "✓ Temporarily enabling public access on PostgreSQL '$serverName'..."
201-
az postgres flexible-server update --resource-group $ResourceGroupName --name $serverName --public-access Enabled 2>$null | Out-Null
202+
$pgOutput = az postgres flexible-server update --resource-group $ResourceGroupName --name $serverName --public-access Enabled 2>&1 | Out-String
202203
if ($LASTEXITCODE -ne 0) {
203204
Restore-NetworkAccess
204-
Write-Error "✗ Failed to enable public access on PostgreSQL. Cannot proceed."
205+
Write-Error "✗ Failed to enable public access on PostgreSQL. Cannot proceed.`n $pgOutput"
205206
exit 1
206207
}
207208
$resourcesToRestore += @{ type = "postgres"; name = $serverName }
@@ -247,14 +248,15 @@ else {
247248
$addedPgAdmin = $false
248249
if (-not $isAdmin) {
249250
Write-Host "✓ Adding current user as PostgreSQL Entra administrator..."
250-
az postgres flexible-server ad-admin create `
251+
$adminOutput = az postgres flexible-server ad-admin create `
251252
--resource-group $ResourceGroupName `
252253
--server-name $serverName `
253254
--display-name $currentUserUpn `
254255
--object-id $currentUserOid `
255-
--type User 2>$null | Out-Null
256+
--type User 2>&1 | Out-String
256257
if ($LASTEXITCODE -ne 0) {
257258
Write-Warning "⚠ Failed to add current user as PostgreSQL admin. Table creation may fail."
259+
Write-Warning " $adminOutput"
258260
} else {
259261
$addedPgAdmin = $true
260262
Write-Host "✓ PostgreSQL admin added. Waiting 60s for propagation..."
@@ -270,7 +272,7 @@ else {
270272
$requirementsFile = Join-Path $scriptDir "data_scripts" "requirements.txt"
271273
if (Test-Path $requirementsFile) {
272274
Write-Host "✓ Installing Python dependencies..."
273-
pip install -r $requirementsFile
275+
pip install --user -r $requirementsFile 2>&1 | Out-Null
274276
}
275277

276278
Write-Host "✓ Creating tables..."

scripts/post_deployment_setup.sh

Lines changed: 18 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -73,11 +73,13 @@ else
7373
EXISTING_ASSIGNMENT=$(az role assignment list --assignee "$CURRENT_USER_OID" --role "$KV_SECRETS_USER_ROLE_ID" --scope "$KV_RESOURCE_ID" --query "[0].id" -o tsv 2>/dev/null || true)
7474
if [ -z "$EXISTING_ASSIGNMENT" ]; then
7575
echo "✓ Assigning 'Key Vault Secrets User' role to current user on Key Vault..."
76-
if az role assignment create --assignee-object-id "$CURRENT_USER_OID" --assignee-principal-type User --role "$KV_SECRETS_USER_ROLE_ID" --scope "$KV_RESOURCE_ID" > /dev/null 2>&1; then
76+
ROLE_ERR=$(az role assignment create --assignee-object-id "$CURRENT_USER_OID" --assignee-principal-type User --role "$KV_SECRETS_USER_ROLE_ID" --scope "$KV_RESOURCE_ID" 2>&1 > /dev/null) || true
77+
if [ $? -eq 0 ] && [ -z "$ROLE_ERR" ] || az role assignment list --assignee "$CURRENT_USER_OID" --role "$KV_SECRETS_USER_ROLE_ID" --scope "$KV_RESOURCE_ID" --query "[0].id" -o tsv 2>/dev/null | grep -q .; then
7778
echo "✓ Role assigned. Waiting 30s for propagation..."
7879
sleep 30
7980
else
80-
echo "⚠ WARNING: Failed to assign Key Vault Secrets User role. You may not have Owner/User Access Administrator permissions."
81+
echo "⚠ WARNING: Failed to assign Key Vault Secrets User role."
82+
echo " $ROLE_ERR"
8183
fi
8284
else
8385
echo "✓ Current user already has 'Key Vault Secrets User' role on Key Vault."
@@ -92,8 +94,10 @@ else
9294
if [ "$KV_PUBLIC_ACCESS" = "Disabled" ]; then
9395
echo "Key Vault has public access disabled (private networking detected)."
9496
echo "✓ Temporarily enabling public access on Key Vault '${KEY_VAULT_NAME}'..."
95-
if ! az keyvault update --name "$KEY_VAULT_NAME" --resource-group "$RESOURCE_GROUP" --public-network-access Enabled > /dev/null 2>&1; then
97+
KV_ERR=$(az keyvault update --name "$KEY_VAULT_NAME" --resource-group "$RESOURCE_GROUP" --public-network-access Enabled 2>&1 > /dev/null) || true
98+
if [ -n "$KV_ERR" ]; then
9699
echo "✗ ERROR: Failed to enable public access on Key Vault. Cannot proceed." >&2
100+
echo " $KV_ERR" >&2
97101
exit 1
98102
fi
99103
RESTORE_KV_NAME="$KEY_VAULT_NAME"
@@ -129,8 +133,10 @@ else
129133
URI="/subscriptions/${SUBSCRIPTION_ID}/resourceGroups/${RESOURCE_GROUP}/providers/Microsoft.Web/sites/${FUNCTION_APP_NAME}/host/default/functionKeys/clientKey?api-version=2023-01-01"
130134
BODY="{\"properties\":{\"name\":\"ClientKey\",\"value\":\"${FUNCTION_KEY}\"}}"
131135

132-
if ! az rest --method put --uri "$URI" --body "$BODY" > /dev/null 2>&1; then
136+
REST_ERR=$(az rest --method put --uri "$URI" --body "$BODY" 2>&1 > /dev/null) || true
137+
if [ -n "$REST_ERR" ]; then
133138
echo "✗ ERROR: Failed to set function key on '${FUNCTION_APP_NAME}'." >&2
139+
echo " $REST_ERR" >&2
134140
restore_network_access
135141
exit 1
136142
fi
@@ -157,8 +163,10 @@ else
157163
if [ "$PG_PUBLIC_ACCESS" = "Disabled" ]; then
158164
echo "PostgreSQL has public access disabled (private networking detected)."
159165
echo "✓ Temporarily enabling public access on PostgreSQL '${SERVER_NAME}'..."
160-
if ! az postgres flexible-server update --resource-group "$RESOURCE_GROUP" --name "$SERVER_NAME" --public-access Enabled > /dev/null 2>&1; then
166+
PG_ERR=$(az postgres flexible-server update --resource-group "$RESOURCE_GROUP" --name "$SERVER_NAME" --public-access Enabled 2>&1 > /dev/null) || true
167+
if [ -n "$PG_ERR" ]; then
161168
echo "✗ ERROR: Failed to enable public access on PostgreSQL. Cannot proceed." >&2
169+
echo " $PG_ERR" >&2
162170
restore_network_access
163171
exit 1
164172
fi
@@ -215,17 +223,19 @@ else
215223
fi
216224
if [ "$IS_ADMIN" = "false" ]; then
217225
echo "✓ Adding current user as PostgreSQL Entra administrator..."
218-
if az postgres flexible-server ad-admin create \
226+
ADMIN_ERR=$(az postgres flexible-server ad-admin create \
219227
--resource-group "$RESOURCE_GROUP" \
220228
--server-name "$SERVER_NAME" \
221229
--display-name "$CURRENT_USER_UPN" \
222230
--object-id "$CURRENT_USER_OID" \
223-
--type User > /dev/null 2>&1; then
231+
--type User 2>&1 > /dev/null) || true
232+
if [ -z "$ADMIN_ERR" ]; then
224233
ADDED_PG_ADMIN=true
225234
echo "✓ PostgreSQL admin added. Waiting 60s for propagation..."
226235
sleep 60
227236
else
228237
echo "⚠ WARNING: Failed to add current user as PostgreSQL admin. Table creation may fail."
238+
echo " $ADMIN_ERR"
229239
fi
230240
else
231241
echo "✓ Current user is already a PostgreSQL Entra administrator."
@@ -256,7 +266,7 @@ else
256266
REQUIREMENTS_FILE="${SCRIPT_DIR}/data_scripts/requirements.txt"
257267
if [ -f "$REQUIREMENTS_FILE" ]; then
258268
echo "✓ Installing Python dependencies..."
259-
pip install -r "$REQUIREMENTS_FILE"
269+
pip install --user -r "$REQUIREMENTS_FILE" > /dev/null 2>&1 || echo "⚠ WARNING: pip install failed. Continuing anyway..."
260270
fi
261271

262272
echo "✓ Creating tables..."

0 commit comments

Comments
 (0)