@@ -16,6 +16,23 @@ $CONTAINER_WORKFLOW_APP_NAME = azd env get-value CONTAINER_WORKFLOW_APP_NAME
1616$SUBSCRIPTION_ID = azd env get-value AZURE_SUBSCRIPTION_ID
1717$RESOURCE_GROUP = azd env get-value AZURE_RESOURCE_GROUP
1818
19+ # If already logged in, pin Azure CLI context to the azd environment subscription.
20+ # If not logged in, the az command that needs auth will surface the login guidance.
21+ if ($SUBSCRIPTION_ID ) {
22+ $CurrentSub = (az account show -- query id - o tsv 2> $null )
23+ if ($CurrentSub ) {
24+ az account set -- subscription $SUBSCRIPTION_ID 2> $null
25+ if ($LASTEXITCODE -ne 0 ) {
26+ throw " Failed to switch Azure CLI context to subscription '$SUBSCRIPTION_ID '. Verify access and re-run."
27+ }
28+
29+ $ActiveSub = (az account show -- query id - o tsv 2> $null )
30+ if (-not $ActiveSub -or $ActiveSub -ne $SUBSCRIPTION_ID ) {
31+ throw " Azure CLI active subscription '$ActiveSub ' does not match AZURE_SUBSCRIPTION_ID '$SUBSCRIPTION_ID '."
32+ }
33+ }
34+ }
35+
1936# Construct Azure Portal URLs
2037$WEB_APP_PORTAL_URL = " https://portal.azure.com/#resource/subscriptions/$SUBSCRIPTION_ID /resourceGroups/$RESOURCE_GROUP /providers/Microsoft.App/containerApps/$CONTAINER_WEB_APP_NAME "
2138$API_APP_PORTAL_URL = " https://portal.azure.com/#resource/subscriptions/$SUBSCRIPTION_ID /resourceGroups/$RESOURCE_GROUP /providers/Microsoft.App/containerApps/$CONTAINER_API_APP_NAME "
@@ -412,6 +429,31 @@ if (-not $ApiReady) {
412429 }
413430}
414431
432+ # --- Refresh Content Understanding Cognitive Services account ---
433+ Write-Host " "
434+ Write-Host (" =" * 60 )
435+ Write-Host " Refreshing Content Understanding Cognitive Services account..."
436+ Write-Host (" =" * 60 )
437+
438+ $CuAccountName = azd env get-value CONTENT_UNDERSTANDING_ACCOUNT_NAME 2> $null
439+
440+ if (-not $CuAccountName ) {
441+ Write-Host " ⚠️ CONTENT_UNDERSTANDING_ACCOUNT_NAME not found in azd env. Skipping refresh."
442+ } else {
443+ Write-Host " Refreshing account: $CuAccountName in resource group: $RESOURCE_GROUP "
444+ az cognitiveservices account update `
445+ - g $RESOURCE_GROUP `
446+ - n $CuAccountName `
447+ -- tags refresh= true `
448+ -- output none
449+
450+ if ($LASTEXITCODE -eq 0 ) {
451+ Write-Host " ✅ Successfully refreshed Cognitive Services account '$CuAccountName '."
452+ } else {
453+ Write-Host " ❌ Failed to refresh Cognitive Services account '$CuAccountName '."
454+ }
455+ }
456+
415457Write-Host " "
416458Write-Host (" =" * 60 )
417459Write-Host " Post-deployment data setup completed."
0 commit comments