Skip to content

Commit ce46763

Browse files
Merge pull request #700 from microsoft/psl-postdeploymentscript
docs: post deployment script changes
2 parents d63cdde + a016314 commit ce46763

File tree

3 files changed

+104
-49
lines changed

3 files changed

+104
-49
lines changed

docs/AVMPostDeploymentGuide.md

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
# AVM Post Deployment Guide
2+
This document provides guidance on post-deployment steps after deploying the Build Your Own Copilot Accelerator from the [AVM (Azure Verified Modules) repository](https://github.com/Azure/bicep-registry-modules/tree/main/avm/ptn/sa/build-your-own-copilot).
3+
4+
## Post Deployment Steps
5+
1. Clone the Repository
6+
First, clone this repository to access the post-deployment scripts:
7+
```bash
8+
git clone https://github.com/microsoft/Build-your-own-copilot-Solution-Accelerator.git
9+
```
10+
```bash
11+
cd Build-your-own-copilot-Solution-Accelerator
12+
```
13+
14+
2. Import Sample Data -Run bash command printed in the terminal. The bash command will look like the following:
15+
16+
```bash
17+
./infra/scripts/process_sample_data.sh <resourceGroupName>
18+
```
19+
If the deployment does not exist or has been deleted – The script will prompt you to manually enter the required values
20+
21+
3. Add Authentication Provider
22+
23+
Follow steps in [App Authentication](https://github.com/microsoft/Build-your-own-copilot-Solution-Accelerator/blob/main/docs/AppAuthentication.md) to configure authentication in app service.
24+
>Note that Authentication changes can take up to 10 minutes.
25+
26+
4. Deleting Resources After a Failed Deployment
27+
28+
Follow steps in [Delete Resource Group](https://github.com/microsoft/Build-your-own-copilot-Solution-Accelerator/blob/main/docs/DeleteResourceGroup.md) if your deployment fails and/or you need to clean up the resources.
29+
30+
By following these steps, you’ll ensure a smooth transition from deployment to hands-on usage.

infra/main.bicep

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -272,6 +272,7 @@ resource resourceGroupTags 'Microsoft.Resources/tags@2021-04-01' = {
272272
TemplateName: 'Client Advisor'
273273
Type: enablePrivateNetworking ? 'WAF' : 'Non-WAF'
274274
CreatedBy: createdBy
275+
DeploymentName: deployment().name
275276
}
276277
}
277278
}
@@ -1381,5 +1382,3 @@ output USE_AI_PROJECT_CLIENT string = useAIProjectClientFlag
13811382
@description('Indicates whether the internal stream should be used.')
13821383
output USE_INTERNAL_STREAM string = useInternalStream
13831384

1384-
@description('The client ID of the managed identity.')
1385-
output AZURE_CLIENT_ID string = userAssignedIdentity.outputs.clientId

infra/scripts/process_sample_data.sh

Lines changed: 73 additions & 47 deletions
Original file line numberDiff line numberDiff line change
@@ -2,16 +2,6 @@
22

33
# Variables
44
resourceGroupName="$1"
5-
cosmosDbAccountName="$2"
6-
storageAccount="$3"
7-
fileSystem="$4"
8-
keyvaultName="$5"
9-
sqlServerName="$6"
10-
SqlDatabaseName="$7"
11-
sqlManagedIdentityClientId="$8"
12-
sqlManagedIdentityDisplayName="$9"
13-
aiSearchName="${10}"
14-
aif_resource_id="${11}"
155

166
# Global variables to track original network access states
177
original_storage_public_access=""
@@ -20,6 +10,7 @@
2010
aif_resource_group=""
2111
aif_account_resource_id=""
2212
# Add global variable for SQL Server public access
13+
2314
original_sql_public_access=""
2415
created_sql_allow_all_firewall_rule="false"
2516
original_full_range_rule_present="false"
@@ -289,55 +280,90 @@
289280
# Set up trap to ensure cleanup happens on exit
290281
trap cleanup_on_exit EXIT INT TERM
291282

292-
# get parameters from azd env, if not provided
293-
if [ -z "$resourceGroupName" ]; then
294-
resourceGroupName=$(azd env get-value RESOURCE_GROUP_NAME)
283+
if az account show &> /dev/null; then
284+
echo "Already authenticated with Azure."
285+
else
286+
echo "Authenticating with Azure CLI..."
287+
az login
288+
echo "Authenticated with Azure CLI."
295289
fi
296290

291+
# fetch all variables from deployment outputs
297292

298-
if [ -z "$cosmosDbAccountName" ]; then
299-
cosmosDbAccountName=$(azd env get-value COSMOSDB_ACCOUNT_NAME)
300-
fi
301-
302-
if [ -z "$storageAccount" ]; then
303-
storageAccount=$(azd env get-value STORAGE_ACCOUNT_NAME)
304-
fi
293+
deploymentName=$(az group show --name "$resourceGroupName" --query "tags.DeploymentName" -o tsv)
294+
echo "Deployment Name (from tag): $deploymentName"
305295

306-
if [ -z "$fileSystem" ]; then
307-
fileSystem=$(azd env get-value STORAGE_CONTAINER_NAME)
308-
fi
296+
if az deployment group show --resource-group "$resourceGroupName" --name "$deploymentName" &>/dev/null; then
297+
cosmosDbAccountName=$(az deployment group show \
298+
--name "$deploymentName" \
299+
--resource-group "$resourceGroupName" \
300+
--query "properties.outputs.cosmosdB_ACCOUNT_NAME.value" -o tsv)
301+
echo "Cosmos DB Account Name (from outputs): $cosmosDbAccountName"
309302

310-
if [ -z "$keyvaultName" ]; then
311-
keyvaultName=$(azd env get-value KEY_VAULT_NAME)
312-
fi
303+
storageAccount=$(az deployment group show \
304+
--name "$deploymentName" \
305+
--resource-group "$resourceGroupName" \
306+
--query "properties.outputs.storagE_ACCOUNT_NAME.value" -o tsv)
307+
echo "Storage Account Name (from outputs): $storageAccount"
313308

314-
if [ -z "$sqlServerName" ]; then
315-
sqlServerName=$(azd env get-value SQLDB_SERVER_NAME)
316-
fi
309+
fileSystem=$(az deployment group show \
310+
--name "$deploymentName" \
311+
--resource-group "$resourceGroupName" \
312+
--query "properties.outputs.storagE_CONTAINER_NAME.value" -o tsv)
313+
echo "Storage Container Name (from outputs): $fileSystem"
317314

318-
if [ -z "$SqlDatabaseName" ]; then
319-
SqlDatabaseName=$(azd env get-value SQLDB_DATABASE)
320-
fi
315+
keyvaultName=$(az deployment group show \
316+
--name "$deploymentName" \
317+
--resource-group "$resourceGroupName" \
318+
--query "properties.outputs.keY_VAULT_NAME.value" -o tsv)
319+
echo "Key Vault Name (from outputs): $keyvaultName"
321320

322-
if [ -z "$sqlManagedIdentityClientId" ]; then
323-
# Use the SQL-specific managed identity for database operations with limited permissions
324-
sqlManagedIdentityClientId=$(azd env get-value MANAGEDIDENTITY_SQL_CLIENTID)
325-
fi
321+
sqlServerName=$(az deployment group show \
322+
--name "$deploymentName" \
323+
--resource-group "$resourceGroupName" \
324+
--query "properties.outputs.sqldB_SERVER_NAME.value" -o tsv)
325+
echo "SQL Server Name (from outputs): $sqlServerName"
326326

327-
if [ -z "$sqlManagedIdentityDisplayName" ]; then
328-
# Use the SQL-specific managed identity for database operations with limited permissions
329-
sqlManagedIdentityDisplayName=$(azd env get-value MANAGEDIDENTITY_SQL_NAME)
330-
fi
327+
webAppManagedIdentityDisplayName=$(az deployment group show \
328+
--name "$deploymentName" \
329+
--resource-group "$resourceGroupName" \
330+
--query "properties.outputs.managedidentitY_WEBAPP_NAME.value" -o tsv)
331+
echo "Web App Managed Identity Display Name (from outputs): $webAppManagedIdentityDisplayName"
331332

332-
if [ -z "$aiSearchName" ]; then
333-
aiSearchName=$(azd env get-value AI_SEARCH_SERVICE_NAME)
334-
fi
333+
aiSearchName=$(az deployment group show \
334+
--name "$deploymentName" \
335+
--resource-group "$resourceGroupName" \
336+
--query "properties.outputs.aI_SEARCH_SERVICE_NAME.value" -o tsv)
337+
echo "AI Search Service Name (from outputs): $aiSearchName"
335338

336-
if [ -z "$aif_resource_id" ]; then
337-
aif_resource_id=$(azd env get-value AI_FOUNDRY_RESOURCE_ID)
338-
fi
339+
aif_resource_id=$(az deployment group show \
340+
--name "$deploymentName" \
341+
--resource-group "$resourceGroupName" \
342+
--query "properties.outputs.aI_FOUNDRY_RESOURCE_ID.value" -o tsv)
343+
echo "AI Foundry Resource ID (from outputs): $aif_resource_id"
339344

340-
azSubscriptionId=$(azd env get-value AZURE_SUBSCRIPTION_ID)
345+
azSubscriptionId=$(az deployment group show \
346+
--name "$deploymentName" \
347+
--resource-group "$resourceGroupName" \
348+
--query "properties.outputs.azurE_SUBSCRIPTION_ID.value" -o tsv)
349+
350+
echo "Azure Subscription ID (from outputs): $azSubscriptionId"
351+
else
352+
echo "Deployment does NOT exist in resource group $resourceGroupName."
353+
echo "Please enter required values manually."
354+
355+
read -rp "Enter Cosmos DB Account Name: " cosmosDbAccountName
356+
read -rp "Enter Storage Account Name: " storageAccount
357+
read -rp "Enter Storage Container/File System Name: " fileSystem
358+
read -rp "Enter SQL Server Name: " sqlServerName
359+
read -rp "Enter SQL Database Name: " SqlDatabaseName
360+
read -rp "Enter Key Vault Name: " keyvaultName
361+
read -rp "Enter Web App Managed Identity Display Name: " webAppManagedIdentityDisplayName
362+
read -rp "Enter Web App Managed Identity Client ID: " webAppManagedIdentityClientId
363+
read -rp "Enter AI Search Service Name: " aiSearchName
364+
read -rp "Enter AI Foundry Resource ID: " aif_resource_id
365+
read -rp "Enter Azure Subscription ID: " azSubscriptionId
366+
fi
341367

342368
# Check if all required arguments are provided
343369
if [ -z "$resourceGroupName" ] || [ -z "$cosmosDbAccountName" ] || [ -z "$storageAccount" ] || [ -z "$fileSystem" ] || [ -z "$keyvaultName" ] || [ -z "$sqlServerName" ] || [ -z "$SqlDatabaseName" ] || [ -z "$sqlManagedIdentityClientId" ] || [ -z "$sqlManagedIdentityDisplayName" ] || [ -z "$aiSearchName" ] || [ -z "$aif_resource_id" ]; then

0 commit comments

Comments
 (0)