Skip to content

Commit 2de49a3

Browse files
update local dev scripts
1 parent 328ac28 commit 2de49a3

4 files changed

Lines changed: 166 additions & 5 deletions

File tree

content-gen/infra/main.bicep

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1006,3 +1006,15 @@ output CONTAINER_INSTANCE_FQDN string = enablePrivateNetworking ? '' : container
10061006

10071007
@description('Contains ACR Name')
10081008
output ACR_NAME string = acrResourceName
1009+
1010+
@description('Contains flag for Azure AI Foundry usage')
1011+
output USE_FOUNDRY bool = useFoundryMode ? true : false
1012+
1013+
@description('Contains Azure AI Project Endpoint')
1014+
output AZURE_AI_PROJECT_ENDPOINT string = aiFoundryAiProjectEndpoint
1015+
1016+
@description('Contains Azure AI Model Deployment Name')
1017+
output AZURE_AI_MODEL_DEPLOYMENT_NAME string = gptModelName
1018+
1019+
@description('Contains Azure AI Image Model Deployment Name (empty if none selected)')
1020+
output AZURE_AI_IMAGE_MODEL_DEPLOYMENT string = imageModelConfig[imageModelChoice].name

content-gen/infra/main.json

Lines changed: 53 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
"_generator": {
77
"name": "bicep",
88
"version": "0.39.26.7824",
9-
"templateHash": "9059763401810969608"
9+
"templateHash": "12629934330443935294"
1010
},
1111
"name": "Intelligent Content Generation Accelerator",
1212
"description": "Solution Accelerator for multimodal marketing content generation using Microsoft Agent Framework.\n"
@@ -172,6 +172,13 @@
172172
"description": "Optional. Enable monitoring for applicable resources (WAF-aligned)."
173173
}
174174
},
175+
"useFoundryMode": {
176+
"type": "bool",
177+
"defaultValue": true,
178+
"metadata": {
179+
"description": "Optional. Enable Azure AI Foundry mode for multi-agent orchestration."
180+
}
181+
},
175182
"enableScalability": {
176183
"type": "bool",
177184
"defaultValue": false,
@@ -33260,6 +33267,22 @@
3326033267
{
3326133268
"name": "RUNNING_IN_PRODUCTION",
3326233269
"value": "true"
33270+
},
33271+
{
33272+
"name": "USE_FOUNDRY",
33273+
"value": "[if(parameters('useFoundryMode'), 'true', 'false')]"
33274+
},
33275+
{
33276+
"name": "AZURE_AI_PROJECT_ENDPOINT",
33277+
"value": "[if(variables('useExistingAiFoundryAiProject'), format('https://{0}.services.ai.azure.com/api/projects/{1}', variables('aiFoundryAiServicesResourceName'), variables('aiFoundryAiProjectResourceName')), reference('aiFoundryAiServicesProject').outputs.apiEndpoint.value)]"
33278+
},
33279+
{
33280+
"name": "AZURE_AI_MODEL_DEPLOYMENT_NAME",
33281+
"value": "[parameters('gptModelName')]"
33282+
},
33283+
{
33284+
"name": "AZURE_AI_IMAGE_MODEL_DEPLOYMENT",
33285+
"value": "[variables('imageModelConfig')[parameters('imageModelChoice')].name]"
3326333286
}
3326433287
]
3326533288
}
@@ -33456,6 +33479,7 @@
3345633479
}
3345733480
},
3345833481
"dependsOn": [
33482+
"aiFoundryAiServicesProject",
3345933483
"userAssignedIdentity",
3346033484
"virtualNetwork"
3346133485
]
@@ -33692,6 +33716,34 @@
3369233716
"description": "Contains ACR Name"
3369333717
},
3369433718
"value": "[variables('acrResourceName')]"
33719+
},
33720+
"USE_FOUNDRY": {
33721+
"type": "bool",
33722+
"metadata": {
33723+
"description": "Contains flag for Azure AI Foundry usage"
33724+
},
33725+
"value": "[if(parameters('useFoundryMode'), true(), false())]"
33726+
},
33727+
"AZURE_AI_PROJECT_ENDPOINT": {
33728+
"type": "string",
33729+
"metadata": {
33730+
"description": "Contains Azure AI Project Endpoint"
33731+
},
33732+
"value": "[if(variables('useExistingAiFoundryAiProject'), format('https://{0}.services.ai.azure.com/api/projects/{1}', variables('aiFoundryAiServicesResourceName'), variables('aiFoundryAiProjectResourceName')), reference('aiFoundryAiServicesProject').outputs.apiEndpoint.value)]"
33733+
},
33734+
"AZURE_AI_MODEL_DEPLOYMENT_NAME": {
33735+
"type": "string",
33736+
"metadata": {
33737+
"description": "Contains Azure AI Model Deployment Name"
33738+
},
33739+
"value": "[parameters('gptModelName')]"
33740+
},
33741+
"AZURE_AI_IMAGE_MODEL_DEPLOYMENT": {
33742+
"type": "string",
33743+
"metadata": {
33744+
"description": "Contains Azure AI Image Model Deployment Name (empty if none selected)"
33745+
},
33746+
"value": "[variables('imageModelConfig')[parameters('imageModelChoice')].name]"
3369533747
}
3369633748
}
3369733749
}

content-gen/scripts/local_dev.ps1

Lines changed: 51 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ $ScriptDir = Split-Path -Parent $MyInvocation.MyCommand.Path
3131
$ProjectRoot = Split-Path -Parent $ScriptDir
3232
$SrcDir = Join-Path $ProjectRoot "src"
3333
$BackendDir = Join-Path $SrcDir "backend"
34-
$FrontendDir = Join-Path $SrcDir "frontend"
34+
$FrontendDir = Join-Path $SrcDir "app\frontend"
3535

3636
# Default ports
3737
$BackendPort = if ($env:BACKEND_PORT) { $env:BACKEND_PORT } else { "5000" }
@@ -174,7 +174,7 @@ function Ensure-CosmosDBRole {
174174
$roleDefId = "00000000-0000-0000-0000-000000000002"
175175

176176
# Check if role already assigned
177-
$existing = az cosmosdb sql role assignment list --resource-group $resourceGroup --account-name $cosmosAccount --query "[?principalId=='$signedUserId'].id" -o tsv 2>$null
177+
$existing = az cosmosdb sql role assignment list --resource-group $resourceGroup --account-name $cosmosAccount --query "[?principalId=='$signedUserId' && contains(roleDefinitionId, '$roleDefId')].id | [0]" -o tsv 2>$null
178178

179179
if ($existing) {
180180
Write-Success "Cosmos DB role already assigned."
@@ -189,6 +189,53 @@ function Ensure-CosmosDBRole {
189189
}
190190
}
191191

192+
function Ensure-StorageRole {
193+
Write-Info "Checking Storage Blob Data Contributor role..."
194+
195+
# Get env vars
196+
$storageAccount = $null
197+
$resourceGroup = $null
198+
if (Test-Path ".env") {
199+
Get-Content ".env" | ForEach-Object {
200+
if ($_ -match "^AZURE_BLOB_ACCOUNT_NAME=(.*)$") { $storageAccount = $matches[1].Trim('"').Trim("'") }
201+
if ($_ -match "^RESOURCE_GROUP_NAME=(.*)$") { $resourceGroup = $matches[1].Trim('"').Trim("'") }
202+
}
203+
}
204+
205+
if (-not $storageAccount -or -not $resourceGroup) {
206+
Write-Error "AZURE_BLOB_ACCOUNT_NAME or RESOURCE_GROUP_NAME not found in .env"
207+
exit 1
208+
}
209+
210+
$signedUserId = az ad signed-in-user show --query id -o tsv 2>$null
211+
if (-not $signedUserId) {
212+
Write-Error "Could not get signed-in user ID."
213+
exit 1
214+
}
215+
216+
# Get storage account resource ID
217+
$storageResourceId = az storage account show --name $storageAccount --resource-group $resourceGroup --query id -o tsv 2>$null
218+
if (-not $storageResourceId) {
219+
Write-Error "Could not get storage account resource ID."
220+
exit 1
221+
}
222+
223+
$roleId = "Storage Blob Data Contributor"
224+
$existing = az role assignment list --assignee $signedUserId --role $roleId --scope $storageResourceId --query "[0].id" -o tsv 2>$null
225+
226+
if ($existing) {
227+
Write-Success "Storage Blob Data Contributor role already assigned."
228+
} else {
229+
Write-Info "Assigning Storage Blob Data Contributor role..."
230+
az role assignment create --assignee $signedUserId --role $roleId --scope $storageResourceId --output none 2>$null
231+
if ($LASTEXITCODE -ne 0) {
232+
Write-Error "Failed to assign Storage Blob Data Contributor role."
233+
exit 1
234+
}
235+
Write-Success "Storage Blob Data Contributor role assigned."
236+
}
237+
}
238+
192239
# =============================================================================
193240
# Setup Function
194241
# =============================================================================
@@ -339,6 +386,7 @@ function Start-Backend {
339386
Ensure-AzureLogin
340387
Ensure-AzureAIUserRole
341388
Ensure-CosmosDBRole
389+
Ensure-StorageRole
342390

343391
# Activate virtual environment
344392
if (Test-Path ".venv") {
@@ -434,6 +482,7 @@ function Start-All {
434482
Ensure-AzureLogin
435483
Ensure-AzureAIUserRole
436484
Ensure-CosmosDBRole
485+
Ensure-StorageRole
437486

438487
Write-Info "Starting backend and frontend in parallel..."
439488
Write-Info ""

content-gen/scripts/local_dev.sh

Lines changed: 50 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
3434
PROJECT_ROOT="$(cd "$SCRIPT_DIR/.." && pwd)"
3535
SRC_DIR="$PROJECT_ROOT/src"
3636
BACKEND_DIR="$SRC_DIR/backend"
37-
FRONTEND_DIR="$SRC_DIR/frontend"
37+
FRONTEND_DIR="$SRC_DIR/app/frontend"
3838

3939
# Default ports
4040
BACKEND_PORT=${BACKEND_PORT:-5000}
@@ -168,7 +168,7 @@ ensure_cosmosdb_role() {
168168

169169
# Check if role already assigned
170170
local existing
171-
existing=$(az cosmosdb sql role assignment list --resource-group "$resource_group" --account-name "$cosmos_account" --query "[?principalId=='$signed_user_id'].id" -o tsv 2>/dev/null)
171+
existing=$(az cosmosdb sql role assignment list --resource-group "$resource_group" --account-name "$cosmos_account" --query "[?principalId=='$signed_user_id' && contains(roleDefinitionId, '$role_def_id')].id | [0]" -o tsv 2>/dev/null)
172172

173173
if [ -n "$existing" ]; then
174174
print_success "Cosmos DB role already assigned."
@@ -183,6 +183,52 @@ ensure_cosmosdb_role() {
183183
fi
184184
}
185185

186+
ensure_storage_role() {
187+
print_info "Checking Storage Blob Data Contributor role..."
188+
189+
local storage_account=""
190+
local resource_group=""
191+
if [ -f ".env" ]; then
192+
storage_account=$(grep "^AZURE_BLOB_ACCOUNT_NAME=" .env | cut -d'=' -f2- | tr -d '"' | tr -d "'" || echo "")
193+
resource_group=$(grep "^RESOURCE_GROUP_NAME=" .env | cut -d'=' -f2- | tr -d '"' | tr -d "'" || echo "")
194+
fi
195+
196+
if [ -z "$storage_account" ] || [ -z "$resource_group" ]; then
197+
print_error "AZURE_BLOB_ACCOUNT_NAME or RESOURCE_GROUP_NAME not found in .env"
198+
exit 1
199+
fi
200+
201+
local signed_user_id
202+
signed_user_id=$(az ad signed-in-user show --query id -o tsv 2>/dev/null)
203+
if [ -z "$signed_user_id" ]; then
204+
print_error "Could not get signed-in user ID."
205+
exit 1
206+
fi
207+
208+
# Get storage account resource ID
209+
local storage_resource_id
210+
storage_resource_id=$(az storage account show --name "$storage_account" --resource-group "$resource_group" --query id -o tsv 2>/dev/null)
211+
if [ -z "$storage_resource_id" ]; then
212+
print_error "Could not get storage account resource ID."
213+
exit 1
214+
fi
215+
216+
local role_name="Storage Blob Data Contributor"
217+
local existing
218+
existing=$(MSYS_NO_PATHCONV=1 az role assignment list --assignee "$signed_user_id" --role "$role_name" --scope "$storage_resource_id" --query "[0].id" -o tsv 2>/dev/null)
219+
220+
if [ -n "$existing" ]; then
221+
print_success "Storage Blob Data Contributor role already assigned."
222+
else
223+
print_info "Assigning Storage Blob Data Contributor role..."
224+
if ! MSYS_NO_PATHCONV=1 az role assignment create --assignee "$signed_user_id" --role "$role_name" --scope "$storage_resource_id" --output none 2>/dev/null; then
225+
print_error "Failed to assign Storage Blob Data Contributor role."
226+
exit 1
227+
fi
228+
print_success "Storage Blob Data Contributor role assigned."
229+
fi
230+
}
231+
186232
# =============================================================================
187233
# Setup Function
188234
# =============================================================================
@@ -323,6 +369,7 @@ start_backend() {
323369
ensure_azure_login
324370
ensure_azure_ai_user_role
325371
ensure_cosmosdb_role
372+
ensure_storage_role
326373

327374
# Activate virtual environment
328375
if [ -d ".venv" ]; then
@@ -410,6 +457,7 @@ start_all() {
410457
ensure_azure_login
411458
ensure_azure_ai_user_role
412459
ensure_cosmosdb_role
460+
ensure_storage_role
413461

414462
print_info "Starting backend and frontend in parallel..."
415463
print_info ""

0 commit comments

Comments
 (0)