Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
19 commits
Select commit Hold shift + click to select a range
242709f
parameterized for model version
AjitPadhi-Microsoft May 30, 2025
be512bc
Merge remote-tracking branch 'origin/main' into PSL-US-18442
AjitPadhi-Microsoft May 30, 2025
af56152
merged with main
AjitPadhi-Microsoft May 30, 2025
fb84df0
Merge pull request #147 from microsoft/PSL-US-18442
Roopan-Microsoft Jun 3, 2025
96138c6
added e2e test automation scripts and pipeline
Harsh-Microsoft Jun 4, 2025
7de4590
fix: update Azure CLI credentials for maintenance subscription in tes…
Harsh-Microsoft Jun 4, 2025
3470eb5
fix: update Azure CLI commands to use variable references for resourc…
Harsh-Microsoft Jun 4, 2025
25881c8
US:18810-Standardize Bicep Parameters for Content Processing
VishalS-Microsoft Jun 4, 2025
81ff327
added CustomizingAzdParameters.md file link in DeploymentGuid.md file
VishalS-Microsoft Jun 4, 2025
2718c97
fix: restore paths configuration for e2e tests in test automation wor…
Harsh-Microsoft Jun 4, 2025
00d289d
Merge pull request #177 from microsoft/psl-us18810-cps
Roopan-Microsoft Jun 4, 2025
a0d9cd1
test: Migrate test automation scripts and pipeline for content proces…
Avijit-Microsoft Jun 4, 2025
fad756e
image tage changes
VishalS-Microsoft Jun 5, 2025
ff29f76
Merge branch 'main' into dev
AjitPadhi-Microsoft Jun 6, 2025
a375147
image tag changes
VishalS-Microsoft Jun 6, 2025
bd3776b
Merge branch 'dev' into psl-imagetag-changes
VishalS-Microsoft Jun 6, 2025
7584597
resolved comments
VishalS-Microsoft Jun 6, 2025
4c98065
Update docs/CustomizingAzdParameters.md
Roopan-Microsoft Jun 6, 2025
664c285
Merge pull request #180 from microsoft/psl-imagetag-changes
Prajwal-Microsoft Jun 6, 2025
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
133 changes: 133 additions & 0 deletions .github/workflows/test-automation.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,133 @@
name: Test Automation Content Processing

on:
push:
branches:
- main
- dev
paths:
- 'tests/e2e-test/**'
schedule:
- cron: '0 13 * * *' # Runs at 1 PM UTC
workflow_dispatch:

env:
url: ${{ vars.CP_WEB_URL }}
accelerator_name: "Content Processing"

jobs:
test:

runs-on: ubuntu-latest
steps:
- name: Checkout repository
uses: actions/checkout@v4

- name: Set up Python
uses: actions/setup-python@v4
with:
python-version: '3.12'

- name: Azure CLI Login
uses: azure/login@v2
with:
creds: '{"clientId":"${{ secrets.AZURE_MAINTENANCE_CLIENT_ID }}","clientSecret":"${{ secrets.AZURE_MAINTENANCE_CLIENT_SECRET }}","subscriptionId":"${{ secrets.AZURE_MAINTENANCE_SUBSCRIPTION_ID }}","tenantId":"${{ secrets.AZURE_TENANT_ID }}"}'

- name: Start Container App
id: start-container-app
uses: azure/cli@v2
with:
azcliversion: 'latest'
inlineScript: |
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"
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"
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"

- name: Install dependencies
run: |
python -m pip install --upgrade pip
pip install -r tests/e2e-test/requirements.txt

- name: Ensure browsers are installed
run: python -m playwright install --with-deps chromium

- name: Run tests(1)
id: test1
run: |
xvfb-run pytest --headed --html=report/report.html --self-contained-html
working-directory: tests/e2e-test
continue-on-error: true

- name: Sleep for 30 seconds
if: ${{ steps.test1.outcome == 'failure' }}
run: sleep 30s
shell: bash

- name: Run tests(2)
id: test2
if: ${{ steps.test1.outcome == 'failure' }}
run: |
xvfb-run pytest --headed --html=report/report.html --self-contained-html
working-directory: tests/e2e-test
continue-on-error: true

- name: Sleep for 60 seconds
if: ${{ steps.test2.outcome == 'failure' }}
run: sleep 60s
shell: bash

- name: Run tests(3)
id: test3
if: ${{ steps.test2.outcome == 'failure' }}
run: |
xvfb-run pytest --headed --html=report/report.html --self-contained-html
working-directory: tests/e2e-test

- name: Upload test report
id: upload_report
uses: actions/upload-artifact@v4
if: ${{ !cancelled() }}
with:
name: test-report
path: tests/e2e-test/report/*

- name: Send Notification
if: always()
run: |
RUN_URL="https://github.com/${{ github.repository }}/actions/runs/${{ github.run_id }}"
REPORT_URL=${{ steps.upload_report.outputs.artifact-url }}
IS_SUCCESS=${{ steps.test1.outcome == 'success' || steps.test2.outcome == 'success' || steps.test3.outcome == 'success' }}
# Construct the email body
if [ "$IS_SUCCESS" = "true" ]; then
EMAIL_BODY=$(cat <<EOF
{
"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>",
"subject": "${{ env.accelerator_name }} Test Automation - Success"
}
EOF
)
else
EMAIL_BODY=$(cat <<EOF
{
"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>",
"subject": "${{ env.accelerator_name }} Test Automation - Failure"
}
EOF
)
fi

# Send the notification
curl -X POST "${{ secrets.EMAILNOTIFICATION_LOGICAPP_URL_TA }}" \
-H "Content-Type: application/json" \
-d "$EMAIL_BODY" || echo "Failed to send notification"

- name: Stop Container App
if: always()
uses: azure/cli@v2
with:
azcliversion: 'latest'
inlineScript: |
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"
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"
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"
az logout
4 changes: 2 additions & 2 deletions azure.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -11,10 +11,10 @@ hooks:
preprovision:
posix:
shell: sh
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"
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"
windows:
shell: pwsh
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
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
postprovision:
posix:
shell: sh
Expand Down
48 changes: 21 additions & 27 deletions docs/CustomizingAzdParameters.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,40 +3,34 @@
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.


> 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.
> 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.

## Parameters

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

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

Change the Deployment Type (allowed values: Standard, GlobalStandard)
```shell
azd env set AZURE_ENV_MODEL_DEPLOYMENT_TYPE 'GlobalStandard'
```
## How to Set a Parameter

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

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

Change if the deployment should use a local build of the containers
```shell
azd env set USE_LOCAL_BUILD 'false'
```
**Example:**

Set the Log Analytics Workspace Id if you need to reuse the existing workspace
```shell
azd env set AZURE_ENV_LOG_ANALYTICS_WORKSPACE_ID '/subscriptions/<subscription-id>/resourceGroups/<resource-group>/providers/Microsoft.OperationalInsights/workspaces/<existing-workspace-name>'
```bash
azd env set AZURE_LOCATION westus2
```
23 changes: 14 additions & 9 deletions docs/DeploymentGuide.md
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ This will allow the scripts to run for the current session without permanently c

<br/>


## Deployment Options & Steps

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

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):

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


</details>

Expand Down
7 changes: 4 additions & 3 deletions infra/container_app/deploy_container_app_api_web.bicep
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ param maxReplicaContainerWeb int = 1
param azureContainerRegistry string
param containerRegistryReaderId string
param useLocalBuild string = 'false'
param imageTag string

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

Expand Down Expand Up @@ -76,7 +77,7 @@ module containerApp 'deploy_container_app.bicep' = {
containerEnvId: containerAppEnvId
azureContainerRegistry: azureContainerRegistry
azureContainerRegistryImage: 'contentprocessor'
azureContainerRegistryImageTag: 'latest'
azureContainerRegistryImageTag: imageTag
managedIdentityId: containerRegistryReaderId
containerEnvVars: [
{
Expand All @@ -99,7 +100,7 @@ module containerAppApi 'deploy_container_app.bicep' = {
containerEnvId: containerAppEnvId
azureContainerRegistry: azureContainerRegistry
azureContainerRegistryImage: 'contentprocessorapi'
azureContainerRegistryImageTag: 'latest'
azureContainerRegistryImageTag: imageTag
managedIdentityId: containerRegistryReaderId
allowedOrigins: [containerAppWebEndpoint]
containerEnvVars: [
Expand All @@ -123,7 +124,7 @@ module containerAppWeb 'deploy_container_app.bicep' = {
containerEnvId: containerAppEnvId
azureContainerRegistry: azureContainerRegistry
azureContainerRegistryImage: 'contentprocessorweb'
azureContainerRegistryImageTag: 'latest'
azureContainerRegistryImageTag: imageTag
managedIdentityId: containerRegistryReaderId
containerEnvVars: [
{
Expand Down
14 changes: 4 additions & 10 deletions infra/main.bicep
Original file line number Diff line number Diff line change
Expand Up @@ -30,20 +30,10 @@ param contentUnderstandingLocation string
])
param deploymentType string = 'GlobalStandard'

@minLength(1)
@description('Name of the GPT model to deploy:')
@allowed([
'gpt-4o-mini'
'gpt-4o'
'gpt-4'
])
param gptModelName string = 'gpt-4o'

@minLength(1)
@description('Version of the GPT model to deploy:')
@allowed([
'2024-08-06'
])
param gptModelVersion string = '2024-08-06'

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

param imageTag string = 'latest'

var containerImageEndPoint = 'cpscontainerreg.azurecr.io'
var resourceGroupLocation = resourceGroup().location

Expand Down Expand Up @@ -186,6 +178,7 @@ module containerApps './container_app/deploy_container_app_api_web.bicep' = {
minReplicaContainerWeb: minReplicaContainerWeb
maxReplicaContainerWeb: maxReplicaContainerWeb
useLocalBuild: 'false'
imageTag: 'latest'
}
}

Expand Down Expand Up @@ -254,6 +247,7 @@ module updateContainerApp './container_app/deploy_container_app_api_web.bicep' =
minReplicaContainerWeb: minReplicaContainerWeb
maxReplicaContainerWeb: maxReplicaContainerWeb
useLocalBuild: useLocalBuildLower
imageTag: imageTag
}
dependsOn: [roleAssignments]
}
Expand Down
3 changes: 3 additions & 0 deletions infra/main.bicepparam
Original file line number Diff line number Diff line change
@@ -1,9 +1,12 @@
using './main.bicep'

param environmentName = readEnvironmentVariable('AZURE_ENV_NAME', 'cps')
param secondaryLocation = readEnvironmentVariable('AZURE_ENV_SECONDARY_LOCATION', 'EastUs2')
param contentUnderstandingLocation = readEnvironmentVariable('AZURE_ENV_CU_LOCATION', 'WestUS')
param deploymentType = readEnvironmentVariable('AZURE_ENV_MODEL_DEPLOYMENT_TYPE', 'GlobalStandard')
param gptModelName = readEnvironmentVariable('AZURE_ENV_MODEL_NAME', 'gpt-4o')
param gptModelVersion = readEnvironmentVariable('AZURE_ENV_MODEL_VERSION', '2024-08-06')
param gptDeploymentCapacity = int(readEnvironmentVariable('AZURE_ENV_MODEL_CAPACITY', '30'))
param useLocalBuild = readEnvironmentVariable('USE_LOCAL_BUILD', 'false')
param imageTag = readEnvironmentVariable('AZURE_ENV_IMAGETAG', 'latest')
param existingLogAnalyticsWorkspaceId = readEnvironmentVariable('AZURE_ENV_LOG_ANALYTICS_WORKSPACE_ID', '')
12 changes: 1 addition & 11 deletions infra/main.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
"_generator": {
"name": "bicep",
"version": "0.35.1.17967",
"templateHash": "12841296004328754819"
"templateHash": "15234454470886032390"
}
},
"parameters": {
Expand Down Expand Up @@ -54,23 +54,13 @@
"gptModelName": {
"type": "string",
"defaultValue": "gpt-4o",
"allowedValues": [
"gpt-4o-mini",
"gpt-4o",
"gpt-4"
],
"minLength": 1,
"metadata": {
"description": "Name of the GPT model to deploy:"
}
},
"gptModelVersion": {
"type": "string",
"defaultValue": "2024-08-06",
"allowedValues": [
"2024-08-06"
],
"minLength": 1,
"metadata": {
"description": "Version of the GPT model to deploy:"
}
Expand Down
Loading
Loading