Skip to content

Commit

Permalink
login using Azure Workload ID when available
Browse files Browse the repository at this point in the history
  • Loading branch information
nawazkh committed Jun 25, 2024
1 parent aed86ce commit 1c24b75
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion hack/ensure-azcli.sh
Original file line number Diff line number Diff line change
Expand Up @@ -25,5 +25,10 @@ if [[ -z "$(command -v az)" ]]; then
AZ_REPO=$(lsb_release -cs)
echo "deb [arch=amd64] https://packages.microsoft.com/repos/azure-cli/ ${AZ_REPO} main" | tee /etc/apt/sources.list.d/azure-cli.list
apt-get update && apt-get install -y azure-cli
az login --service-principal -u "${AZURE_CLIENT_ID}" -p "${AZURE_CLIENT_SECRET}" --tenant "${AZURE_TENANT_ID}" > /dev/null
if [[ -n "${AZURE_WORKLOAD_ID:-}" ]]; then
# TODO: federated token should also be fetched from the workload identity file
az login --service-principal -u "${AZURE_WORKLOAD_ID}" -t "${AZURE_TENANT_ID}" --federated-token "$(cat /var/run/secrets/azure-token/serviceaccount/token)" > /dev/null
else
az login --service-principal -u "${AZURE_CLIENT_ID}" -p "${AZURE_CLIENT_SECRET}" --tenant "${AZURE_TENANT_ID}" > /dev/null
fi
fi

0 comments on commit 1c24b75

Please sign in to comment.