Why does this az login command fail in Gitlab CI?

Viewed 2002

I'm trying to run a task within GitLab CI using the official MS Azure-CLI docker image. It fails at the first step, logging in using the "az login" command. I'm using a service principal login with a secret, all stored as GitLab CI variables. Using this command with the CI job:

az login --service-principal --username="${AZURE_APP_ID}" --password="${AZURE_CLIENT_SECRET}" --tenant=${AZURE_TENANT_ID}

gives me the error:

usage error: --service-principal --username NAME --password SECRET --tenant TENANT

Yet if I run the Azure-CLI docker image locally and run the exact same command it works fine. Why is this not working? What format do I need to use to get the damn thing working?

1 Answers

Debug with Print Driven Development style.

Before the az login line echo all the variables to see if they have the proper values.

I could reproduce the error you provided only in one occasion, when the command line contained this only: az login --service-principal

If any more arguments or garbage are provided, the error is different. You should check if Gitlab CI even executes those commands you think it should execute.

Related