Skip to content

Commit 4da5f79

Browse files
post deployment script changes
1 parent c6f19ab commit 4da5f79

File tree

3 files changed

+118
-44
lines changed

3 files changed

+118
-44
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: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -287,6 +287,7 @@ resource resourceGroupTags 'Microsoft.Resources/tags@2021-04-01' = {
287287
TemplateName: 'Client Advisor'
288288
Type: enablePrivateNetworking ? 'WAF' : 'Non-WAF'
289289
CreatedBy: createdBy
290+
DeploymentName: deployment().name
290291
}
291292
}
292293
}
@@ -1367,3 +1368,6 @@ output USE_AI_PROJECT_CLIENT string = useAIProjectClientFlag
13671368

13681369
@description('Indicates whether the internal stream should be used.')
13691370
output USE_INTERNAL_STREAM string = useInternalStream
1371+
1372+
@description('The subscription ID where the resources are deployed.')
1373+
output AZURE_SUBSCRIPTION_ID string = subscription().subscriptionId

infra/scripts/process_sample_data.sh

Lines changed: 84 additions & 44 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-
webAppManagedIdentityClientId="$8"
12-
webAppManagedIdentityDisplayName="$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"
@@ -286,53 +277,102 @@
286277
# Set up trap to ensure cleanup happens on exit
287278
trap cleanup_on_exit EXIT INT TERM
288279

289-
# get parameters from azd env, if not provided
290-
if [ -z "$resourceGroupName" ]; then
291-
resourceGroupName=$(azd env get-value RESOURCE_GROUP_NAME)
280+
if az account show &> /dev/null; then
281+
echo "Already authenticated with Azure."
282+
else
283+
echo "Authenticating with Azure CLI..."
284+
az login
285+
echo "Authenticated with Azure CLI."
292286
fi
293287

288+
# fetch all variables from deployment outputs
294289

295-
if [ -z "$cosmosDbAccountName" ]; then
296-
cosmosDbAccountName=$(azd env get-value COSMOSDB_ACCOUNT_NAME)
297-
fi
290+
deploymentName=$(az group show --name "$resourceGroupName" --query "tags.DeploymentName" -o tsv)
291+
echo "Deployment Name (from tag): $deploymentName"
298292

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

303-
if [ -z "$fileSystem" ]; then
304-
fileSystem=$(azd env get-value STORAGE_CONTAINER_NAME)
305-
fi
300+
storageAccount=$(az deployment group show \
301+
--name "$deploymentName" \
302+
--resource-group "$resourceGroupName" \
303+
--query "properties.outputs.storagE_ACCOUNT_NAME.value" -o tsv)
304+
echo "Storage Account Name (from outputs): $storageAccount"
306305

307-
if [ -z "$keyvaultName" ]; then
308-
keyvaultName=$(azd env get-value KEY_VAULT_NAME)
309-
fi
306+
fileSystem=$(az deployment group show \
307+
--name "$deploymentName" \
308+
--resource-group "$resourceGroupName" \
309+
--query "properties.outputs.storagE_CONTAINER_NAME.value" -o tsv)
310+
echo "Storage Container Name (from outputs): $fileSystem"
310311

311-
if [ -z "$sqlServerName" ]; then
312-
sqlServerName=$(azd env get-value SQLDB_SERVER_NAME)
313-
fi
312+
keyvaultName=$(az deployment group show \
313+
--name "$deploymentName" \
314+
--resource-group "$resourceGroupName" \
315+
--query "properties.outputs.keY_VAULT_NAME.value" -o tsv)
316+
echo "Key Vault Name (from outputs): $keyvaultName"
314317

315-
if [ -z "$SqlDatabaseName" ]; then
316-
SqlDatabaseName=$(azd env get-value SQLDB_DATABASE)
317-
fi
318+
sqlServerName=$(az deployment group show \
319+
--name "$deploymentName" \
320+
--resource-group "$resourceGroupName" \
321+
--query "properties.outputs.sqldB_SERVER_NAME.value" -o tsv)
322+
echo "SQL Server Name (from outputs): $sqlServerName"
318323

319-
if [ -z "$webAppManagedIdentityClientId" ]; then
320-
webAppManagedIdentityClientId=$(azd env get-value MANAGEDIDENTITY_WEBAPP_CLIENTID)
321-
fi
324+
SqlDatabaseName=$(az deployment group show \
325+
--name "$deploymentName" \
326+
--resource-group "$resourceGroupName" \
327+
--query "properties.outputs.sqldB_DATABASE.value" -o tsv)
328+
echo "SQL Database Name (from outputs): $SqlDatabaseName"
322329

323-
if [ -z "$webAppManagedIdentityDisplayName" ]; then
324-
webAppManagedIdentityDisplayName=$(azd env get-value MANAGEDIDENTITY_WEBAPP_NAME)
325-
fi
330+
webAppManagedIdentityClientId=$(az deployment group show \
331+
--name "$deploymentName" \
332+
--resource-group "$resourceGroupName" \
333+
--query "properties.outputs.managedidentitY_WEBAPP_CLIENTID.value" -o tsv)
334+
echo "Web App Managed Identity Client ID (from outputs): $webAppManagedIdentityClientId"
326335

327-
if [ -z "$aiSearchName" ]; then
328-
aiSearchName=$(azd env get-value AI_SEARCH_SERVICE_NAME)
329-
fi
336+
webAppManagedIdentityDisplayName=$(az deployment group show \
337+
--name "$deploymentName" \
338+
--resource-group "$resourceGroupName" \
339+
--query "properties.outputs.managedidentitY_WEBAPP_NAME.value" -o tsv)
340+
echo "Web App Managed Identity Display Name (from outputs): $webAppManagedIdentityDisplayName"
330341

331-
if [ -z "$aif_resource_id" ]; then
332-
aif_resource_id=$(azd env get-value AI_FOUNDRY_RESOURCE_ID)
333-
fi
342+
aiSearchName=$(az deployment group show \
343+
--name "$deploymentName" \
344+
--resource-group "$resourceGroupName" \
345+
--query "properties.outputs.aI_SEARCH_SERVICE_NAME.value" -o tsv)
346+
echo "AI Search Service Name (from outputs): $aiSearchName"
334347

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

337377
# Check if all required arguments are provided
338378
if [ -z "$resourceGroupName" ] || [ -z "$cosmosDbAccountName" ] || [ -z "$storageAccount" ] || [ -z "$fileSystem" ] || [ -z "$keyvaultName" ] || [ -z "$sqlServerName" ] || [ -z "$SqlDatabaseName" ] || [ -z "$webAppManagedIdentityClientId" ] || [ -z "$webAppManagedIdentityDisplayName" ] || [ -z "$aiSearchName" ] || [ -z "$aif_resource_id" ]; then

0 commit comments

Comments
 (0)