Azure Create Client Secret 具有预定值

Azure Create Client Secret with predetermined value

在Azure中生成Client Secret时,是否可以自己赋值?还是 Azure 必须自己生成机密并由您复制?

我问这个问题的原因是因为我正在管理一个使用最近过期的特定客户端密码的平台,但要更新客户端密码值,我需要进行完全重新部署并且由于多种原因,最好等到 2 月初。

很遗憾,不可以。至少在您使用 Azure 门户时不会。如果您这样做,秘密将由平台自动生成。

After saving the client secret, the value of the client secret is displayed. Copy this value because you aren't able to retrieve the key later. You provide the key value with the application ID to sign in as the application. Store the key value where your application can retrieve it.

摘自 Create a new application secret.

此外,在其他文档中,客户端密码被描述为:

The client secret that you generated for your app in the app registration portal.

或提到

[...] you can get the client ID (Application ID) and generate the client secret (key) values.

根据您的需要,您可以考虑使用 certificates or Managed identities for Azure Resources.

编辑:
但是,您 可以 ,像 中指定的 Joy 一样使用 Azure CLI。

事实上,你可以。只需要先使用 Azure CLI az ad app credential reset, make sure you have installed the Azure CLI

我的测试样本:

如果要创建新的客户端密码,只需使用 --append 参数即可。

az ad app credential reset --id "<application id or object id>" --password "Password12345678!"


创建密文后,我们尝试使用它登录,效果很好。

az login --service-principal --username '<application id>' --password 'Password12345678!' --tenant '<tenant id>'