Skip to content

Commit 5ac87b0

Browse files
Merge pull request #483 from microsoft/dev
feat: Merge the AVM WAF,Azd Quota check, EXP changes from dev to main
2 parents 2d7d122 + 29db4d4 commit 5ac87b0

19 files changed

+607
-177
lines changed

docs/DeploymentGuide.md

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -134,6 +134,42 @@ To adjust quota settings, follow these [steps](./AzureGPTQuotaSettings.md).
134134

135135
</details>
136136

137+
<details>
138+
139+
<summary><b>Reusing an Existing Log Analytics Workspace</b></summary>
140+
141+
To configure your environment to use an existing Log Analytics Workspace, follow these steps:
142+
143+
#### 1. Navigate to Azure Portal
144+
Go to [Azure Portal](https://portal.azure.com)
145+
146+
#### 2. Find Your Log Analytics Workspace
147+
- In the search bar at the top, type "Log Analytics workspaces" and select it.
148+
- Click on the workspace you want to use.
149+
150+
![Log Analytics Resource List](../docs/images/logAnalyticsList.png)
151+
152+
#### 3. Copy Workspace Id
153+
- In the Overview pane, Click on **JSON View**
154+
155+
![Log Analytics](../docs/images/logAnalytics.png)
156+
157+
- Copy the **Resource ID** (this is your Workspace ID)
158+
159+
![Log Analytics JSON](../docs/images/logAnalyticsJson.png)
160+
161+
#### 4. Set the Workspace ID in Your Environment
162+
Run the following command in your terminal
163+
```bash
164+
azd env set AZURE_ENV_LOG_ANALYTICS_WORKSPACE_ID '<Existing Log Analytics Workspace Id>'
165+
```
166+
Replace `<Existing Log Analytics Workspace Id>` with the full Resource ID obtained from Step 3.
167+
168+
#### 5. Continue Deployment
169+
Continue with the [deploying steps](#deploying-with-azd).
170+
171+
</details>
172+
137173
### Deploying with AZD
138174

139175
Once you've opened the project in [Codespaces](#github-codespaces), [Dev Containers](#vs-code-dev-containers), or [locally](#local-environment), you can deploy it to Azure by following these steps:

docs/images/logAnalytics.png

142 KB
Loading

docs/images/logAnalyticsJson.png

196 KB
Loading

docs/images/logAnalyticsList.png

88.9 KB
Loading

infra/main.bicep

Lines changed: 19 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -6,16 +6,25 @@ targetScope = 'resourceGroup'
66
@description('A unique prefix for all resources in this deployment. This should be 3-20 characters long:')
77
param environmentName string
88

9+
@minLength(1)
10+
@description('Secondary location for databases creation(example:eastus2):')
11+
param secondaryLocation string = 'eastus2'
12+
13+
@description('Azure location for the solution. If not provided, it defaults to the resource group location.')
14+
param AZURE_LOCATION string=''
15+
16+
// ========== AI Deployments Location ========== //
17+
@description('Location for AI deployments. This should be a valid Azure region where OpenAI services are available.')
918
@metadata({
1019
azd: {
1120
type: 'location'
21+
usageName: [
22+
'OpenAI.GlobalStandard.gpt4.1,150'
23+
'OpenAI.Standard.text-embedding-ada-002,80'
24+
]
1225
}
1326
})
14-
15-
16-
@minLength(1)
17-
@description('Secondary location for databases creation(example:eastus2):')
18-
param secondaryLocation string
27+
param aiDeploymentsLocation string
1928

2029
@minLength(1)
2130
@description('GPT model deployment type:')
@@ -31,28 +40,26 @@ param gptModelName string = 'gpt-4.1'
3140
@description('Version of the GPT model to deploy:')
3241
param gptModelVersion string = '2025-04-14'
3342

34-
param azureOpenaiAPIVersion string = '2024-05-01-preview'
43+
@description('API version for Azure OpenAI service. This should be a valid API version supported by the service.')
44+
param azureOpenaiAPIVersion string = '2025-01-01-preview'
3545

3646
@minValue(10)
3747
@description('Capacity of the GPT deployment:')
3848
// You can increase this, but capacity is limited per model/region, so you will get errors if you go over
3949
// https://learn.microsoft.com/en-us/azure/ai-services/openai/quotas-limits
40-
param gptDeploymentCapacity int = 30
50+
param gptDeploymentCapacity int = 150
4151

4252
@minLength(1)
4353
@description('Name of the Text Embedding model to deploy:')
44-
@allowed([
45-
'text-embedding-ada-002'
46-
])
4754
param embeddingModel string = 'text-embedding-ada-002'
4855

4956
var abbrs = loadJsonContent('./abbreviations.json')
5057
@minValue(10)
5158
@description('Capacity of the Embedding Model deployment')
5259
param embeddingDeploymentCapacity int = 80
5360

61+
@description('Image tag for the App Service container. Default is "latest".')
5462
param imageTag string = 'latest'
55-
param AZURE_LOCATION string=''
5663

5764
@description('Optional: Existing Log Analytics Workspace Resource ID')
5865
param existingLogAnalyticsWorkspaceId string = ''
@@ -91,7 +98,7 @@ module aifoundry 'deploy_ai_foundry.bicep' = {
9198
name: 'deploy_ai_foundry'
9299
params: {
93100
solutionName: solutionPrefix
94-
solutionLocation: solutionLocation
101+
solutionLocation: aiDeploymentsLocation
95102
keyVaultName: kvault.outputs.keyvaultName
96103
deploymentType: deploymentType
97104
gptModelName: gptModelName

infra/main.bicepparam

Lines changed: 0 additions & 17 deletions
This file was deleted.

infra/main.parameters.json

Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
1+
{
2+
"$schema": "https://schema.management.azure.com/schemas/2019-04-01/deploymentParameters.json#",
3+
"contentVersion": "1.0.0.0",
4+
"parameters": {
5+
"environmentName": {
6+
"value": "${AZURE_ENV_NAME}"
7+
},
8+
"location": {
9+
"value": "${AZURE_LOCATION}"
10+
},
11+
"secondaryLocation": {
12+
"value": "${AZURE_ENV_SECONDARY_LOCATION}"
13+
},
14+
"gptModelVersion": {
15+
"value": "${AZURE_ENV_MODEL_VERSION}"
16+
},
17+
"deploymentType": {
18+
"value": "${AZURE_ENV_MODEL_DEPLOYMENT_TYPE}"
19+
},
20+
"gptModelName": {
21+
"value": "${AZURE_ENV_MODEL_NAME}"
22+
},
23+
"azureOpenaiAPIVersion": {
24+
"value": "${AZURE_ENV_OPENAI_API_VERSION}"
25+
},
26+
"gptDeploymentCapacity": {
27+
"value": "${AZURE_ENV_MODEL_CAPACITY}"
28+
},
29+
"embeddingModel": {
30+
"value": "${AZURE_ENV_EMBEDDING_MODEL_NAME}"
31+
},
32+
"embeddingDeploymentCapacity": {
33+
"value": "${AZURE_ENV_EMBEDDING_MODEL_CAPACITY}"
34+
},
35+
"azureOpenaiAPIVersion ": {
36+
"value": "${AZURE_ENV_OPENAI_API_VERSION}"
37+
},
38+
"imageTag": {
39+
"value": "${AZURE_ENV_IMAGETAG}"
40+
},
41+
"existingLogAnalyticsWorkspaceId": {
42+
"value": "${AZURE_ENV_LOG_ANALYTICS_WORKSPACE_ID}"
43+
}
44+
}
45+
}

infra/scripts/copy_kb_files.sh

Lines changed: 24 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,12 +46,14 @@ if [ -z "$role_assignment" ]; then
4646
MSYS_NO_PATHCONV=1 az role assignment create --assignee $signed_user_id --role "Storage Blob Data Contributor" --scope $storage_account_resource_id --output none
4747
if [ $? -eq 0 ]; then
4848
echo "Role assignment completed successfully."
49+
sleep 5
4950
retries=3
5051
while [ $retries -gt 0 ]; do
5152
# Check if the role assignment was successful
5253
role_assignment_check=$(MSYS_NO_PATHCONV=1 az role assignment list --assignee $signed_user_id --role "Storage Blob Data Contributor" --scope $storage_account_resource_id --query "[].roleDefinitionId" -o tsv)
5354
if [ -n "$role_assignment_check" ]; then
5455
echo "Role assignment verified successfully."
56+
sleep 5
5557
break
5658
else
5759
echo "Role assignment not found, retrying..."
@@ -93,6 +95,27 @@ unzip -o $zipUrl1 -d infra/data/"$extractedFolder1"
9395
# unzip /mnt/azscripts/azscriptinput/"$zipFileName2" -d /mnt/azscripts/azscriptinput/"$extractedFolder2"
9496

9597
# Using az storage blob upload-batch to upload files with managed identity authentication, as the az storage fs directory upload command is not working with managed identity authentication.
96-
echo "Uploading files to Azure Storage"
98+
echo "Uploading files to Azure Blob Storage"
9799
az storage blob upload-batch --account-name "$storageAccount" --destination "$fileSystem"/"$extractedFolder1" --source infra/data/"$extractedFolder1" --auth-mode login --pattern '*' --overwrite --output none
100+
if [ $? -ne 0 ]; then
101+
retries=3
102+
sleepTime=10
103+
echo "Error: Failed to upload files to Azure Blob Storage. Retrying upload...($((4 - retries)) of 3)"
104+
while [ $retries -gt 0 ]; do
105+
sleep $sleepTime
106+
az storage blob upload-batch --account-name "$storageAccount" --destination "$fileSystem"/"$extractedFolder1" --source infra/data/"$extractedFolder1" --auth-mode login --pattern '*' --overwrite --output none
107+
if [ $? -eq 0 ]; then
108+
echo "Files uploaded successfully to Azure Blob Storage."
109+
break
110+
else
111+
((retries--))
112+
echo "Retrying upload... ($((4 - retries)) of 3)"
113+
sleepTime=$((sleepTime * 2))
114+
sleep $sleepTime
115+
fi
116+
done
117+
exit 1
118+
else
119+
echo "Files uploaded successfully to Azure Blob Storage."
120+
fi
98121
# az storage blob upload-batch --account-name "$storageAccount" --destination data/"$extractedFolder2" --source /mnt/azscripts/azscriptinput/"$extractedFolder2" --auth-mode login --pattern '*' --overwrite

infra/scripts/process_sample_data.sh

Lines changed: 60 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,12 +34,72 @@ if [ -z "$aiFoundryName" ]; then
3434
aiFoundryName=$(azd env get-value AI_FOUNDRY_NAME)
3535
fi
3636

37+
azSubscriptionId=$(azd env get-value AZURE_SUBSCRIPTION_ID)
38+
3739
# Check if all required arguments are provided
3840
if [ -z "$storageAccount" ] || [ -z "$fileSystem" ] || [ -z "$keyvaultName" ] || [ -z "$cosmosDbAccountName" ] || [ -z "$resourceGroupName" ] || [ -z "$aiFoundryName" ]; then
3941
echo "Usage: $0 <storageAccount> <storageContainerName> <keyvaultName> <cosmosDbAccountName> <resourceGroupName> <aiFoundryName>"
4042
exit 1
4143
fi
4244

45+
# Authenticate with Azure
46+
if az account show &> /dev/null; then
47+
echo "Already authenticated with Azure."
48+
else
49+
if [ -n "$managedIdentityClientId" ]; then
50+
# Use managed identity if running in Azure
51+
echo "Authenticating with Managed Identity..."
52+
az login --identity --client-id ${managedIdentityClientId}
53+
else
54+
# Use Azure CLI login if running locally
55+
echo "Authenticating with Azure CLI..."
56+
az login
57+
fi
58+
echo "Not authenticated with Azure. Attempting to authenticate..."
59+
fi
60+
61+
#check if user has selected the correct subscription
62+
currentSubscriptionId=$(az account show --query id -o tsv)
63+
currentSubscriptionName=$(az account show --query name -o tsv)
64+
if [ "$currentSubscriptionId" != "$azSubscriptionId" ]; then
65+
echo "Current selected subscription is $currentSubscriptionName ( $currentSubscriptionId )."
66+
read -rp "Do you want to continue with this subscription?(y/n): " confirmation
67+
if [[ "$confirmation" != "y" && "$confirmation" != "Y" ]]; then
68+
echo "Fetching available subscriptions..."
69+
availableSubscriptions=$(az account list --query "[?state=='Enabled'].[name,id]" --output tsv)
70+
while true; do
71+
echo ""
72+
echo "Available Subscriptions:"
73+
echo "========================"
74+
echo "$availableSubscriptions" | awk '{printf "%d. %s ( %s )\n", NR, $1, $2}'
75+
echo "========================"
76+
echo ""
77+
read -rp "Enter the number of the subscription (1-$(echo "$availableSubscriptions" | wc -l)) to use: " subscriptionIndex
78+
if [[ "$subscriptionIndex" =~ ^[0-9]+$ ]] && [ "$subscriptionIndex" -ge 1 ] && [ "$subscriptionIndex" -le $(echo "$availableSubscriptions" | wc -l) ]; then
79+
selectedSubscription=$(echo "$availableSubscriptions" | sed -n "${subscriptionIndex}p")
80+
selectedSubscriptionName=$(echo "$selectedSubscription" | cut -f1)
81+
selectedSubscriptionId=$(echo "$selectedSubscription" | cut -f2)
82+
83+
# Set the selected subscription
84+
if az account set --subscription "$selectedSubscriptionId"; then
85+
echo "Switched to subscription: $selectedSubscriptionName ( $selectedSubscriptionId )"
86+
break
87+
else
88+
echo "Failed to switch to subscription: $selectedSubscriptionName ( $selectedSubscriptionId )."
89+
fi
90+
else
91+
echo "Invalid selection. Please try again."
92+
fi
93+
done
94+
else
95+
echo "Proceeding with the current subscription: $currentSubscriptionName ( $currentSubscriptionId )"
96+
az account set --subscription "$currentSubscriptionId"
97+
fi
98+
else
99+
echo "Proceeding with the subscription: $currentSubscriptionName ( $currentSubscriptionId )"
100+
az account set --subscription "$currentSubscriptionId"
101+
fi
102+
43103
# Call add_cosmosdb_access.sh
44104
echo "Running add_cosmosdb_access.sh"
45105
bash infra/scripts/add_cosmosdb_access.sh "$resourceGroupName" "$cosmosDbAccountName" "$managedIdentityClientId"

tests/e2e-test/README.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,11 +20,11 @@ This will create a virtual environment directory named microsoft inside your cur
2020
Installing Playwright Pytest from Virtual Environment
2121

2222
- To install libraries run "pip install -r requirements.txt"
23-
- Install the required browsers "playwright install"
23+
2424

2525
Run test cases
2626

27-
- To run test cases from your 'tests' folder : "pytest --html=report.html --self-contained-html"
27+
- To run test cases from your 'tests/e2e-test' folder : "pytest --html=report.html --self-contained-html"
2828

2929
Create .env file in project root level with web app url and client credentials
3030

0 commit comments

Comments
 (0)