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

2

23

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

Crush answered 30/8, 2019 at 20:32 Comment(0)
U
30

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

Uncap answered 2/9, 2019 at 1:11 Comment(4)
What exactly does append do? Will it create a second secret?Wheatear
@Wheatear yes it creates an additional client secret every time you run it with --appendMange
I get "Property identifierUris is invalid." no matter if I use powershell (AzureAD) or the Cli :/Waw
Just in case anyone is equally confused, there can be a lag between running this command, and the new secret being visible in the Azure Portal. Also, you can use --display-name to set a Description.Marchesa
B
0

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"
}
Backandforth answered 7/12, 2023 at 22:34 Comment(0)

© 2022 - 2025 — McMap. All rights reserved.