@@ -123,23 +123,32 @@ jobs:
123123
124124 - name : Azure Login (Managed Identity)
125125 run : |
126- # GitHub Actions injects IDENTITY_ENDPOINT / IDENTITY_HEADER which
127- # cause az CLI to bypass IMDS and hit the Actions OIDC endpoint.
128- # Unsetting them forces az CLI to use the VM's IMDS for managed identity.
129- unset IDENTITY_ENDPOINT IDENTITY_HEADER
130- unset MSI_ENDPOINT MSI_SECRET
131- unset ACTIONS_ID_TOKEN_REQUEST_URL ACTIONS_ID_TOKEN_REQUEST_TOKEN
126+ set -euo pipefail
132127
133128 if [ -z "$AZURE_CLIENT_ID" ]; then
134129 echo "::error::AZURE_CLIENT_ID secret is empty or not set"
135130 exit 1
136131 fi
137132
138- echo "Authenticating via user-assigned managed identity..."
139- az login --identity \
140- --client-id "$AZURE_CLIENT_ID" \
141- --output none
142- az account set --subscription "$E2E_AZURE_SUBSCRIPTION_ID"
133+ # Debug: show identity-related env vars that may confuse az CLI
134+ echo "=== Identity-related env vars in GHA runner ==="
135+ env | sort | grep -iE '^(IDENTITY|MSI_|ACTIONS_ID|AZURE_)' \
136+ | sed 's/=.*/=<set>/' || echo "(none)"
137+ echo "=== end ==="
138+
139+ # Run az login in a stripped environment so that no GHA/OIDC/App-Service
140+ # variables trick azure-identity into a non-IMDS code-path.
141+ CLIENT_ID="$AZURE_CLIENT_ID"
142+ SUB_ID="$E2E_AZURE_SUBSCRIPTION_ID"
143+
144+ env -i \
145+ HOME="$HOME" \
146+ PATH="$PATH" \
147+ LANG="${LANG:-C.UTF-8}" \
148+ AZURE_CONFIG_DIR="${AZURE_CONFIG_DIR:-$HOME/.azure}" \
149+ bash -c "az login --identity --client-id '${CLIENT_ID}' --output none"
150+
151+ az account set --subscription "$SUB_ID"
143152 echo "Logged in. Active subscription:"
144153 az account show --query '{name:name, id:id}' -o table
145154
0 commit comments