You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
# ── Signed-in user principal id (for backend API auth header) ─────────────
603
-
$script:userPrincipalId= az ad signed-in-user show --query id -o tsv
625
+
# In CI the workflow logs in as a service principal (OIDC), so
626
+
# `az ad signed-in-user show` returns nothing. Fall back to an explicit
627
+
# USER_PRINCIPAL_ID env var, then to the SP object id looked up via
628
+
# AZURE_CLIENT_ID.
629
+
if ($env:USER_PRINCIPAL_ID) {
630
+
$script:userPrincipalId=$env:USER_PRINCIPAL_ID
631
+
Write-Host"Using principal id from USER_PRINCIPAL_ID env var."
632
+
} else {
633
+
$script:userPrincipalId= az ad signed-in-user show --query id -o tsv 2>$null
634
+
if (-not$script:userPrincipalId-and$env:AZURE_CLIENT_ID) {
635
+
Write-Host"No interactive user — falling back to service principal object id (AZURE_CLIENT_ID=$($env:AZURE_CLIENT_ID))."
636
+
$script:userPrincipalId= az ad sp show --id $env:AZURE_CLIENT_ID--query id -o tsv 2>$null
637
+
}
638
+
}
604
639
if (-not$script:userPrincipalId) {
605
-
Write-Host"Error: Could not retrieve signed-in user principal id."-ForegroundColor Red
640
+
Write-Host"Error: Could not retrieve signed-in user principal id. In CI, set USER_PRINCIPAL_ID or ensure AZURE_CLIENT_ID is exported and the SP is visible to Microsoft Graph."-ForegroundColor Red
0 commit comments