@@ -108,10 +108,54 @@ else {
108108 # Show deployment outputs
109109 Write-Host " "
110110 Write-Host " Deployment outputs:" - ForegroundColor Cyan
111- az deployment sub show `
111+ $outputs = az deployment sub show `
112112 -- name $DeploymentName `
113113 -- query " properties.outputs" `
114- -- output table
114+ -- output json | ConvertFrom-Json
115+
116+ $outputs | ConvertTo-Json | Write-Host
117+
118+ # Configure ACR managed identity authentication
119+ if ($outputs.webAppName ) {
120+ $webAppName = $outputs.webAppName.value
121+ $resourceGroupName = (az webapp show -- name $webAppName -- query resourceGroup - o tsv)
122+
123+ Write-Host " "
124+ Write-Host " Configuring ACR managed identity authentication..." - ForegroundColor Yellow
125+
126+ # Ensure acrUseManagedIdentityCreds is set (should be set by Bicep, but double-check)
127+ Write-Host " Verifying ACR managed identity configuration..." - ForegroundColor Cyan
128+ $config = az webapp config show -- name $webAppName -- resource- group $resourceGroupName -- query " acrUseManagedIdentityCreds" - o tsv
129+
130+ if ($config -ne " true" ) {
131+ Write-Host " Setting acrUseManagedIdentityCreds=true..." - ForegroundColor Cyan
132+ az resource update `
133+ -- ids " /subscriptions/$ ( $account.id ) /resourceGroups/$resourceGroupName /providers/Microsoft.Web/sites/$webAppName /config/web" `
134+ -- set properties.acrUseManagedIdentityCreds= true
135+ } else {
136+ Write-Host " ACR managed identity already configured" - ForegroundColor Green
137+ }
138+
139+ # Restart the web app to apply all changes
140+ Write-Host " Restarting web app to apply configuration..." - ForegroundColor Cyan
141+ az webapp restart -- name $webAppName -- resource- group $resourceGroupName
142+
143+ if ($LASTEXITCODE -eq 0 ) {
144+ Write-Host " Web app restarted successfully!" - ForegroundColor Green
145+ Write-Host " "
146+ Write-Host " === Configuration Summary ===" - ForegroundColor Cyan
147+ Write-Host " ✓ System-assigned managed identity enabled" - ForegroundColor Green
148+ Write-Host " ✓ AcrPull role assigned to managed identity" - ForegroundColor Green
149+ Write-Host " ✓ ACR authentication configured to use managed identity" - ForegroundColor Green
150+ Write-Host " ✓ Web app restarted" - ForegroundColor Green
151+ Write-Host " "
152+ if ($outputs.webAppUrl ) {
153+ Write-Host " Web App URL: $ ( $outputs.webAppUrl.value ) " - ForegroundColor Green
154+ }
155+ } else {
156+ Write-Warning " Failed to restart web app. You may need to restart it manually."
157+ }
158+ }
115159 }
116160 else {
117161 Write-Error " Deployment failed with exit code: $LASTEXITCODE "
0 commit comments