Skip to content
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.

Commit 6abc398

Browse files
authoredJun 5, 2025··
Merge pull request #120 from microsoft/dev
feat: merging the changes from dev to main
2 parents 2aa15c0 + b6ab9fd commit 6abc398

35 files changed

+1451
-114
lines changed
 

‎.devcontainer/devcontainer.json

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,19 +3,26 @@
33
"image": "mcr.microsoft.com/devcontainers/python:3.11-bullseye",
44
"forwardPorts": [50505],
55
"features": {
6-
"ghcr.io/azure/azure-dev/azd:latest": {}
6+
"ghcr.io/azure/azure-dev/azd:latest": {},
7+
"ghcr.io/devcontainers/features/azure-cli:1": {
8+
"installBicep": true,
9+
"version": "latest",
10+
"bicepVersion": "latest"
11+
}
712
},
813
"customizations": {
914
"vscode": {
1015
"extensions": [
1116
"ms-azuretools.azure-dev",
17+
"ms-azuretools.vscode-azcli",
1218
"ms-azuretools.vscode-bicep",
1319
"ms-python.python",
1420
"ms-toolsai.jupyter",
1521
"GitHub.vscode-github-actions"
1622
]
1723
}
1824
},
25+
"postCreateCommand": "sudo chmod +x ./scripts/quota_check_params.sh",
1926
"postStartCommand": "git pull origin main && python3 -m pip install -r ./src/frontend/requirements.txt && python3 -m pip install -r ./src/backend/requirements.txt",
2027
"remoteUser": "vscode",
2128
"hostRequirements": {

‎.github/workflows/test-automation.yml

Lines changed: 131 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,131 @@
1+
name: Test Automation Code Modernization
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.CODEMOD_WEB_URL }}
16+
accelerator_name: "Code Modernization"
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.13'
30+
31+
- name: Azure CLI Login
32+
uses: azure/login@v2
33+
with:
34+
creds: '{"clientId":"${{ secrets.AZURE_CLIENT_ID }}","clientSecret":"${{ secrets.AZURE_CLIENT_SECRET }}","subscriptionId":"${{ secrets.AZURE_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_SUBSCRIPTION_ID }}/resourceGroups/${{ vars.CODEMOD_RG }}/providers/Microsoft.App/containerApps/${{ vars.CODEMOD_FRONTEND_CONTAINER_NAME }}/start?api-version=2025-01-01"
43+
az rest -m post -u "/subscriptions/${{ secrets.AZURE_SUBSCRIPTION_ID }}/resourceGroups/${{ vars.CODEMOD_RG }}/providers/Microsoft.App/containerApps/${{ vars.CODEMOD_BACKEND_CONTAINER_NAME }}/start?api-version=2025-01-01"
44+
45+
- name: Install dependencies
46+
run: |
47+
python -m pip install --upgrade pip
48+
pip install -r tests/e2e-test/requirements.txt
49+
50+
- name: Ensure browsers are installed
51+
run: python -m playwright install --with-deps chromium
52+
53+
- name: Run tests(1)
54+
id: test1
55+
run: |
56+
xvfb-run pytest --headed --html=report/report.html --self-contained-html
57+
working-directory: tests/e2e-test
58+
continue-on-error: true
59+
60+
- name: Sleep for 30 seconds
61+
if: ${{ steps.test1.outcome == 'failure' }}
62+
run: sleep 30s
63+
shell: bash
64+
65+
- name: Run tests(2)
66+
id: test2
67+
if: ${{ steps.test1.outcome == 'failure' }}
68+
run: |
69+
xvfb-run pytest --headed --html=report/report.html --self-contained-html
70+
working-directory: tests/e2e-test
71+
continue-on-error: true
72+
73+
- name: Sleep for 60 seconds
74+
if: ${{ steps.test2.outcome == 'failure' }}
75+
run: sleep 60s
76+
shell: bash
77+
78+
- name: Run tests(3)
79+
id: test3
80+
if: ${{ steps.test2.outcome == 'failure' }}
81+
run: |
82+
xvfb-run pytest --headed --html=report/report.html --self-contained-html
83+
working-directory: tests/e2e-test
84+
85+
- name: Upload test report
86+
id: upload_report
87+
uses: actions/upload-artifact@v4
88+
if: ${{ !cancelled() }}
89+
with:
90+
name: test-report
91+
path: tests/e2e-test/report/*
92+
93+
- name: Send Notification
94+
if: always()
95+
run: |
96+
RUN_URL="https://github.com/${{ github.repository }}/actions/runs/${{ github.run_id }}"
97+
REPORT_URL=${{ steps.upload_report.outputs.artifact-url }}
98+
IS_SUCCESS=${{ steps.test1.outcome == 'success' || steps.test2.outcome == 'success' || steps.test3.outcome == 'success' }}
99+
# Construct the email body
100+
if [ "$IS_SUCCESS" = "true" ]; then
101+
EMAIL_BODY=$(cat <<EOF
102+
{
103+
"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>",
104+
"subject": "${{ env.accelerator_name }} Test Automation - Success"
105+
}
106+
EOF
107+
)
108+
else
109+
EMAIL_BODY=$(cat <<EOF
110+
{
111+
"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></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>",
112+
"subject": "${{ env.accelerator_name }} Test Automation - Failure"
113+
}
114+
EOF
115+
)
116+
fi
117+
118+
# Send the notification
119+
curl -X POST "${{ secrets.EMAILNOTIFICATION_LOGICAPP_URL_TA }}" \
120+
-H "Content-Type: application/json" \
121+
-d "$EMAIL_BODY" || echo "Failed to send notification"
122+
123+
- name: Stop Container App
124+
if: always()
125+
uses: azure/cli@v2
126+
with:
127+
azcliversion: 'latest'
128+
inlineScript: |
129+
az rest -m post -u "/subscriptions/${{ secrets.AZURE_SUBSCRIPTION_ID }}/resourceGroups/${{ vars.CODEMOD_RG }}/providers/Microsoft.App/containerApps/${{ vars.CODEMOD_FRONTEND_CONTAINER_NAME }}/stop?api-version=2025-01-01"
130+
az rest -m post -u "/subscriptions/${{ secrets.AZURE_SUBSCRIPTION_ID }}/resourceGroups/${{ vars.CODEMOD_RG }}/providers/Microsoft.App/containerApps/${{ vars.CODEMOD_BACKEND_CONTAINER_NAME }}/stop?api-version=2025-01-01"
131+
az logout

‎azure.yaml

Lines changed: 22 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -5,19 +5,35 @@ name: modernize-your-code-solution-accelerator
55
metadata:
66
template: modernize-your-code-solution-accelerator@1.0
77
parameters:
8-
AiLocation:
8+
AzureAiServiceLocation:
99
type: string
1010
default: japaneast
11-
ResourcePrefix:
11+
Prefix:
1212
type: string
13-
default: bs-azdtest
13+
default: azdtemp
1414
baseUrl:
1515
type: string
1616
default: 'https://raw.githubusercontent.com/microsoft/Modernize-your-code-solution-accelerator'
1717
deployment:
1818
mode: Incremental
1919
template: ./infra/main.bicep # Path to the main.bicep file inside the 'deployment' folder
20-
prameters:
21-
AiLocation: ${{ parameters.AiLocation }}
22-
ResourcePrefix: ${{ parameters.ResourcePrefix }}
20+
parameters:
21+
AzureAiServiceLocation: ${{ parameters.AzureAiServiceLocation }}
22+
Prefix: ${{ parameters.Prefix }}
2323
baseUrl: ${{ parameters.baseUrl }}
24+
hooks:
25+
preprovision:
26+
posix:
27+
shell: sh
28+
run: >
29+
chmod u+r+x ./scripts/validate_model_deployment_quota.sh; chmod u+r+x ./scripts/validate_model_quota.sh; ./scripts/validate_model_deployment_quota.sh --subscription "$AZURE_SUBSCRIPTION_ID" --location "${AZURE_AISERVICE_LOCATION:-japaneast}" --models-parameter "aiModelDeployments"
30+
interactive: false
31+
continueOnError: false
32+
33+
windows:
34+
shell: pwsh
35+
run: >
36+
$location = if ($env:AZURE_AISERVICE_LOCATION) { $env:AZURE_AISERVICE_LOCATION } else { "japaneast" };
37+
./scripts/validate_model_deployment_quota.ps1 -SubscriptionId $env:AZURE_SUBSCRIPTION_ID -Location $location -ModelsParameter "aiModelDeployments"
38+
interactive: false
39+
continueOnError: false

‎docs/CustomizingAzdParameters.md

Lines changed: 23 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -2,28 +2,38 @@
22

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

5+
> 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.
56
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.
7+
## Parameters
78

8-
Change the Model Deployment Type (allowed values: Standard, GlobalStandard)
9+
| Name | Type | Default Value | Purpose |
10+
| -------------------------------------- | ------- | ---------------- | ---------------------------------------------------------------------------------------------------- |
11+
| `AZURE_ENV_NAME` | string | `azdtemp` | Used as a prefix for all resource names to ensure uniqueness across environments. |
12+
| `AZURE_LOCATION` | string | `japaneast` | Location of the Azure resources. Controls where the infrastructure will be deployed. |
13+
| `AZURE_ENV_MODEL_DEPLOYMENT_TYPE` | string | `GlobalStandard` | Change the Model Deployment Type (allowed values: Standard, GlobalStandard). |
14+
| `AZURE_ENV_MODEL_NAME` | string | `gpt-4o` | Set the Model Name (allowed values: gpt-4o). |
15+
| `AZURE_ENV_MODEL_VERSION` | string | `2024-08-06` | Set the Azure model version (allowed values: 2024-08-06) |
16+
| `AZURE_ENV_MODEL_CAPACITY` | integer | `200` | Set the Model Capacity (choose a number based on available GPT model capacity in your subscription). |
17+
| `AZURE_ENV_LOG_ANALYTICS_WORKSPACE_ID` | string | `<Existing Workspace Id>` | Set this if you want to reuse an existing Log Analytics Workspace instead of creating a new one. |
18+
| `AZURE_ENV_IMAGETAG` | string | `latest` | Set the Image tag Like (allowed values: latest, dev, hotfix) |
919

10-
```shell
11-
azd env set AZURE_ENV_MODEL_DEPLOYMENT_TYPE Standard
12-
```
13-
14-
Set the Model Name (allowed values: gpt-4)
20+
---
1521

16-
```shell
17-
azd env set AZURE_ENV_MODEL_NAME gpt-4
18-
```
22+
## How to Set a Parameter
1923

20-
Change the Model Capacity (choose a number based on available GPT model capacity in your subscription)
24+
To customize any of the above values, run the following command **before** `azd up`:
2125

22-
```shell
23-
azd env set AZURE_ENV_MODEL_CAPACITY 30
26+
```bash
27+
azd env set <PARAMETER_NAME> <VALUE>
2428
```
2529

2630
Set the Log Analytics Workspace Id if you need to reuse the existing workspace which is already existing
2731
```shell
2832
azd env set AZURE_ENV_LOG_ANALYTICS_WORKSPACE_ID '/subscriptions/<subscription-id>/resourceGroups/<resource-group>/providers/Microsoft.OperationalInsights/workspaces/<workspace-name>'
2933
```
34+
35+
**Example:**
36+
37+
```bash
38+
azd env set AZURE_LOCATION westus2
39+
```

‎docs/EXAMPLE-CustomizingAzdParameters.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
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 <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.
77
88
Change the Content Understanding Location (allowed values: Sweden Central, Australia East)
99

@@ -17,10 +17,10 @@ Change the Model Deployment Type (allowed values: Standard, GlobalStandard)
1717
azd env set AZURE_ENV_MODEL_DEPLOYMENT_TYPE GlobalStandard
1818
```
1919

20-
Set the Model Name (allowed values: gpt-4o-mini, gpt-4o, gpt-4)
20+
Set the Model Name (allowed values: gpt-4o)
2121

2222
```shell
23-
azd env set AZURE_ENV_MODEL_NAME gpt-4o-mini
23+
azd env set AZURE_ENV_MODEL_NAME gpt-4o
2424
```
2525

2626
Change the Model Capacity (choose a number based on available GPT model capacity in your subscription)

‎infra/deploy_ai_foundry.bicep

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,9 @@ var aiHubFriendlyName = azureAiHubName
3333
var aiHubDescription = 'AI Hub for KM template'
3434
var aiProjectName = '${abbrs.ai.aiHubProject}${solutionName}'
3535
var aiProjectFriendlyName = aiProjectName
36-
var aiSearchName = '${abbrs.ai.aiSearch}${solutionName}'
36+
var aiSearchName = '${solutionName}-search'
37+
var applicationInsightsName = '${solutionName}-appi'
38+
3739

3840

3941
resource keyVault 'Microsoft.KeyVault/vaults@2022-07-01' existing = {
@@ -57,6 +59,17 @@ resource logAnalytics 'Microsoft.OperationalInsights/workspaces@2023-09-01' = if
5759
}
5860
}
5961

62+
resource applicationInsights 'Microsoft.Insights/components@2020-02-02' = {
63+
name: applicationInsightsName
64+
location: location
65+
kind: 'web'
66+
properties: {
67+
Application_Type: 'web'
68+
publicNetworkAccessForIngestion: 'Enabled'
69+
publicNetworkAccessForQuery: 'Enabled'
70+
WorkspaceResourceId: logAnalytics.id
71+
}
72+
}
6073

6174
var storageNameCleaned = replace(replace(replace(replace('${storageName}cast', '-', ''), '_', ''), '.', ''),'/', '')
6275

@@ -318,5 +331,6 @@ output storageAccountName string = storageNameCleaned
318331

319332
output logAnalyticsId string = useExisting ? existingLogAnalyticsWorkspace.id : logAnalytics.id
320333
output storageAccountId string = storage.id
334+
output applicationInsightsConnectionString string = applicationInsights.properties.ConnectionString
321335

322336
output projectConnectionString string = '${split(aiHubProject.properties.discoveryUrl, '/')[2]};${subscription().subscriptionId};${resourceGroup().name};${aiHubProject.name}'

0 commit comments

Comments
 (0)
Please sign in to comment.