Skip to content

Commit d0ecf04

Browse files
Merge pull request #179 from microsoft/dev
fix: merging dev changes to main
2 parents 6bb40ce + 664c285 commit d0ecf04

25 files changed

+822
-69
lines changed
Lines changed: 133 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,133 @@
1+
name: Test Automation Content Processing
2+
3+
on:
4+
push:
5+
branches:
6+
- main
7+
- dev
8+
paths:
9+
- 'tests/e2e-test/**'
10+
schedule:
11+
- cron: '0 13 * * *' # Runs at 1 PM UTC
12+
workflow_dispatch:
13+
14+
env:
15+
url: ${{ vars.CP_WEB_URL }}
16+
accelerator_name: "Content Processing"
17+
18+
jobs:
19+
test:
20+
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.12'
30+
31+
- name: Azure CLI Login
32+
uses: azure/login@v2
33+
with:
34+
creds: '{"clientId":"${{ secrets.AZURE_MAINTENANCE_CLIENT_ID }}","clientSecret":"${{ secrets.AZURE_MAINTENANCE_CLIENT_SECRET }}","subscriptionId":"${{ secrets.AZURE_MAINTENANCE_SUBSCRIPTION_ID }}","tenantId":"${{ secrets.AZURE_TENANT_ID }}"}'
35+
36+
- name: Start Container App
37+
id: start-container-app
38+
uses: azure/cli@v2
39+
with:
40+
azcliversion: 'latest'
41+
inlineScript: |
42+
az rest -m post -u "/subscriptions/${{ secrets.AZURE_MAINTENANCE_SUBSCRIPTION_ID }}/resourceGroups/${{ vars.CP_RG }}/providers/Microsoft.App/containerApps/${{ vars.CP_CONTAINERAPP_PREFIX }}-app/start?api-version=2025-01-01"
43+
az rest -m post -u "/subscriptions/${{ secrets.AZURE_MAINTENANCE_SUBSCRIPTION_ID }}/resourceGroups/${{ vars.CP_RG }}/providers/Microsoft.App/containerApps/${{ vars.CP_CONTAINERAPP_PREFIX }}-api/start?api-version=2025-01-01"
44+
az rest -m post -u "/subscriptions/${{ secrets.AZURE_MAINTENANCE_SUBSCRIPTION_ID }}/resourceGroups/${{ vars.CP_RG }}/providers/Microsoft.App/containerApps/${{ vars.CP_CONTAINERAPP_PREFIX }}-web/start?api-version=2025-01-01"
45+
46+
- name: Install dependencies
47+
run: |
48+
python -m pip install --upgrade pip
49+
pip install -r tests/e2e-test/requirements.txt
50+
51+
- name: Ensure browsers are installed
52+
run: python -m playwright install --with-deps chromium
53+
54+
- name: Run tests(1)
55+
id: test1
56+
run: |
57+
xvfb-run pytest --headed --html=report/report.html --self-contained-html
58+
working-directory: tests/e2e-test
59+
continue-on-error: true
60+
61+
- name: Sleep for 30 seconds
62+
if: ${{ steps.test1.outcome == 'failure' }}
63+
run: sleep 30s
64+
shell: bash
65+
66+
- name: Run tests(2)
67+
id: test2
68+
if: ${{ steps.test1.outcome == 'failure' }}
69+
run: |
70+
xvfb-run pytest --headed --html=report/report.html --self-contained-html
71+
working-directory: tests/e2e-test
72+
continue-on-error: true
73+
74+
- name: Sleep for 60 seconds
75+
if: ${{ steps.test2.outcome == 'failure' }}
76+
run: sleep 60s
77+
shell: bash
78+
79+
- name: Run tests(3)
80+
id: test3
81+
if: ${{ steps.test2.outcome == 'failure' }}
82+
run: |
83+
xvfb-run pytest --headed --html=report/report.html --self-contained-html
84+
working-directory: tests/e2e-test
85+
86+
- name: Upload test report
87+
id: upload_report
88+
uses: actions/upload-artifact@v4
89+
if: ${{ !cancelled() }}
90+
with:
91+
name: test-report
92+
path: tests/e2e-test/report/*
93+
94+
- name: Send Notification
95+
if: always()
96+
run: |
97+
RUN_URL="https://github.com/${{ github.repository }}/actions/runs/${{ github.run_id }}"
98+
REPORT_URL=${{ steps.upload_report.outputs.artifact-url }}
99+
IS_SUCCESS=${{ steps.test1.outcome == 'success' || steps.test2.outcome == 'success' || steps.test3.outcome == 'success' }}
100+
# Construct the email body
101+
if [ "$IS_SUCCESS" = "true" ]; then
102+
EMAIL_BODY=$(cat <<EOF
103+
{
104+
"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><br></p><p><strong>Test Report:</strong> <a href=\"${REPORT_URL}\">${REPORT_URL}</a></p><p>Best regards,<br>Your Automation Team</p>",
105+
"subject": "${{ env.accelerator_name }} Test Automation - Success"
106+
}
107+
EOF
108+
)
109+
else
110+
EMAIL_BODY=$(cat <<EOF
111+
{
112+
"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><br> ${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,<br>Your Automation Team</p>",
113+
"subject": "${{ env.accelerator_name }} Test Automation - Failure"
114+
}
115+
EOF
116+
)
117+
fi
118+
119+
# Send the notification
120+
curl -X POST "${{ secrets.EMAILNOTIFICATION_LOGICAPP_URL_TA }}" \
121+
-H "Content-Type: application/json" \
122+
-d "$EMAIL_BODY" || echo "Failed to send notification"
123+
124+
- name: Stop Container App
125+
if: always()
126+
uses: azure/cli@v2
127+
with:
128+
azcliversion: 'latest'
129+
inlineScript: |
130+
az rest -m post -u "/subscriptions/${{ secrets.AZURE_MAINTENANCE_SUBSCRIPTION_ID }}/resourceGroups/${{ vars.CP_RG }}/providers/Microsoft.App/containerApps/${{ vars.CP_CONTAINERAPP_PREFIX }}-app/stop?api-version=2025-01-01"
131+
az rest -m post -u "/subscriptions/${{ secrets.AZURE_MAINTENANCE_SUBSCRIPTION_ID }}/resourceGroups/${{ vars.CP_RG }}/providers/Microsoft.App/containerApps/${{ vars.CP_CONTAINERAPP_PREFIX }}-api/stop?api-version=2025-01-01"
132+
az rest -m post -u "/subscriptions/${{ secrets.AZURE_MAINTENANCE_SUBSCRIPTION_ID }}/resourceGroups/${{ vars.CP_RG }}/providers/Microsoft.App/containerApps/${{ vars.CP_CONTAINERAPP_PREFIX }}-web/stop?api-version=2025-01-01"
133+
az logout

azure.yaml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,10 +11,10 @@ hooks:
1111
preprovision:
1212
posix:
1313
shell: sh
14-
run: timestamp=$(date +"%Y%m%d-%H%M%S"); logFile="azd_preprovision_$timestamp.log"; sed -i 's/\r$//' ./infra/scripts/docker-build.sh; ./infra/scripts/docker-build.sh "$AZURE_SUBSCRIPTION_ID" "$AZURE_ENV_NAME" "$AZURE_LOCATION" "$AZURE_RESOURCE_GROUP" "$USE_LOCAL_BUILD" 2>&1 | tee "$logFile"
14+
run: timestamp=$(date +"%Y%m%d-%H%M%S"); logFile="azd_preprovision_$timestamp.log"; sed -i 's/\r$//' ./infra/scripts/docker-build.sh; ./infra/scripts/docker-build.sh "$AZURE_SUBSCRIPTION_ID" "$AZURE_ENV_NAME" "$AZURE_LOCATION" "$AZURE_RESOURCE_GROUP" "$USE_LOCAL_BUILD" "$AZURE_ENV_IMAGETAG" 2>&1 | tee "$logFile"
1515
windows:
1616
shell: pwsh
17-
run: $timestamp = Get-Date -Format "yyyyMMdd-HHmmss"; $logFile = "azd_preprovision_$timestamp.log"; ./infra/scripts/docker-build.ps1 $env:AZURE_SUBSCRIPTION_ID $env:AZURE_ENV_NAME $env:AZURE_LOCATION $env:AZURE_RESOURCE_GROUP $env:USE_LOCAL_BUILD *>&1 | Tee-Object -FilePath $logFile
17+
run: $timestamp = Get-Date -Format "yyyyMMdd-HHmmss"; $logFile = "azd_preprovision_$timestamp.log"; ./infra/scripts/docker-build.ps1 $env:AZURE_SUBSCRIPTION_ID $env:AZURE_ENV_NAME $env:AZURE_LOCATION $env:AZURE_RESOURCE_GROUP $env:USE_LOCAL_BUILD $env:AZURE_ENV_IMAGETAG *>&1 | Tee-Object -FilePath $logFile
1818
postprovision:
1919
posix:
2020
shell: sh

docs/CustomizingAzdParameters.md

Lines changed: 21 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -3,40 +3,34 @@
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 charaters 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 characters alphanumeric unique name.
77
8+
## Parameters
89

9-
Set the Environment Name Prefix
10-
```shell
11-
azd env set AZURE_ENV_NAME 'cps'
12-
```
10+
| Name | Type | Example Value | Purpose |
11+
| -------------------------------------- | ------- | --------------------------- | ------------------------------------------------------------------------------------- |
12+
| `AZURE_ENV_NAME` | string | `cps` | Sets the environment name prefix for all Azure resources. |
13+
| `AZURE_ENV_SECONDARY_LOCATION` | string | `eastus2` | Specifies a secondary Azure region. |
14+
| `AZURE_ENV_CU_LOCATION` | string | `WestUS` | Sets the location for the Azure Content Understanding service. |
15+
| `AZURE_ENV_MODEL_DEPLOYMENT_TYPE` | string | `GlobalStandard` | Defines the model deployment type (allowed values: `Standard`, `GlobalStandard`). |
16+
| `AZURE_ENV_MODEL_NAME` | string | `gpt-4o` | Specifies the GPT model name (allowed values: `gpt-4o`).
17+
| `AZURE_ENV_MODEL_VERSION` | string | `2024-08-06` | Specifies the GPT model version (allowed values: `2024-08-06`). |
18+
| `AZURE_ENV_MODEL_CAPACITY` | integer | `30` | Sets the model capacity (choose based on your subscription's available GPT capacity). |
19+
| `USE_LOCAL_BUILD` | boolean | `false` | Indicates whether to use a local container build for deployment. |
20+
| `AZURE_ENV_IMAGETAG` | boolean | `latest` | Set the Image tag Like (allowed values: latest, dev, hotfix) |
21+
| `AZURE_ENV_LOG_ANALYTICS_WORKSPACE_ID` | string | `<Existing Workspace Id>` | Reuses an existing Log Analytics Workspace instead of provisioning a new one. |
1322

14-
Change the Azure Content Understanding Service Location (example: eastus2, westus2, etc.)
15-
```shell
16-
azd env set AZURE_ENV_CU_LOCATION 'West US'
17-
```
1823

19-
Change the Deployment Type (allowed values: Standard, GlobalStandard)
20-
```shell
21-
azd env set AZURE_ENV_MODEL_DEPLOYMENT_TYPE 'GlobalStandard'
22-
```
24+
## How to Set a Parameter
2325

24-
Set the Model Name (allowed values: gpt-4o)
25-
```shell
26-
azd env set AZURE_ENV_MODEL_NAME 'gpt-4o'
27-
```
26+
To customize any of the above values, run the following command **before** `azd up`:
2827

29-
Change the Model Capacity (choose a number based on available GPT model capacity in your subscription)
30-
```shell
31-
azd env set AZURE_ENV_MODEL_CAPACITY '30'
28+
```bash
29+
azd env set <PARAMETER_NAME> <VALUE>
3230
```
3331

34-
Change if the deployment should use a local build of the containers
35-
```shell
36-
azd env set USE_LOCAL_BUILD 'false'
37-
```
32+
**Example:**
3833

39-
Set the Log Analytics Workspace Id if you need to reuse the existing workspace
40-
```shell
41-
azd env set AZURE_ENV_LOG_ANALYTICS_WORKSPACE_ID '/subscriptions/<subscription-id>/resourceGroups/<resource-group>/providers/Microsoft.OperationalInsights/workspaces/<existing-workspace-name>'
34+
```bash
35+
azd env set AZURE_LOCATION westus2
4236
```

docs/DeploymentGuide.md

Lines changed: 14 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,7 @@ This will allow the scripts to run for the current session without permanently c
3636

3737
<br/>
3838

39+
3940
## Deployment Options & Steps
4041

4142
Pick from the options below to see step-by-step instructions for GitHub Codespaces, VS Code Dev Containers, and Local Environments.
@@ -111,15 +112,19 @@ Consider the following settings during your deployment to modify specific settin
111112

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

114-
| **Setting** | **Description** | **Default value** |
115-
|-------------|-----------------|-------------------|
116-
| **Azure Region** | The region where resources will be created. | East US |
117-
| **Azure AI Content Understanding Location** | Select from a drop-down list of values. | Sweden Central |
118-
| **Secondary Location** | A **less busy** region for **Azure Cosmos DB**, useful in case of availability constraints. | eastus2 |
119-
| **Deployment Type** | Select from a drop-down list. | GlobalStandard |
120-
| **GPT Model** | Choose from **gpt-4o**. | gpt-4o |
121-
| **GPT Model Deployment Capacity** | Configure capacity for **GPT models**. | 30k |
122-
| **Existing Log analytics workspace** | To reuse the existing Log analytics workspace Id. | |
115+
| **Setting** | **Description** | **Default Value** |
116+
| ------------------------------------------- | ------------------------------------------------------------------------------------------- | ----------------- |
117+
| **Azure Region** | The region where resources will be created. | East US |
118+
| **Azure AI Content Understanding Location** | Location for the **Content Understanding** service. | Sweden Central |
119+
| **Secondary Location** | A **less busy** region for **Azure Cosmos DB**, useful in case of availability constraints. | eastus2 |
120+
| **Deployment Type** | Select from a drop-down list. | GlobalStandard |
121+
| **GPT Model** | Choose from **gpt-4o**. | gpt-4o |
122+
| **GPT Model Version** | GPT model version used in the deployment. | 2024-08-06 |
123+
| **GPT Model Deployment Capacity** | Configure capacity for **GPT models**. | 30k |
124+
| **Use Local Build** | Boolean flag to determine if local container builds should be used. | false |
125+
| **Image Tag** | Image version for deployment (allowed values: `latest`, `dev`, `hotfix`). | latest |
126+
| **Existing Log Analytics Workspace** | To reuse an existing Log Analytics Workspace ID instead of creating a new one. | *(none)* |
127+
123128

124129
</details>
125130

infra/container_app/deploy_container_app_api_web.bicep

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@ param maxReplicaContainerWeb int = 1
2626
param azureContainerRegistry string
2727
param containerRegistryReaderId string
2828
param useLocalBuild string = 'false'
29+
param imageTag string
2930

3031
var abbrs = loadJsonContent('../abbreviations.json')
3132

@@ -76,7 +77,7 @@ module containerApp 'deploy_container_app.bicep' = {
7677
containerEnvId: containerAppEnvId
7778
azureContainerRegistry: azureContainerRegistry
7879
azureContainerRegistryImage: 'contentprocessor'
79-
azureContainerRegistryImageTag: 'latest'
80+
azureContainerRegistryImageTag: imageTag
8081
managedIdentityId: containerRegistryReaderId
8182
containerEnvVars: [
8283
{
@@ -99,7 +100,7 @@ module containerAppApi 'deploy_container_app.bicep' = {
99100
containerEnvId: containerAppEnvId
100101
azureContainerRegistry: azureContainerRegistry
101102
azureContainerRegistryImage: 'contentprocessorapi'
102-
azureContainerRegistryImageTag: 'latest'
103+
azureContainerRegistryImageTag: imageTag
103104
managedIdentityId: containerRegistryReaderId
104105
allowedOrigins: [containerAppWebEndpoint]
105106
containerEnvVars: [
@@ -123,7 +124,7 @@ module containerAppWeb 'deploy_container_app.bicep' = {
123124
containerEnvId: containerAppEnvId
124125
azureContainerRegistry: azureContainerRegistry
125126
azureContainerRegistryImage: 'contentprocessorweb'
126-
azureContainerRegistryImageTag: 'latest'
127+
azureContainerRegistryImageTag: imageTag
127128
managedIdentityId: containerRegistryReaderId
128129
containerEnvVars: [
129130
{

infra/main.bicep

Lines changed: 4 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -30,20 +30,10 @@ param contentUnderstandingLocation string
3030
])
3131
param deploymentType string = 'GlobalStandard'
3232

33-
@minLength(1)
3433
@description('Name of the GPT model to deploy:')
35-
@allowed([
36-
'gpt-4o-mini'
37-
'gpt-4o'
38-
'gpt-4'
39-
])
4034
param gptModelName string = 'gpt-4o'
4135

42-
@minLength(1)
4336
@description('Version of the GPT model to deploy:')
44-
@allowed([
45-
'2024-08-06'
46-
])
4737
param gptModelVersion string = '2024-08-06'
4838

4939
//var gptModelVersion = '2024-02-15-preview'
@@ -78,6 +68,8 @@ param useLocalBuild string = 'false'
7868
@description('Optional: Existing Log Analytics Workspace Resource ID')
7969
param existingLogAnalyticsWorkspaceId string = ''
8070

71+
param imageTag string = 'latest'
72+
8173
var containerImageEndPoint = 'cpscontainerreg.azurecr.io'
8274
var resourceGroupLocation = resourceGroup().location
8375

@@ -186,6 +178,7 @@ module containerApps './container_app/deploy_container_app_api_web.bicep' = {
186178
minReplicaContainerWeb: minReplicaContainerWeb
187179
maxReplicaContainerWeb: maxReplicaContainerWeb
188180
useLocalBuild: 'false'
181+
imageTag: 'latest'
189182
}
190183
}
191184

@@ -254,6 +247,7 @@ module updateContainerApp './container_app/deploy_container_app_api_web.bicep' =
254247
minReplicaContainerWeb: minReplicaContainerWeb
255248
maxReplicaContainerWeb: maxReplicaContainerWeb
256249
useLocalBuild: useLocalBuildLower
250+
imageTag: imageTag
257251
}
258252
dependsOn: [roleAssignments]
259253
}

infra/main.bicepparam

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,12 @@
11
using './main.bicep'
22

33
param environmentName = readEnvironmentVariable('AZURE_ENV_NAME', 'cps')
4+
param secondaryLocation = readEnvironmentVariable('AZURE_ENV_SECONDARY_LOCATION', 'EastUs2')
45
param contentUnderstandingLocation = readEnvironmentVariable('AZURE_ENV_CU_LOCATION', 'WestUS')
56
param deploymentType = readEnvironmentVariable('AZURE_ENV_MODEL_DEPLOYMENT_TYPE', 'GlobalStandard')
67
param gptModelName = readEnvironmentVariable('AZURE_ENV_MODEL_NAME', 'gpt-4o')
8+
param gptModelVersion = readEnvironmentVariable('AZURE_ENV_MODEL_VERSION', '2024-08-06')
79
param gptDeploymentCapacity = int(readEnvironmentVariable('AZURE_ENV_MODEL_CAPACITY', '30'))
810
param useLocalBuild = readEnvironmentVariable('USE_LOCAL_BUILD', 'false')
11+
param imageTag = readEnvironmentVariable('AZURE_ENV_IMAGETAG', 'latest')
912
param existingLogAnalyticsWorkspaceId = readEnvironmentVariable('AZURE_ENV_LOG_ANALYTICS_WORKSPACE_ID', '')

infra/main.json

Lines changed: 1 addition & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
"_generator": {
66
"name": "bicep",
77
"version": "0.35.1.17967",
8-
"templateHash": "12841296004328754819"
8+
"templateHash": "15234454470886032390"
99
}
1010
},
1111
"parameters": {
@@ -54,23 +54,13 @@
5454
"gptModelName": {
5555
"type": "string",
5656
"defaultValue": "gpt-4o",
57-
"allowedValues": [
58-
"gpt-4o-mini",
59-
"gpt-4o",
60-
"gpt-4"
61-
],
62-
"minLength": 1,
6357
"metadata": {
6458
"description": "Name of the GPT model to deploy:"
6559
}
6660
},
6761
"gptModelVersion": {
6862
"type": "string",
6963
"defaultValue": "2024-08-06",
70-
"allowedValues": [
71-
"2024-08-06"
72-
],
73-
"minLength": 1,
7464
"metadata": {
7565
"description": "Version of the GPT model to deploy:"
7666
}

0 commit comments

Comments
 (0)