Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 22 additions & 0 deletions infra/scripts/post-provision/post_deployment_setup.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -236,6 +236,28 @@ try {
$env:AZURE_POSTGRES_DEPLOYER_PRINCIPAL_NAME = $DeployerUpn
}

# -------------------------------------------------------
# Grant the deployer Container Apps Contributor at the resource group so the
# Microsoft identity provider (Easy Auth) can be configured manually on any
# container app in the RG. A direct (non-group) grant sidesteps the
# group-based-RBAC listSecrets validation failure. Idempotent.
# -------------------------------------------------------
$DeployerObjectId = az ad signed-in-user show --query "id" -o tsv 2>$null
if ($LASTEXITCODE -ne 0) { $DeployerObjectId = "" }
$ResourceGroupId = az group show --name $ResourceGroupName --query "id" -o tsv 2>$null
if ($LASTEXITCODE -ne 0) { $ResourceGroupId = "" }
if ($DeployerObjectId -and $ResourceGroupId) {
Write-Host "[OK] Granting Container Apps Contributor to deployer on '$ResourceGroupName'..."
az role assignment create `
--assignee-object-id $DeployerObjectId `
--assignee-principal-type User `
--role "358470bc-b998-42bd-ab17-a7e34c199c0f" `
--scope $ResourceGroupId 2>&1 | Out-Null
if ($LASTEXITCODE -ne 0) {
Write-Warning "Could not grant Container Apps Contributor (needs Owner or User Access Administrator). Configuring Easy Auth manually may fail until this role is assigned."
}
}

Write-Host ""
Write-Host "--- Running post_provision.py ---"
Write-Host ""
Expand Down
16 changes: 16 additions & 0 deletions infra/scripts/post-provision/post_deployment_setup.sh
Original file line number Diff line number Diff line change
Expand Up @@ -202,6 +202,22 @@ if [ -n "$DEPLOYER_UPN" ]; then
export AZURE_POSTGRES_DEPLOYER_PRINCIPAL_NAME="$DEPLOYER_UPN"
fi

# Grant the deployer Container Apps Contributor at the resource group so the
# Microsoft identity provider (Easy Auth) can be configured manually on any
# container app in the RG. A direct (non-group) grant sidesteps the
# group-based-RBAC listSecrets validation failure. Idempotent.
DEPLOYER_OBJECT_ID=$(az ad signed-in-user show --query "id" -o tsv 2>/dev/null || true)
RESOURCE_GROUP_ID=$(az group show --name "$RESOURCE_GROUP" --query "id" -o tsv 2>/dev/null || true)
if [ -n "$DEPLOYER_OBJECT_ID" ] && [ -n "$RESOURCE_GROUP_ID" ]; then
echo "✓ Granting Container Apps Contributor to deployer on '${RESOURCE_GROUP}'..."
az role assignment create \
--assignee-object-id "$DEPLOYER_OBJECT_ID" \
--assignee-principal-type User \
--role "358470bc-b998-42bd-ab17-a7e34c199c0f" \
--scope "$RESOURCE_GROUP_ID" >/dev/null 2>&1 || \
echo "⚠ Could not grant Container Apps Contributor (needs Owner or User Access Administrator). Configuring Easy Auth manually may fail until this role is assigned."
fi

echo ""
echo "--- Running post_provision.py ---"
echo ""
Expand Down
Loading