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 ebe5917
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion hack/ensure-azcli.sh
Original file line number Diff line number Diff line change
Expand Up @@ -25,5 +25,9 @@ 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
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 ebe5917

Please sign in to comment.