Skip to content

Commit f542e68

Browse files
Merge pull request #561 from microsoft/dev
refactor: Code clean up, EXP changes
2 parents d035fc1 + 23d4e64 commit f542e68

36 files changed

+1332
-830
lines changed

.github/dependabot.yml

Lines changed: 4 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ updates:
1515
patterns:
1616
- "*"
1717

18-
# 2. Python dependencies – App
18+
# 2. Python dependencies – App
1919
- package-ecosystem: "pip"
2020
directory: "/src/App"
2121
schedule:
@@ -28,22 +28,8 @@ updates:
2828
backend-deps:
2929
patterns:
3030
- "*"
31-
32-
# 3. Python dependencies – Azure Function
33-
- package-ecosystem: "pip"
34-
directory: "/src/AzureFunction"
35-
schedule:
36-
interval: "monthly"
37-
commit-message:
38-
prefix: "build"
39-
target-branch: "dependabotchanges"
40-
open-pull-requests-limit: 10
41-
groups:
42-
backend-deps:
43-
patterns:
44-
- "*"
45-
46-
# 4. Python dependencies – Fabric Scripts
31+
32+
# 3. Python dependencies – Fabric Scripts
4733
- package-ecosystem: "pip"
4834
directory: "/src/infra/scripts/fabric_scripts"
4935
schedule:
@@ -57,7 +43,7 @@ updates:
5743
patterns:
5844
- "*"
5945

60-
# 5. Python dependencies – Index Scripts
46+
# 4. Python dependencies – Index Scripts
6147
- package-ecosystem: "pip"
6248
directory: "/src/infra/scripts/index_scripts"
6349
schedule:
Lines changed: 111 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,111 @@
1+
name: Test Automation ClientAdvisor
2+
3+
on:
4+
push:
5+
branches:
6+
- main
7+
- dev
8+
9+
paths:
10+
- 'tests/e2e-test/**'
11+
schedule:
12+
- cron: '0 13 * * *' # Runs at 1 PM UTC
13+
workflow_dispatch:
14+
15+
env:
16+
url: ${{ vars.CLIENT_ADVISOR_URL }}
17+
accelerator_name: "Client Advisor"
18+
19+
jobs:
20+
test:
21+
runs-on: ubuntu-latest
22+
steps:
23+
- name: Checkout repository
24+
uses: actions/checkout@v4
25+
26+
- name: Set up Python
27+
uses: actions/setup-python@v4
28+
with:
29+
python-version: '3.13'
30+
31+
- name: Install dependencies
32+
run: |
33+
python -m pip install --upgrade pip
34+
pip install -r tests/e2e-test/requirements.txt
35+
36+
- name: Ensure browsers are installed
37+
run: python -m playwright install --with-deps chromium
38+
39+
- name: Run tests(1)
40+
id: test1
41+
run: |
42+
xvfb-run pytest --headed --html=report/report.html --self-contained-html
43+
working-directory: tests/e2e-test
44+
continue-on-error: true
45+
46+
- name: Sleep for 30 seconds
47+
if: ${{ steps.test1.outcome == 'failure' }}
48+
run: sleep 30s
49+
shell: bash
50+
51+
- name: Run tests(2)
52+
if: ${{ steps.test1.outcome == 'failure' }}
53+
id: test2
54+
run: |
55+
xvfb-run pytest --headed --html=report/report.html --self-contained-html
56+
working-directory: tests/e2e-test
57+
continue-on-error: true
58+
59+
- name: Sleep for 60 seconds
60+
if: ${{ steps.test2.outcome == 'failure' }}
61+
run: sleep 60s
62+
shell: bash
63+
64+
- name: Run tests(3)
65+
if: ${{ steps.test2.outcome == 'failure' }}
66+
id: test3
67+
run: |
68+
xvfb-run pytest --headed --html=report/report.html --self-contained-html
69+
working-directory: tests/e2e-test
70+
71+
- name: Upload test report
72+
id: upload_report
73+
uses: actions/upload-artifact@v4
74+
if: ${{ !cancelled() }}
75+
with:
76+
name: test-report
77+
path: tests/e2e-test/report/*
78+
79+
- name: Send Notification
80+
if: always()
81+
run: |
82+
RUN_URL="https://github.com/${{ github.repository }}/actions/runs/${{ github.run_id }}"
83+
REPORT_URL=${{ steps.upload_report.outputs.artifact-url }}
84+
IS_SUCCESS=${{ steps.test1.outcome == 'success' || steps.test2.outcome == 'success' || steps.test3.outcome == 'success' }}
85+
# Construct the email body
86+
if [ "$IS_SUCCESS" = "true" ]; then
87+
EMAIL_BODY=$(cat <<EOF
88+
{
89+
"body": "<p>Dear Team,</p><p>We would like to inform you that the ${{ env.accelerator_name }} Test Automation process has completed successfully.</p><p><strong>Run URL:</strong> <a href=\"${RUN_URL}\">${RUN_URL}</a>
90+
</p><p><strong>Test Report:</strong> <a href=\"${REPORT_URL}\">${REPORT_URL}</a></p><p>Best regards,
91+
Your Automation Team</p>",
92+
"subject": "${{ env.accelerator_name }} Test Automation - Success"
93+
}
94+
EOF
95+
)
96+
else
97+
EMAIL_BODY=$(cat <<EOF
98+
{
99+
"body": "<p>Dear Team,</p><p>We would like to inform you that the ${{ env.accelerator_name }} Test Automation process has encountered an issue and has failed to complete successfully.</p><p><strong>Run URL:</strong> <a href=\"${RUN_URL}\">${RUN_URL}</a>
100+
${OUTPUT}</p><p><strong>Test Report:</strong> <a href=\"${REPORT_URL}\">${REPORT_URL}</a></p><p>Please investigate the matter at your earliest convenience.</p><p>Best regards,
101+
Your Automation Team</p>",
102+
"subject": "${{ env.accelerator_name }} Test Automation - Failure"
103+
}
104+
EOF
105+
)
106+
fi
107+
108+
# Send the notification
109+
curl -X POST "${{ secrets.EMAILNOTIFICATION_LOGICAPP_URL_TA}}" \
110+
-H "Content-Type: application/json" \
111+
-d "$EMAIL_BODY" || echo "Failed to send notification"

docs/CustomizingAzdParameters.md

Lines changed: 27 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -3,41 +3,35 @@
33
By default this template will use the environment name as the prefix to prevent naming collisions within Azure. The parameters below show the default values. You only need to run the statements below if you need to change the values.
44

55

6-
> To override any of the parameters, run `azd env set <key> <value>` before running `azd up`. On the first azd command, it will prompt you for the environment name. Be sure to choose 3-20 characters alphanumeric unique name.
6+
> To override any of the parameters, run `azd env set <PARAMETER_NAME> <VALUE>` before running `azd up`. On the first azd command, it will prompt you for the environment name. Be sure to choose 3-20 charaters alphanumeric unique name.
7+
8+
## Parameters
9+
10+
| Name | Type | Default Value | Purpose |
11+
| -----------------------------| ------- | ------------------- | ---------------------------------------------------------------------------------------------------- |
12+
| `AZURE_ENV_NAME` | string | `azdtemp` | Used as a prefix for all resource names to ensure uniqueness across environments. |
13+
| `AZURE_ENV_COSMOS_LOCATION` | string | `eastus2` | Location of the Cosmos DB instance. Choose from (allowed values: `swedencentral`, `australiaeast`). |
14+
| `AZURE_ENV_MODEL_DEPLOYMENT_TYPE` | string | `GlobalStandard` | Change the Model Deployment Type (allowed values: Standard, GlobalStandard). |
15+
| `AZURE_ENV_MODEL_NAME` | string | `gpt-4o-mini` | Set the GPT model name (allowed values: `gpt-4o`). |
16+
| `AZURE_ENV_MODEL_VERSION` | string | `2025-01-01-preview` | Set the Azure OpenAI API version (allowed values: 2024-08-06). |
17+
| `AZURE_ENV_MODEL_CAPACITY` | integer | `30` | Set the model capacity for GPT deployment. Choose based on your Azure quota and usage needs. |
18+
| `AZURE_ENV_EMBEDDING_MODEL_NAME` | string | `text-embedding-ada-002` | Set the model name used for embeddings. |
19+
| `AZURE_ENV_EMBEDDING_MODEL_CAPACITY` | integer | `80` | Set the capacity for embedding model deployment. |
20+
| `AZURE_ENV_IMAGETAG` | string | `latest` | Set the image tag (allowed values: `latest`, `dev`, `hotfix`). |
21+
| `AZURE_ENV_OPENAI_LOCATION` | string | `eastus2` | Location of the Azure OpenAI resource. Choose from (allowed values: `swedencentral`, `australiaeast`). |
22+
| `AZURE_LOCATION` | string | `japaneast` | Sets the Azure region for resource deployment. |
23+
| `AZURE_ENV_LOG_ANALYTICS_WORKSPACE_ID` | string | `<Existing Workspace Id>` | Reuses an existing Log Analytics Workspace instead of provisioning a new one. |
24+
25+
## How to Set a Parameter
26+
To customize any of the above values, run the following command **before** `azd up`:
27+
28+
```bash
29+
azd env set <PARAMETER_NAME> <VALUE>
730

8-
9-
Change the Secondary Location (example: eastus2, westus2, etc.)
10-
11-
```shell
12-
azd env set AZURE_ENV_SECONDARY_LOCATION eastus2
13-
```
14-
15-
Change the Model Deployment Type (allowed values: Standard, GlobalStandard)
16-
17-
```shell
18-
azd env set AZURE_ENV_MODEL_DEPLOYMENT_TYPE Standard
19-
```
20-
21-
Set the Model Name (allowed values: gpt-4, gpt-4o)
22-
23-
```shell
24-
azd env set AZURE_ENV_MODEL_NAME gpt-4o
25-
```
26-
27-
Change the Model Capacity (choose a number based on available GPT model capacity in your subscription)
28-
29-
```shell
30-
azd env set AZURE_ENV_MODEL_CAPACITY 30
31-
```
32-
33-
Change the Embedding Model
34-
35-
```shell
36-
azd env set AZURE_ENV_EMBEDDING_MODEL_NAME text-embedding-ada-002
3731
```
3832

39-
Change the Embedding Deployment Capacity (choose a number based on available embedding model capacity in your subscription)
33+
**Example:**
4034

41-
```shell
42-
azd env set AZURE_ENV_EMBEDDING_MODEL_CAPACITY 80
35+
```bash
36+
azd env set AZURE_LOCATION westus2
4337
```

docs/DeploymentGuide.md

Lines changed: 18 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -104,16 +104,24 @@ Consider the following settings during your deployment to modify specific settin
104104

105105
When you start the deployment, most parameters will have **default values**, but you can update the below settings by following the steps [here](CustomizingAzdParameters.md):
106106

107-
| **Setting** | **Description** | **Default value** |
108-
|------------|----------------| ------------|
109-
| **Azure OpenAI Location** | The region where OpenAI deploys | eastus2 |
110-
| **Environment Name** | A **3-20 character alphanumeric value** used to generate a unique ID to prefix the resources. | byocatemplate |
111-
| **Cosmos Location** | A **less busy** region for **CosmosDB**, useful in case of availability constraints. | eastus2 |
112-
| **Deployment Type** | Select from a drop-down list. | Global Standard |
113-
| **GPT Model** | OpenAI GPT model | gpt-4o-mini |
114-
| **GPT Model Deployment Capacity** | Configure capacity for **GPT models**. | 30k |
115-
| **Embedding Model** | OpenAI embedding model | text-embedding-ada-002 |
116-
| **Embedding Model Capacity** | Set the capacity for **embedding models**. | 80k |
107+
108+
| **Setting** | **Description** | **Default value** |
109+
| ------------------------------------ | -------------------------------------------------------------------------------------------------- | ------------------------ |
110+
| **Azure OpenAI Location** | The region where Azure OpenAI deploys. Choose from `swedencentral`, `australiaeast`, etc. | `eastus2` |
111+
| **Environment Name** | A **3-20 character alphanumeric value** used to generate a unique ID to prefix the resources. | `azdtemp` |
112+
| **Cosmos Location** | A **less busy** region for **CosmosDB**, useful in case of availability constraints. | `eastus2` |
113+
| **Deployment Type** | Select from a drop-down list (`Standard`, `GlobalStandard`). | `GlobalStandard` |
114+
| **GPT Model** | Azure OpenAI GPT model to deploy. | `gpt-4o-mini` |
115+
| **GPT Model Deployment Capacity** | Configure capacity for **GPT models**. Choose based on Azure OpenAI quota. | `30` |
116+
| **Embedding Model** | OpenAI embedding model used for vector similarity. | `text-embedding-ada-002` |
117+
| **Embedding Model Capacity** | Set the capacity for **embedding models**. Choose based on usage and quota. | `80` |
118+
| **Image Tag** | The version of the Docker image to use (e.g., `latest`, `dev`, `hotfix`). | `latest` |
119+
| **Azure OpenAI API Version** | Set the API version for OpenAI model deployments. | `2025-01-01-preview` |
120+
| **AZURE\_LOCATION** | Sets the Azure region for resource deployment. | `japaneast` |
121+
| **Existing Log Analytics Workspace** | To reuse an existing Log Analytics Workspace ID instead of creating a new one. | *(empty)* |
122+
123+
124+
117125

118126
</details>
119127

docs/FabricDeployment.md

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,8 @@
11
## Fabric Deployment
2-
## Step 1: Create Fabric workspace
2+
## Step 1: Create or Use an Existing Microsoft Fabric Workspace
3+
4+
ℹ️ Note: If you already have an existing Microsoft Fabric Workspace, you can **skip this step** and proceed to Step 2. To retrieve an existing Workspace ID, check **Point 5 below**.
5+
36
1. Navigate to ([Fabric Workspace](https://app.fabric.microsoft.com/))
47
2. Click on Workspaces from left Navigation
58
3. Click on + New Workspace
@@ -19,7 +22,7 @@
1922
- ```cd ./Build-your-own-copilot-Solution-Accelerator/infra/scripts/fabric_scripts```
2023
- ```sh ./run_fabric_items_scripts.sh keyvault_param workspaceid_param solutionprefix_param```
2124
1. keyvault_param - the name of the keyvault that was created in Step 1
22-
2. workspaceid_param - the workspaceid created in Step 2
25+
2. workspaceid_param - Existing Workspaceid or workspaceid created in Step 2
2326
3. solutionprefix_param - prefix used to append to lakehouse upon creation
2427
4. Get Fabric Lakehouse connection details:
2528
5. Once deployment is complete, navigate to Fabric Workspace

docs/LocalSetupAndDeploy.md

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -40,9 +40,11 @@ Follow these steps to deploy the application to Azure App Service:
4040
If this is your first time deploying the app, use the `az webapp up` command. Run the following commands from the `App` folder, replacing the placeholders with your desired values:
4141

4242
```sh
43-
az webapp up --runtime PYTHON:3.11 --sku B1 --name <new-app-name> --resource-group <resource-group-name> --location <azure-region> --subscription <subscription-name>
43+
az webapp up --runtime PYTHON:3.11 --sku B1 --name <new-app-name> --resource-group <resource-group-name> --location <azure-region> --subscription <subscription-id>
4444

45-
az webapp config set --startup-file "python3 -m gunicorn app:app" --name <new-app-name> --resource-group <resource-group-name>
45+
az webapp config set --startup-file "python3 -m uvicorn app:app --host 0.0.0.0 --port 8000" --name <new-app-name> --resource-group <resource-group-name>
46+
47+
az webapp config appsettings set --resource-group <resource-group-name> --name <new-app-name> --settings WEBSITES_PORT=8000
4648
```
4749

4850
Next, configure the required environment variables in the deployed app to ensure it functions correctly.
@@ -83,7 +85,7 @@ az webapp up \
8385
--resource-group <resource-group-name>
8486

8587
az webapp config set \
86-
--startup-file "python3 -m gunicorn app:app" \
88+
--startup-file "python3 -m uvicorn app:app --host 0.0.0.0 --port 8000" \
8789
--name <existing-app-name> --resource-group <resource-group-name>
8890
```
8991

infra/deploy_ai_foundry.bicep

Lines changed: 19 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ param gptDeploymentCapacity int
99
param embeddingModel string
1010
param embeddingDeploymentCapacity int
1111
param managedIdentityObjectId string
12+
param existingLogAnalyticsWorkspaceId string = ''
1213

1314
// Load the abbrevations file required to name the azure resources.
1415
var abbrs = loadJsonContent('./abbreviations.json')
@@ -54,7 +55,17 @@ resource keyVault 'Microsoft.KeyVault/vaults@2022-07-01' existing = {
5455
name: keyVaultName
5556
}
5657

57-
resource logAnalytics 'Microsoft.OperationalInsights/workspaces@2023-09-01' = {
58+
var useExisting = !empty(existingLogAnalyticsWorkspaceId)
59+
var existingLawSubscription = useExisting ? split(existingLogAnalyticsWorkspaceId, '/')[2] : ''
60+
var existingLawResourceGroup = useExisting ? split(existingLogAnalyticsWorkspaceId, '/')[4] : ''
61+
var existingLawName = useExisting ? split(existingLogAnalyticsWorkspaceId, '/')[8] : ''
62+
63+
resource existingLogAnalyticsWorkspace 'Microsoft.OperationalInsights/workspaces@2023-09-01' existing = if (useExisting) {
64+
name: existingLawName
65+
scope: resourceGroup(existingLawSubscription, existingLawResourceGroup)
66+
}
67+
68+
resource logAnalytics 'Microsoft.OperationalInsights/workspaces@2023-09-01' = if (!useExisting) {
5869
name: workspaceName
5970
location: location
6071
tags: {}
@@ -93,7 +104,7 @@ resource applicationInsights 'Microsoft.Insights/components@2020-02-02' = {
93104
Application_Type: 'web'
94105
publicNetworkAccessForIngestion: 'Enabled'
95106
publicNetworkAccessForQuery: 'Enabled'
96-
WorkspaceResourceId: logAnalytics.id
107+
WorkspaceResourceId: useExisting ? existingLogAnalyticsWorkspace.id : logAnalytics.id
97108
}
98109
}
99110

@@ -490,5 +501,10 @@ output aiSearchService string = aiSearch.name
490501
output aiProjectName string = aiHubProject.name
491502

492503
output applicationInsightsId string = applicationInsights.id
493-
output logAnalyticsWorkspaceResourceName string = logAnalytics.name
504+
output logAnalyticsWorkspaceResourceName string = useExisting ? existingLogAnalyticsWorkspace.name : logAnalytics.name
505+
output logAnalyticsWorkspaceResourceGroup string = useExisting ? existingLawResourceGroup : resourceGroup().name
506+
507+
494508
output storageAccountName string = storageNameCleaned
509+
output applicationInsightsConnectionString string = applicationInsights.properties.ConnectionString
510+

0 commit comments

Comments
 (0)