Skip to content

Commit e57859b

Browse files
validate resourcegroup name
1 parent 3c56cd4 commit e57859b

File tree

3 files changed

+26
-20
lines changed

3 files changed

+26
-20
lines changed

docs/CustomizeData.md

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -10,13 +10,14 @@ If you would like to update the solution to leverage your own data please follow
1010

1111
1. Navigate to the storage account in the resource group you are using for this solution.
1212
2. Open the `data` container
13-
3. If you have audio files, upload them to `custom_audiodata` folder. If you have call transcript files, upload them to `custom_call_transcripts` folder.
13+
3. If you have audio files, upload them to `custom_audiodata` folder. If you have call transcript files, upload them to `custom_transcripts` folder.
1414
4. Navigate to the terminal and run the `run_process_data_script.sh` to process the new data into the solution with the following commands.
15-
```shell
16-
cd infra
15+
```shell
16+
cd infra/scripts
1717

1818
az login
1919

20-
bash run_process_data_script.sh
21-
```
20+
bash run_process_data_script.sh resourcegroupname_param
21+
```
22+
a. resourcegroupname_param - the name of the resource group.
2223

infra/scripts/index_scripts/04_cu_process_data_new_data.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@
1717
key_vault_name = 'kv_to-be-replaced'
1818

1919
file_system_client_name = "data"
20-
directory = 'custom_call_transcripts'
20+
directory = 'custom_transcripts'
2121
audio_directory = 'custom_audiodata'
2222

2323
def get_secrets_from_kv(kv_name, secret_name):
Lines changed: 19 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,36 +1,41 @@
11
#!/bin/bash
22

33
# === Configuration ===
4-
RESOURCE_GROUP="$1"
5-
BICEP_FILE="./../process_data_scripts.bicep"
4+
resourceGroupName="$1"
5+
bicepFile="./../process_data_scripts.bicep"
66

7-
# === Validate input ===
8-
if [[ -z "$RESOURCE_GROUP" ]]; then
9-
echo "Usage: $0 <RESOURCE_GROUP>"
10-
echo "ERROR: RESOURCE_GROUP parameter is required."
11-
exit 1
7+
# If resourcegroup not provided as an argument, get it from AZD environment
8+
if [ -z "$resourceGroupName" ]; then
9+
resourceGroupName=$(azd env get-value RESOURCE_GROUP_NAME 2>/dev/null)
10+
fi
11+
12+
# Validate the value was eventually set
13+
if [ -z "$resourceGroupName" ]; then
14+
echo "Usage: $0 <resourceGroupName>"
15+
echo "ERROR: resourceGroupName not provided and not found in AZD environment."
16+
exit 1
1217
fi
1318

1419
# === Ensure user is logged in to Azure CLI ===
1520
az account show > /dev/null 2>&1 || az login
1621

17-
echo "Fetching Key Vault and Managed Identity from resource group: $RESOURCE_GROUP"
22+
echo "Fetching Key Vault and Managed Identity from resource group: $resourceGroupName"
1823

1924
# === Retrieve the first Key Vault name from the specified resource group ===
20-
keyVaultName=$(az keyvault list --resource-group "$RESOURCE_GROUP" --query "[0].name" -o tsv)
25+
keyVaultName=$(az keyvault list --resource-group "$resourceGroupName" --query "[0].name" -o tsv)
2126

2227
# === Retrieve the ID of the first user-assigned identity with name starting with 'id-' ===
23-
identityId=$(az identity list --resource-group "$RESOURCE_GROUP" --query "[?starts_with(name, 'id-')].id | [0]" -o tsv)
28+
identityId=$(az identity list --resource-group "$resourceGroupName" --query "[?starts_with(name, 'id-')].id | [0]" -o tsv)
2429

2530
# === Normalize identityId (necessary for compatibility in Git Bash on Windows) ===
2631
identityId=$(echo "$identityId" | sed -E 's|.*(/subscriptions/)|\1|')
2732

2833
# === Get the location of the first SQL Server in the resource group ===
29-
sqlServerLocation=$(az sql server list --resource-group "$RESOURCE_GROUP" --query "[0].location" -o tsv)
34+
sqlServerLocation=$(az sql server list --resource-group "$resourceGroupName" --query "[0].location" -o tsv)
3035

3136
# === Validate that all required resources were found ===
3237
if [[ -z "$keyVaultName" || -z "$sqlServerLocation" || -z "$identityId" || ! "$identityId" =~ ^/subscriptions/ ]]; then
33-
echo "ERROR: Could not find required resources in resource group $RESOURCE_GROUP or identityId is invalid"
38+
echo "ERROR: Could not find required resources in resource group $resourceGroupName or identityId is invalid"
3439
exit 1
3540
fi
3641

@@ -43,8 +48,8 @@ echo "Deploying Bicep template..."
4348

4449
# MSYS_NO_PATHCONV disables path conversion in Git Bash for Windows
4550
MSYS_NO_PATHCONV=1 az deployment group create \
46-
--resource-group "$RESOURCE_GROUP" \
47-
--template-file "$BICEP_FILE" \
51+
--resource-group "$resourceGroupName" \
52+
--template-file "$bicepFile" \
4853
--parameters solutionLocation="$sqlServerLocation" keyVaultName="$keyVaultName" identity="$identityId"
4954

5055
echo "Deployment completed."

0 commit comments

Comments
 (0)