Skip to content

Commit bd244c7

Browse files
Merge branch 'dev' into feature/bicepchanges
2 parents 6c8a4e1 + dc23cba commit bd244c7

34 files changed

+220
-258
lines changed

.flake8

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
[flake8]
22
max-line-length = 88
33
extend-ignore = E501
4-
exclude = .venv, frontend
4+
exclude = .venv, frontend, src/backend/tests
55
ignore = E203, W503, G004, G200, E402

.github/workflows/azure-dev.yml

Lines changed: 9 additions & 59 deletions
Original file line numberDiff line numberDiff line change
@@ -15,69 +15,19 @@ permissions:
1515
jobs:
1616
template_validation_job:
1717
runs-on: ubuntu-latest
18-
name: Template validation
18+
name: template validation
1919
steps:
20-
# Step 1: Checkout the code from your repository
21-
- name: Checkout code
22-
uses: actions/checkout@v4
20+
- uses: actions/checkout@v4
2321

24-
# Step 2: Set up Python
25-
- name: Set up Python
26-
uses: actions/setup-python@v4
27-
with:
28-
python-version: "3.9"
29-
30-
# Step 3: Create and populate the virtual environment
31-
- name: Create virtual environment and install dependencies
32-
run: |
33-
python -m venv .venv
34-
source .venv/bin/activate
35-
python -m pip install --upgrade pip
36-
pip install azure-mgmt-resource azure-identity azure-core azure-mgmt-subscription azure-cli-core
37-
# Install any other dependencies that might be needed
38-
pip freeze > requirements-installed.txt
39-
echo "Virtual environment created with these packages:"
40-
cat requirements-installed.txt
41-
42-
# Step 4: Create azd directory if it doesn't exist
43-
- name: Create azd directory
44-
run: |
45-
mkdir -p ./.azd || true
46-
touch ./.azd/.env || true
47-
48-
# Step 5: Validate the Azure template
49-
- name: Validate Azure Template
50-
uses: microsoft/template-validation-action@v0.3.5
22+
- uses: microsoft/template-validation-action@Latest
5123
id: validation
5224
env:
53-
AZURE_CLIENT_ID: ${{ secrets.AZURE_CLIENT_ID }}
54-
AZURE_TENANT_ID: ${{ secrets.AZURE_TENANT_ID }}
55-
AZURE_SUBSCRIPTION_ID: ${{ secrets.AZURE_SUBSCRIPTION_ID }}
56-
AZURE_ENV_NAME: ${{ secrets.AZURE_ENV_NAME }}
57-
AZURE_LOCATION: ${{ secrets.AZURE_LOCATION }}
25+
AZURE_CLIENT_ID: ${{ vars.AZURE_CLIENT_ID }}
26+
AZURE_TENANT_ID: ${{ vars.AZURE_TENANT_ID }}
27+
AZURE_SUBSCRIPTION_ID: ${{ vars.AZURE_SUBSCRIPTION_ID }}
28+
AZURE_ENV_NAME: ${{ vars.AZURE_ENV_NAME }}
29+
AZURE_LOCATION: ${{ vars.AZURE_LOCATION }}
5830
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
5931

60-
# Step 6: Debug output in case of failure
61-
- name: Debug on failure
62-
if: failure()
63-
run: |
64-
echo "Validation failed. Checking environment:"
65-
ls -la
66-
if [ -d ".venv" ]; then
67-
echo ".venv directory exists"
68-
ls -la .venv/bin/
69-
else
70-
echo ".venv directory does not exist"
71-
fi
72-
if [ -d "tva_*" ]; then
73-
echo "TVA directory exists:"
74-
find . -name "tva_*" -type d
75-
ls -la $(find . -name "tva_*" -type d)
76-
else
77-
echo "No TVA directory found"
78-
fi
79-
80-
# Step 7: Print the result of the validation
81-
- name: Print result
82-
if: success()
32+
- name: print result
8333
run: cat ${{ steps.validation.outputs.resultFile }}

.github/workflows/deploy.yml

Lines changed: 0 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -168,34 +168,6 @@ jobs:
168168
echo "Azure Container Registry name: ${acr_name}"
169169
fi
170170
171-
172-
- name: Build the image and update the container app
173-
id: build-and-update
174-
run: |
175-
176-
set -e
177-
# Define variables for acr and container app names
178-
acr_name="${{ env.ACR_NAME }}"
179-
echo "ACR name: {$acr_name}"
180-
backend_container_app_name="macae-backend"
181-
backend_build_image_tag="backend:latest"
182-
183-
echo "Building the container image..."
184-
# Build the image
185-
az acr build -r ${acr_name} -t ${backend_build_image_tag} ./src/backend
186-
echo "Backend image build completed successfully."
187-
188-
frontend_container_app_name="${{ env.APP_SERVICE_NAME }}"
189-
frontend_build_image_tag="frontend:latest"
190-
191-
echo "Building the container image..."
192-
# Build the image
193-
az acr build -r ${acr_name} -t ${frontend_build_image_tag} ./src/frontend
194-
echo "Frontend image build completed successfully."
195-
196-
# Add the new container to the website
197-
az webapp config container set --resource-group ${{ env.RESOURCE_GROUP_NAME }} --name ${frontend_container_app_name} --container-image-name ${acr_name}.azurecr.io/frontend:latest --container-registry-url https://${acr_name}.azurecr.io
198-
199171
200172
- name: Delete Bicep Deployment
201173
if: success()

.github/workflows/docker-build-and-push.yml

Lines changed: 33 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ on:
1818
- dev
1919
- demo
2020
- hotfix
21-
workflow_dispatch:
21+
workflow_dispatch:
2222

2323
jobs:
2424
build-and-push:
@@ -32,14 +32,19 @@ jobs:
3232
uses: docker/setup-buildx-action@v1
3333

3434
- name: Log in to Azure Container Registry
35-
if: ${{ (github.ref_name == 'main' || github.ref_name == 'dev' || github.ref_name == 'demo' || github.ref_name == 'hotfix') }}
35+
if: ${{ github.ref_name == 'main' || github.ref_name == 'dev' || github.ref_name == 'demo' || github.ref_name == 'hotfix' }}
3636
uses: azure/docker-login@v2
3737
with:
3838
login-server: ${{ secrets.ACR_LOGIN_SERVER }}
3939
username: ${{ secrets.ACR_USERNAME }}
4040
password: ${{ secrets.ACR_PASSWORD }}
4141

42-
- name: Set Docker image tag
42+
- name: Get current date
43+
id: date
44+
run: echo "date=$(date +'%Y-%m-%d')" >> $GITHUB_OUTPUT
45+
46+
- name: Determine Tag Name Based on Branch
47+
id: determine_tag
4348
run: |
4449
if [[ "${{ github.ref }}" == "refs/heads/main" ]]; then
4550
echo "TAG=latest" >> $GITHUB_ENV
@@ -52,24 +57,30 @@ jobs:
5257
else
5358
echo "TAG=pullrequest-ignore" >> $GITHUB_ENV
5459
fi
55-
56-
- name: Build and push Docker images optionally
60+
61+
- name: Set Historical Tag
5762
run: |
58-
cd src/backend
59-
docker build -t ${{ secrets.ACR_LOGIN_SERVER }}/macaebackend:${{ env.TAG }} -f Dockerfile . && \
60-
if [[ "${{ env.TAG }}" == "latest" || "${{ env.TAG }}" == "dev" || "${{ env.TAG }}" == "demo" || "${{ env.TAG }}" == "hotfix" ]]; then
61-
docker push ${{ secrets.ACR_LOGIN_SERVER }}/macaebackend:${{ env.TAG }} && \
62-
echo "Backend image built and pushed successfully."
63-
else
64-
echo "Skipping Docker push for backend with tag: ${{ env.TAG }}"
65-
fi
66-
cd ../frontend
67-
docker build -t ${{ secrets.ACR_LOGIN_SERVER }}/macaefrontend:${{ env.TAG }} -f Dockerfile . && \
68-
if [[ "${{ env.TAG }}" == "latest" || "${{ env.TAG }}" == "dev" || "${{ env.TAG }}" == "demo" || "${{ env.TAG }}" == "hotfix" ]]; then
69-
docker push ${{ secrets.ACR_LOGIN_SERVER }}/macaefrontend:${{ env.TAG }} && \
70-
echo "Frontend image built and pushed successfully."
71-
else
72-
echo "Skipping Docker push for frontend with tag: ${{ env.TAG }}"
73-
fi
63+
DATE_TAG=$(date +'%Y-%m-%d')
64+
RUN_ID=${{ github.run_number }}
65+
# Create historical tag using TAG, DATE_TAG, and RUN_ID
66+
echo "HISTORICAL_TAG=${{ env.TAG }}_${DATE_TAG}_${RUN_ID}" >> $GITHUB_ENV
7467
75-
68+
- name: Build and optionally push Backend Docker image
69+
uses: docker/build-push-action@v6
70+
with:
71+
context: ./src/backend
72+
file: ./src/backend/Dockerfile
73+
push: ${{ env.TAG != 'pullrequest-ignore' }}
74+
tags: |
75+
${{ secrets.ACR_LOGIN_SERVER }}/macaebackend:${{ env.TAG }}
76+
${{ secrets.ACR_LOGIN_SERVER }}/macaebackend:${{ env.HISTORICAL_TAG }}
77+
78+
- name: Build and optionally push Frontend Docker image
79+
uses: docker/build-push-action@v6
80+
with:
81+
context: ./src/frontend
82+
file: ./src/frontend/Dockerfile
83+
push: ${{ env.TAG != 'pullrequest-ignore' }}
84+
tags: |
85+
${{ secrets.ACR_LOGIN_SERVER }}/macaefrontend:${{ env.TAG }}
86+
${{ secrets.ACR_LOGIN_SERVER }}/macaefrontend:${{ env.HISTORICAL_TAG }}

infra/deploy_ai_foundry.bicep

Lines changed: 14 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -136,11 +136,8 @@ resource aiHub 'Microsoft.MachineLearningServices/workspaces@2023-08-01-preview'
136136
properties: {
137137
category: 'AIServices'
138138
target: aiServicesEndpoint
139-
authType: 'ApiKey'
139+
authType: 'AAD'
140140
isSharedToAll: true
141-
credentials: {
142-
key: aiServicesKey
143-
}
144141
metadata: {
145142
ApiType: 'Azure'
146143
ResourceId: aiServicesId
@@ -162,6 +159,19 @@ resource aiHubProject 'Microsoft.MachineLearningServices/workspaces@2024-01-01-p
162159
}
163160
}
164161

162+
resource aiDeveloper 'Microsoft.Authorization/roleDefinitions@2022-04-01' existing = {
163+
name: '64702f94-c441-49e6-a78b-ef80e0188fee'
164+
}
165+
166+
resource aiDevelopertoAIProject 'Microsoft.Authorization/roleAssignments@2022-04-01' = {
167+
name: guid(aiHubProject.id, aiDeveloper.id)
168+
scope: resourceGroup()
169+
properties: {
170+
roleDefinitionId: aiDeveloper.id
171+
principalId: aiHubProject.identity.principalId
172+
}
173+
}
174+
165175
resource tenantIdEntry 'Microsoft.KeyVault/vaults/secrets@2021-11-01-preview' = {
166176
parent: keyVault
167177
name: 'TENANT-ID'

infra/main.bicep

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -128,7 +128,7 @@ resource aiServices 'Microsoft.CognitiveServices/accounts@2024-04-01-preview' =
128128
apiProperties: {
129129
//statisticsEnabled: false
130130
}
131-
//disableLocalAuth: true
131+
disableLocalAuth: true
132132
}
133133
}
134134

@@ -210,7 +210,7 @@ resource cosmos 'Microsoft.DocumentDB/databaseAccounts@2024-05-15' = {
210210
}
211211
]
212212
capabilities: [{ name: 'EnableServerless' }]
213-
//disableLocalAuth: true
213+
disableLocalAuth: true
214214
}
215215

216216
resource contributorRoleDefinition 'sqlRoleDefinitions' existing = {

infra/main.json

Lines changed: 27 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -5,14 +5,13 @@
55
"metadata": {
66
"_generator": {
77
"name": "bicep",
8-
"version": "0.34.44.8038",
9-
"templateHash": "17550717161725705246"
8+
"version": "0.35.1.17967",
9+
"templateHash": "4208201882676728802"
1010
}
1111
},
1212
"parameters": {
1313
"azureOpenAILocation": {
1414
"type": "string",
15-
"defaultValue": "eastus2",
1615
"allowedValues": [
1716
"australiaeast",
1817
"brazilsouth",
@@ -454,7 +453,8 @@
454453
"kind": "AIServices",
455454
"properties": {
456455
"customSubDomainName": "[variables('aiServicesName')]",
457-
"apiProperties": {}
456+
"apiProperties": {},
457+
"disableLocalAuth": true
458458
}
459459
},
460460
"aiServicesDeployments": {
@@ -522,7 +522,8 @@
522522
{
523523
"name": "EnableServerless"
524524
}
525-
]
525+
],
526+
"disableLocalAuth": true
526527
}
527528
},
528529
"pullIdentity": {
@@ -543,7 +544,7 @@
543544
"destination": "log-analytics",
544545
"logAnalyticsConfiguration": {
545546
"customerId": "[reference('logAnalytics').customerId]",
546-
"sharedKey": "[listKeys(resourceId('Microsoft.OperationalInsights/workspaces', format('{0}{1}', variables('abbrs').managementGovernance.logAnalyticsWorkspace, variables('solutionPrefix'))), '2023-09-01').primarySharedKey]"
547+
"sharedKey": "[listKeys('logAnalytics', '2023-09-01').primarySharedKey]"
547548
}
548549
}
549550
},
@@ -808,8 +809,8 @@
808809
"metadata": {
809810
"_generator": {
810811
"name": "bicep",
811-
"version": "0.34.44.8038",
812-
"templateHash": "6018596764344872545"
812+
"version": "0.35.1.17967",
813+
"templateHash": "4587248441449388111"
813814
}
814815
},
815816
"parameters": {
@@ -928,7 +929,7 @@
928929
"value": "[reference('aiServices').endpoint]"
929930
},
930931
"aiServicesKey": {
931-
"value": "[listKeys(resourceId('Microsoft.CognitiveServices/accounts', variables('aiServicesName')), '2024-04-01-preview').key1]"
932+
"value": "[listKeys('aiServices', '2024-04-01-preview').key1]"
932933
},
933934
"aiServicesId": {
934935
"value": "[resourceId('Microsoft.CognitiveServices/accounts', variables('aiServicesName'))]"
@@ -940,8 +941,8 @@
940941
"metadata": {
941942
"_generator": {
942943
"name": "bicep",
943-
"version": "0.34.44.8038",
944-
"templateHash": "4169059378107378993"
944+
"version": "0.35.1.17967",
945+
"templateHash": "13047093698365252995"
945946
}
946947
},
947948
"parameters": {
@@ -1223,11 +1224,8 @@
12231224
"properties": {
12241225
"category": "AIServices",
12251226
"target": "[parameters('aiServicesEndpoint')]",
1226-
"authType": "ApiKey",
1227+
"authType": "AAD",
12271228
"isSharedToAll": true,
1228-
"credentials": {
1229-
"key": "[parameters('aiServicesKey')]"
1230-
},
12311229
"metadata": {
12321230
"ApiType": "Azure",
12331231
"ResourceId": "[parameters('aiServicesId')]"
@@ -1353,6 +1351,18 @@
13531351
"[resourceId('Microsoft.MachineLearningServices/workspaces', variables('aiHubName'))]"
13541352
]
13551353
},
1354+
{
1355+
"type": "Microsoft.Authorization/roleAssignments",
1356+
"apiVersion": "2022-04-01",
1357+
"name": "[guid(resourceId('Microsoft.MachineLearningServices/workspaces', variables('aiProjectName')), resourceId('Microsoft.Authorization/roleDefinitions', '64702f94-c441-49e6-a78b-ef80e0188fee'))]",
1358+
"properties": {
1359+
"roleDefinitionId": "[resourceId('Microsoft.Authorization/roleDefinitions', '64702f94-c441-49e6-a78b-ef80e0188fee')]",
1360+
"principalId": "[reference(resourceId('Microsoft.MachineLearningServices/workspaces', variables('aiProjectName')), '2024-01-01-preview', 'full').identity.principalId]"
1361+
},
1362+
"dependsOn": [
1363+
"[resourceId('Microsoft.MachineLearningServices/workspaces', variables('aiProjectName'))]"
1364+
]
1365+
},
13561366
{
13571367
"type": "Microsoft.KeyVault/vaults/secrets",
13581368
"apiVersion": "2021-11-01-preview",
@@ -1561,8 +1571,8 @@
15611571
"metadata": {
15621572
"_generator": {
15631573
"name": "bicep",
1564-
"version": "0.34.44.8038",
1565-
"templateHash": "225360114294826340"
1574+
"version": "0.35.1.17967",
1575+
"templateHash": "14769217536017297821"
15661576
}
15671577
},
15681578
"parameters": {

0 commit comments

Comments
 (0)