如何从 CLI 在 Azure AD 中的 Azure 应用程序注册中生成客户端密钥?

问题描述 投票:0回答:2

如何使用 AZ 命令创建客户端密钥,就像从门户创建客户端密钥一样?

azure authentication azure-active-directory authorization azure-cli
2个回答
29
投票

您正在寻找

az ad app credential reset
,它会附加或覆盖应用程序的密码(即
client secret
)或证书凭据。

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

示例(您也可以指定其他参数,这取决于您):

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


0
投票

获取应用程序注册的客户端ID 例如:“appId”:“b23e2416-xxxx-xxxx-98d4”

创建:

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

输出:

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"
}
© www.soinside.com 2019 - 2024. All rights reserved.