Skip to content

Commit 8aa38d3

Browse files
Merge pull request #622 from microsoft/fix-customdeploymentissue
fix: Custom file Deployment Issue [Bug 24589]
2 parents 1be3b12 + 595e5c0 commit 8aa38d3

File tree

3 files changed

+108
-32
lines changed

3 files changed

+108
-32
lines changed

documents/CustomizeData.md

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,9 @@ 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+
14+
> **Note for WAF-aligned deployments:** If your deployment uses private networking, you'll need to log into a VM within the virtual network to upload files. See [VM login instructions](#how-to-login-to-vm-using-azure-bastion) below.
15+
1316
3. If you have audio files, upload them to `custom_audiodata` folder. If you have call transcript files, upload them to `custom_transcripts` folder.
1417
4. Navigate to the terminal and run the `run_process_data_scripts.sh` to process the new data into the solution with the following commands.
1518
```shell
@@ -21,17 +24,14 @@ If you would like to update the solution to leverage your own data please follow
2124
```
2225
a. resourcegroupname_param - the name of the resource group.
2326

24-
> Note (WAF‑aligned deployments): If you deployed the solution with the WAF / private networking option enabled, you must run the data processing script **from inside the deployed VM (jumpbox / processing VM)** so it can reach the private endpoints. Follow these steps:
25-
>
26-
> 1. Connect to the VM (Azure Bastion, SSH, or RDP depending on OS).
27-
> 2. Ensure the repo (or the `infra/scripts` folder) is present. If not, clone or pull it.
28-
> 3. Open a Bash-compatible shell (Git Bash on Windows, or native bash on Linux).
29-
> 4. Run `az login` (add `--tenant <tenantId>` if required by your org policy).
30-
> 5. Navigate to `infra/scripts` and execute:
31-
> ```bash
32-
> bash run_process_data_scripts.sh <resource-group-name>
33-
> ```
34-
> 6. Replace `<resource-group-name>` with the name of the resource group you deployed (same value used for `resourcegroupname_param`).
35-
>
36-
> Tip: If Azure CLI is not installed on the VM, install it first (see official docs) before running the script.
27+
## How to Login to VM Using Azure Bastion
28+
29+
For WAF-aligned deployments with private networking:
30+
31+
1. Navigate to your VM in the Azure portal
32+
2. Click **Connect****Bastion**
33+
3. Enter your VM credentials (username and password) and click **Connect**
34+
4. Wait for the Bastion connection to establish - this may take a few moments
35+
5. Once connected, you'll have access to the VM desktop/terminal interface
36+
3737

infra/process_data_scripts.bicep

Lines changed: 24 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -2,25 +2,33 @@ param solutionLocation string
22
param keyVaultName string
33
param managedIdentityResourceId string
44
param managedIdentityClientId string
5+
param storageAccount string
6+
param enablePrivateNetworking bool = false
7+
param subnetId string = ''
58

69
var baseUrl = 'https://raw.githubusercontent.com/microsoft/Conversation-Knowledge-Mining-Solution-Accelerator/main/'
710

8-
resource process_data_scripts 'Microsoft.Resources/deploymentScripts@2020-10-01' = {
9-
kind:'AzureCLI'
10-
name: 'process_data_scripts'
11-
location: solutionLocation // Replace with your desired location
12-
identity: {
13-
type: 'UserAssigned'
14-
userAssignedIdentities: {
15-
'${managedIdentityResourceId}' : {}
16-
}
17-
}
18-
properties: {
11+
module uploadFiles 'br/public:avm/res/resources/deployment-script:0.5.1' = {
12+
name: take('avm.res.resources.deployment-script.uploadFiles', 64)
13+
params: {
14+
kind: 'AzureCLI'
15+
name: 'process_data_scripts'
1916
azCliVersion: '2.52.0'
20-
primaryScriptUri: '${baseUrl}infra/scripts/process_data_scripts.sh'
21-
arguments: '${baseUrl} ${keyVaultName} ${managedIdentityClientId}' // Specify any arguments for the script
22-
timeout: 'PT1H' // Specify the desired timeout duration
23-
retentionInterval: 'PT1H' // Specify the desired retention interval
24-
cleanupPreference:'OnSuccess'
17+
cleanupPreference: 'Always'
18+
location: solutionLocation
19+
managedIdentities: {
20+
userAssignedResourceIds: [
21+
managedIdentityResourceId
22+
]
23+
}
24+
retentionInterval: 'P1D'
25+
runOnce: true
26+
primaryScriptUri: '${baseUrl}infra/scripts/process_data_scripts.sh'
27+
arguments: '${baseUrl} ${keyVaultName} ${managedIdentityClientId}'
28+
storageAccountResourceId: storageAccount
29+
subnetResourceIds: (enablePrivateNetworking && !empty(subnetId)) ? [
30+
subnetId
31+
] : null
32+
timeout: 'PT1H'
2533
}
2634
}

infra/scripts/run_process_data_scripts.sh

Lines changed: 71 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -36,24 +36,92 @@ sqlServerLocation=$(az sql server list --resource-group "$resourceGroupName" --q
3636
# === Retrieve the principal ID of the first user-assigned identity with name starting with 'id-' ===
3737
managedIdentityClientId=$(az identity list --resource-group "$resourceGroupName" --query "[?starts_with(name, 'id-') && !starts_with(name, 'id-sql-')].clientId | [0]" -o tsv)
3838

39+
# === Check for VNet deployment ===
40+
echo "Checking for VNet deployment in resource group: $resourceGroupName"
41+
vnetResourceId=$(az network vnet list --resource-group "$resourceGroupName" --query "[0].id" -o tsv)
42+
43+
# === Get resource group location ===
44+
rgLocation=$(az group show --name "$resourceGroupName" --query "location" -o tsv)
45+
46+
# === Find storage account (always needed) ===
47+
echo "Looking for storage account in resource group..."
48+
storageAccountResourceId=$(az storage account list --resource-group "$resourceGroupName" --query "[0].id" -o tsv)
49+
50+
if [ -z "$storageAccountResourceId" ]; then
51+
echo "ERROR: No storage account found in resource group $resourceGroupName"
52+
exit 1
53+
else
54+
echo "Using storage account: $storageAccountResourceId"
55+
fi
56+
57+
if [ -z "$vnetResourceId" ]; then
58+
echo "No VNet found in resource group. Private networking is disabled."
59+
enablePrivateNetworking="false"
60+
subnetId=""
61+
solutionLocation="$sqlServerLocation"
62+
echo "Using SQL Server location for solution: $solutionLocation"
63+
else
64+
echo "VNet found: $vnetResourceId"
65+
echo "VNet detected - enabling private networking."
66+
enablePrivateNetworking="true"
67+
solutionLocation="$rgLocation"
68+
echo "Using Resource Group location for solution: $solutionLocation"
69+
70+
# === Find the deployment script subnet ===
71+
echo "Looking for deployment-scripts subnet..."
72+
subnetId=$(az network vnet subnet list --resource-group "$resourceGroupName" --vnet-name $(basename "$vnetResourceId") --query "[?name=='deployment-scripts'].id | [0]" -o tsv)
73+
74+
if [ -z "$subnetId" ]; then
75+
echo "Warning: deployment-scripts subnet not found. Checking for alternative subnet names..."
76+
# Try alternative names
77+
subnetId=$(az network vnet subnet list --resource-group "$resourceGroupName" --vnet-name $(basename "$vnetResourceId") --query "[?contains(name, 'deployment') || contains(name, 'script')].id | [0]" -o tsv)
78+
fi
79+
80+
if [ -z "$subnetId" ]; then
81+
echo "Warning: No deployment script subnet found. Private networking will be disabled for deployment script."
82+
enablePrivateNetworking="false"
83+
subnetId=""
84+
else
85+
echo "Using deployment script subnet: $subnetId"
86+
fi
87+
fi
88+
3989
# === Validate that all required resources were found ===
40-
if [[ -z "$keyVaultName" || -z "$sqlServerLocation" || -z "$managedIdentityResourceId" || ! "$managedIdentityResourceId" =~ ^/subscriptions/ ]]; then
90+
if [[ -z "$keyVaultName" || -z "$solutionLocation" || -z "$managedIdentityResourceId" || ! "$managedIdentityResourceId" =~ ^/subscriptions/ ]]; then
4191
echo "ERROR: Could not find required resources in resource group $resourceGroupName or managedIdentityResourceId is invalid"
4292
exit 1
4393
fi
4494

45-
echo "Using SQL Server Location: $sqlServerLocation"
95+
echo "Using Solution Location: $solutionLocation"
4696
echo "Using Key Vault: $keyVaultName"
4797
echo "Using Managed Identity Resource Id: $managedIdentityResourceId"
4898
echo "Using Managed Identity ClientId Id: $managedIdentityClientId"
99+
echo "Enable Private Networking: $enablePrivateNetworking"
100+
echo "Subnet ID: $subnetId"
101+
echo "Storage Account Resource ID: $storageAccountResourceId"
49102

50103
# === Deploy resources using the specified Bicep template ===
51104
echo "Deploying Bicep template..."
52105

106+
# Build base parameters
107+
deploymentParams="solutionLocation=$solutionLocation keyVaultName=$keyVaultName managedIdentityResourceId=$managedIdentityResourceId managedIdentityClientId=$managedIdentityClientId storageAccount=$storageAccountResourceId"
108+
109+
# Add networking parameters if VNet is deployed
110+
if [ "$enablePrivateNetworking" = "true" ]; then
111+
deploymentParams="$deploymentParams enablePrivateNetworking=true"
112+
if [ -n "$subnetId" ]; then
113+
deploymentParams="$deploymentParams subnetId=$subnetId"
114+
fi
115+
else
116+
deploymentParams="$deploymentParams enablePrivateNetworking=false"
117+
fi
118+
119+
echo "Deployment parameters: $deploymentParams"
120+
53121
# MSYS_NO_PATHCONV disables path conversion in Git Bash for Windows
54122
MSYS_NO_PATHCONV=1 az deployment group create \
55123
--resource-group "$resourceGroupName" \
56124
--template-file "$bicepFile" \
57-
--parameters solutionLocation="$sqlServerLocation" keyVaultName="$keyVaultName" managedIdentityResourceId="$managedIdentityResourceId" managedIdentityClientId="$managedIdentityClientId"
125+
--parameters $deploymentParams
58126

59127
echo "Deployment completed."

0 commit comments

Comments
 (0)