0

I was told to use Azure service principal with auth by certificate which is protected by password
I'm trying to login with az cli: az login --service-principal --username '$APP_ID' --tenant '$TENANT_ID' --password C:\sda-cript-dvlp.pfx
..obviously there're no cert password and login fails

Where should I paste certificate's password?

kagarlickij
  • 7,327
  • 10
  • 36
  • 71

1 Answers1

1

To sign in with a certificate, it must be available locally as a PEM or DER file, in ASCII format. When using a PEM file, the PRIVATE KEY and CERTIFICATE must be appended together within the file.

You could refer to the steps below.

1.Login with a user(need the permission to create a service principal), create a service principal along with a self-signed certificate.

az ad sp create-for-rbac --name 'joyapp234' --create-cert

enter image description here

2.Copy the fileWithCertAndPrivateKey in step 1, login as below.

az login --service-principal --username '<app-id>' --tenant '<tenant-id>' --password 'C:\\Users\\joyw\\tmpbnpcixh8.pem'

enter image description here

For more details, see this and this.

Joy Wang
  • 39,905
  • 3
  • 30
  • 54