如何设置 Azure AD 注册应用程序的 API 密钥 "key description"

How to set an API Key's "key description" of an Azure AD Registered App

我正在尝试找出一种方法来通过 Azure CLI 或 PowerShell

设置 Azure AD 应用程序(注册应用程序)的密钥描述

我知道我可以创建 API 访问密钥,使用 az ad app update --id --password 或 --key-value,但无法设置描述,所以我可以命名键

有什么方法可以创建密钥的描述吗?

无法通过 powershell 或 cli 创建描述,您只能在门户中创建。

AAD powershell and cli essentially call the AAD Graph API, the passwordCredentials does not has the passwordDescription property, see PasswordCredential Type。所以你会发现即使你通过powershell或cli获取应用程序,结果也不会 return 而 passwordCredentialspasswordDescription.

在门户中,如果您创建一个密钥并捕获请求,您会发现它调用 api https://main.iam.ad.ext.azure.com/api/RegisteredApplications/xxxxx?expand={expand}&getLogoUrl={getLogoUrl},它是一个 Microsoft 未公开的 api。您可以在响应中看到 passwordDescription

对于那些感兴趣的人,这里是我的问题的解决方案:

使用 Powershell,您可以使用以下 属性 在 AAD 注册应用程序的 API 权限中以编程方式设置应用程序密码的 "Description",也就是名称"New-AzureADApplicationPasswordCredential" 命令:

-自定义密钥标识符

这是一个完整的可见性命令:

$app = "EnterYourAADRegisteredAppName"
$aadAppId = (Get-AzureADApplication -Filter "DisplayName eq '$app'").ObjectId
New-AzureADApplicationPasswordCredential -ObjectId $aadAppId -CustomKeyIdentifier
"EnterDesiredAppPasswordName"