Skip to content

Commit 5da4063

Browse files
author
Prajwal-Microsoft
authored
Merge branch 'dev' into main-to-dev
2 parents 5dbd9b2 + 541b085 commit 5da4063

5 files changed

Lines changed: 1531 additions & 5 deletions

File tree

azure_custom.yaml

Lines changed: 108 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,108 @@
1+
# yaml-language-server: $schema=https://raw.githubusercontent.com/Azure/azure-dev/main/schemas/v1.0/azure.yaml.json
2+
3+
# This file contains a developer‑focused Azure Developer CLI configuration. It
4+
# extends the default template by defining three services (backend API,
5+
# processor and frontend) and instructs azd to build container images from
6+
# your local source code. All three services are packaged as container apps
7+
# using the Dockerfiles located in their respective project directories.
8+
# After deployment a post‑deploy hook prints the endpoints of the deployed
9+
# container apps.
10+
11+
name: container-migration-solution-accelerator
12+
metadata:
13+
template: container-migration-solution-accelerator@1.0
14+
15+
requiredVersions:
16+
# Require a recent version of azd that supports the packaging
17+
# functionality used here. Versions less than 1.17.1 had a bug in
18+
# remoteBuild.
19+
azd: ">=1.18.2"
20+
21+
infra:
22+
parameters:
23+
backendImageName: ${SERVICE_BACKEND_IMAGE_NAME}
24+
processorImageName: ${SERVICE_PROCESSOR_IMAGE_NAME}
25+
frontendImageName: ${SERVICE_FRONTEND_IMAGE_NAME}
26+
27+
services:
28+
# Backend API service. This is a Python FastAPI application defined in
29+
# src/backend-api. The azd packaging stage builds a Docker image using
30+
# the Dockerfile in that directory. The image name 'backend-api' is
31+
# combined with the automatically created Azure Container Registry login
32+
# server to form the final image reference.
33+
backend:
34+
project: ./src/backend-api
35+
language: py
36+
host: containerapp
37+
docker:
38+
image: backend-api
39+
remoteBuild: true
40+
41+
# Processor service. This service reads messages from storage queues and
42+
# orchestrates long‑running migrations. It is also packaged as a
43+
# container and deployed to a container app environment. The Dockerfile
44+
# in the src/processor directory defines how the image is built.
45+
processor:
46+
project: ./src/processor
47+
language: py
48+
host: containerapp
49+
docker:
50+
image: processor
51+
remoteBuild: true
52+
53+
# Frontend service. The frontend consists of a React single‑page
54+
# application and a lightweight Python server that serves the compiled
55+
# assets. azd packages the frontend by building a Docker image using
56+
# the Dockerfile in the src/frontend directory and deploys it to a
57+
# container app.
58+
frontend:
59+
project: ./src/frontend
60+
language: py
61+
host: containerapp
62+
docker:
63+
image: frontend
64+
remoteBuild: true
65+
66+
hooks:
67+
# After deployment prints the names and endpoints of the deployed
68+
# container apps. This reproduces the behaviour of the default
69+
# configuration so that developers can easily discover their services.
70+
postdeploy:
71+
posix:
72+
shell: sh
73+
run: |
74+
echo "-----"
75+
echo "🧭 Frontend Container App Details:"
76+
echo "✅ Name: $CONTAINER_FRONTEND_APP_NAME"
77+
echo "🌐 Endpoint: https://$CONTAINER_FRONTEND_APP_FQDN"
78+
echo "🔗 Portal URL: https://portal.azure.com/#resource/subscriptions/$AZURE_SUBSCRIPTION_ID/resourceGroups/$AZURE_RESOURCE_GROUP/providers/Microsoft.App/containerApps/$CONTAINER_FRONTEND_APP_NAME"
79+
echo "-----"
80+
echo "🧭 Backend API Container App Details:"
81+
echo "✅ Name: $CONTAINER_API_APP_NAME"
82+
echo "🌐 Endpoint: https://$CONTAINER_API_APP_FQDN"
83+
echo "🔗 Portal URL: https://portal.azure.com/#resource/subscriptions/$AZURE_SUBSCRIPTION_ID/resourceGroups/$AZURE_RESOURCE_GROUP/providers/Microsoft.App/containerApps/$CONTAINER_API_APP_NAME"
84+
echo "-----"
85+
echo "🧭 Processor Container App Details:"
86+
echo "✅ Name: $SERVICE_PROCESSOR_NAME"
87+
echo "🔗 Portal URL: https://portal.azure.com/#resource/subscriptions/$AZURE_SUBSCRIPTION_ID/resourceGroups/$AZURE_RESOURCE_GROUP/providers/Microsoft.App/containerApps/$SERVICE_PROCESSOR_NAME"
88+
echo "-----"
89+
interactive: true
90+
windows:
91+
shell: pwsh
92+
run: |
93+
Write-Host "-----"
94+
Write-Host "🧭 Frontend Container App Details:"
95+
Write-Host "✅ Name: $env:CONTAINER_FRONTEND_APP_NAME"
96+
Write-Host "🌐 Endpoint: https://$env:CONTAINER_FRONTEND_APP_FQDN"
97+
Write-Host "🔗 Portal URL: https://portal.azure.com/#resource/subscriptions/$env:AZURE_SUBSCRIPTION_ID/resourceGroups/$env:AZURE_RESOURCE_GROUP/providers/Microsoft.App/containerApps/$env:CONTAINER_FRONTEND_APP_NAME" -ForegroundColor Cyan
98+
Write-Host "-----"
99+
Write-Host "🧭 Backend API Container App Details:"
100+
Write-Host "✅ Name: $env:CONTAINER_API_APP_NAME"
101+
Write-Host "🌐 Endpoint: https://$env:CONTAINER_API_APP_FQDN"
102+
Write-Host "🔗 Portal URL: https://portal.azure.com/#resource/subscriptions/$env:AZURE_SUBSCRIPTION_ID/resourceGroups/$env:AZURE_RESOURCE_GROUP/providers/Microsoft.App/containerApps/$env:CONTAINER_API_APP_NAME" -ForegroundColor Cyan
103+
Write-Host "-----"
104+
Write-Host "🧭 Processor Container App Details:"
105+
Write-Host "✅ Name: $env:SERVICE_PROCESSOR_NAME"
106+
Write-Host "🔗 Portal URL: https://portal.azure.com/#resource/subscriptions/$env:AZURE_SUBSCRIPTION_ID/resourceGroups/$env:AZURE_RESOURCE_GROUP/providers/Microsoft.App/containerApps/$env:SERVICE_PROCESSOR_NAME" -ForegroundColor Cyan
107+
Write-Host "-----"
108+
interactive: true

docs/DeploymentGuide.md

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -430,3 +430,10 @@ azd env get-values
430430
- 🐛 **Issues:** Check [Troubleshooting Guide](./TroubleShootingSteps.md)
431431
- 💬 **Support:** Review [Support Guidelines](../SUPPORT.md)
432432
- 🔧 **Development:** See [Contributing Guide](../CONTRIBUTING.md)
433+
434+
### Deploy Your local changes
435+
To Deploy your local changes rename the below files.
436+
437+
Rename `azure.yaml` to `azure_custom2.yaml` and `azure_custom.yaml` to `azure.yaml`.
438+
Go to `infra` directory
439+
Rename `main.bicep` to `main_custom2.bicep` and `main_custom.bicep` to `main.bicep`. Continue with the [deploying steps](#deploying-with-azd).

infra/main.bicep

Lines changed: 60 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,7 @@ param azureAiServiceLocation string
5353
'westus3'
5454
])
5555
@description('Required. Azure region for AI model deployment. Should match azureAiServiceLocation for optimal performance.')
56+
#disable-next-line no-unused-params
5657
param aiDeploymentLocation string = azureAiServiceLocation
5758

5859
@description('Optional. The host (excluding https://) of an existing container registry. This is the `loginServer` when using Azure Container Registry.')
@@ -103,6 +104,11 @@ param createdBy string = contains(deployer(), 'userPrincipalName')
103104
? split(deployer().userPrincipalName, '@')[0]
104105
: deployer().objectId
105106

107+
// Get the current deployer's information for local debugging permissions
108+
var deployerInfo = deployer()
109+
var deployingUserPrincipalId = deployerInfo.objectId
110+
var deployingUserType = !empty(deployerInfo.userPrincipalName) ? 'User' : 'ServicePrincipal'
111+
106112
@description('Optional. Resource ID of an existing Foundry project')
107113
param existingFoundryProjectResourceId string = ''
108114

@@ -469,6 +475,17 @@ module storageAccount 'br/public:avm/res/storage/storage-account:0.20.0' = {
469475
principalId: appIdentity.outputs.principalId
470476
principalType: 'ServicePrincipal'
471477
}
478+
// Add deployer permissions
479+
{
480+
roleDefinitionIdOrName: 'Storage Blob Data Contributor'
481+
principalId: deployingUserPrincipalId
482+
principalType: deployingUserType
483+
}
484+
{
485+
roleDefinitionIdOrName: 'Storage Queue Data Contributor'
486+
principalId: deployingUserPrincipalId
487+
principalType: deployingUserType
488+
}
472489
]
473490
// WAF aligned networking
474491
networkAcls: {
@@ -655,6 +672,12 @@ module cosmosDb 'br/public:avm/res/document-db/database-account:0.15.0' = {
655672
principalType: 'ServicePrincipal'
656673
roleDefinitionIdOrName: 'DocumentDB Account Contributor'
657674
}
675+
// Add deployer for local debugging
676+
{
677+
principalId: deployingUserPrincipalId
678+
principalType: deployingUserType
679+
roleDefinitionIdOrName: 'DocumentDB Account Contributor'
680+
}
658681
]
659682
// Create custom data plane role definition and assignment
660683
dataPlaneRoleDefinitions: [
@@ -669,6 +692,8 @@ module cosmosDb 'br/public:avm/res/document-db/database-account:0.15.0' = {
669692
]
670693
assignments: [
671694
{ principalId: appIdentity.outputs.principalId }
695+
// ADD THIS for local debugging support:
696+
{ principalId: deployingUserPrincipalId }
672697
]
673698
}
674699
]
@@ -699,7 +724,7 @@ module existingAiFoundryAiServicesDeployments 'modules/ai-services-deployments.b
699724
name: take('module.ai-services-model-deployments.${existingAiFoundryAiServices.name}', 64)
700725
scope: resourceGroup(aiFoundryAiServicesSubscriptionId, aiFoundryAiServicesResourceGroupName)
701726
params: {
702-
name: existingAiFoundryAiServices.name
727+
name: aiFoundryAiServicesResourceName // Fix: use variable instead of resource reference
703728
deployments: [
704729
{
705730
name: aiModelDeploymentName
@@ -715,6 +740,7 @@ module existingAiFoundryAiServicesDeployments 'modules/ai-services-deployments.b
715740
}
716741
]
717742
roleAssignments: [
743+
// Service Principal permissions
718744
{
719745
principalId: appIdentity.outputs.principalId
720746
principalType: 'ServicePrincipal'
@@ -723,12 +749,23 @@ module existingAiFoundryAiServicesDeployments 'modules/ai-services-deployments.b
723749
{
724750
principalId: appIdentity.outputs.principalId
725751
principalType: 'ServicePrincipal'
726-
roleDefinitionIdOrName: '64702f94-c441-49e6-a78b-ef80e0188fee' // Azure AI Developer
752+
roleDefinitionIdOrName: '64702f94-c441-49e6-a78b-ef80e0188fee'
727753
}
728754
{
729755
principalId: appIdentity.outputs.principalId
730756
principalType: 'ServicePrincipal'
731-
roleDefinitionIdOrName: '53ca6127-db72-4b80-b1b0-d745d6d5456d' // Azure AI User
757+
roleDefinitionIdOrName: '53ca6127-db72-4b80-b1b0-d745d6d5456d'
758+
}
759+
// Deployer permissions
760+
{
761+
principalId: deployingUserPrincipalId
762+
principalType: deployingUserType
763+
roleDefinitionIdOrName: 'Cognitive Services OpenAI Contributor'
764+
}
765+
{
766+
principalId: deployingUserPrincipalId
767+
principalType: deployingUserType
768+
roleDefinitionIdOrName: 'Cognitive Services User'
732769
}
733770
]
734771
}
@@ -746,6 +783,7 @@ module aiFoundry 'br/public:avm/ptn/ai-ml/ai-foundry:0.4.0' = if(!useExistingAiF
746783
accountName:aiFoundryAiServicesResourceName
747784
allowProjectManagement: true
748785
roleAssignments: [
786+
// Service Principal permissions
749787
{
750788
principalId: appIdentity.outputs.principalId
751789
principalType: 'ServicePrincipal'
@@ -761,6 +799,17 @@ module aiFoundry 'br/public:avm/ptn/ai-ml/ai-foundry:0.4.0' = if(!useExistingAiF
761799
principalType: 'ServicePrincipal'
762800
roleDefinitionIdOrName: '53ca6127-db72-4b80-b1b0-d745d6d5456d' // Azure AI User
763801
}
802+
// Deployer permissions for local debugging
803+
{
804+
principalId: deployingUserPrincipalId
805+
principalType: deployingUserType
806+
roleDefinitionIdOrName: 'Cognitive Services OpenAI Contributor'
807+
}
808+
{
809+
principalId: deployingUserPrincipalId
810+
principalType: deployingUserType
811+
roleDefinitionIdOrName: 'Cognitive Services User'
812+
}
764813
]
765814
// Remove networking configuration to avoid AML workspace creation issues
766815
networking: enablePrivateNetworking? {
@@ -791,7 +840,7 @@ module aiFoundry 'br/public:avm/ptn/ai-ml/ai-foundry:0.4.0' = if(!useExistingAiF
791840
}
792841
}
793842

794-
var aiServicesName = useExistingAiFoundryAiProject ? existingAiFoundryAiServices.name : aiFoundry.outputs.aiServicesName
843+
var aiServicesName = useExistingAiFoundryAiProject ? existingAiFoundryAiServices.name : aiFoundryAiServicesResourceName
795844
module appConfiguration 'br/public:avm/res/app-configuration/configuration-store:0.9.1' = {
796845
name: take('avm.res.app-config.store.${solutionSuffix}', 64)
797846
params: {
@@ -898,6 +947,8 @@ module appConfiguration 'br/public:avm/res/app-configuration/configuration-store
898947
sku: 'Standard'
899948
publicNetworkAccess: 'Enabled'
900949
}
950+
// Add explicit dependency
951+
dependsOn: useExistingAiFoundryAiProject ? [] : [aiFoundry]
901952
}
902953

903954
module avmAppConfigUpdated 'br/public:avm/res/app-configuration/configuration-store:0.6.3' = if (enablePrivateNetworking) {
@@ -971,7 +1022,7 @@ module containerAppsEnvironment 'br/public:avm/res/app/managed-environment:0.11.
9711022
platformReservedDnsIP: '172.17.17.17'
9721023
zoneRedundant: (enablePrivateNetworking) ? true : false // Enable zone redundancy if private networking is enabled
9731024
infrastructureSubnetResourceId: (enablePrivateNetworking)
974-
? virtualNetwork.outputs.containersSubnetResourceId // Use the container app subnet
1025+
? virtualNetwork!.outputs.containersSubnetResourceId // Use the container app subnet
9751026
: null // Use the container app subnet
9761027
}
9771028
}
@@ -1210,3 +1261,7 @@ output AZURE_SUBSCRIPTION_ID string = subscription().subscriptionId
12101261

12111262
@description('The Azure resource group name.')
12121263
output AZURE_RESOURCE_GROUP string = resourceGroup().name
1264+
1265+
// Log deployer information for debugging
1266+
output deployerObjectId string = deployingUserPrincipalId
1267+
output deployerType string = deployingUserType

0 commit comments

Comments
 (0)