Ahmed Mohamed
Ahmed Mohamed

Reputation: 464

How to generate client secret in azure app registration in Azure AD from CLI?

How can I use AZ commands to create client secret the same way I can do it from the portal? Creating client secret from portal

Upvotes: 24

Views: 23377

Answers (2)

Jhonny Ramirez Zeballos
Jhonny Ramirez Zeballos

Reputation: 3156

Get ID Client of app register for example: "appId": "b23e2416-xxxx-xxxx-98d4"

Create:

az ad app credential reset --id b23e2416-xxxx-xxxx-98d4 --append \
  --display-name 'Description: Secret Bolivian client' --end-date '2024-12-31'

Output:

The output includes credentials that you must protect. 
Be sure that you do not include these credentials in your code or check the credentials into your source control. 
For more information, see https://aka.ms/azadsp-cli
{
   "appId": "b23e2416-xxxx-xxxx-98d4",
   "password": "rp28Q~VNlFt-xxxxxxxxxxxxxxxxxxxxxxx",
   "tenant": "67f3b853-xxxx-xxxx-xxxx"
}

Upvotes: 0

Joy Wang
Joy Wang

Reputation: 42063

You are looking for az ad app credential reset, it appends or overwrites an application's password(i.e. client secret) or certificate credentials.

az ad app credential reset --id
                           [--append]
                           [--cert]
                           [--create-cert]
                           [--credential-description]
                           [--end-date]
                           [--keyvault]
                           [--password]
                           [--years]

Sample(you can also specify other parameters, it depends on you):

az ad app credential reset --id xxxxxxxxxxxx --append

enter image description here

Upvotes: 31

Related Questions