使用 CmdLet New-AzureRmADAppCredential 使用证书创建新凭据时出错
Error when using CmdLet New-AzureRmADAppCredential to create new credential with certificates
我正在尝试使用 New-AzureRmADAppCredential cmdlet。我正在尝试使用以下语法创建新凭证:
New-SelfSignedCertificateEx -Subject "CN=$ClientId" -KeySpec "Exchange" -FriendlyName "$ClientId"
$start = (Get-Date).ToUniversalTime()
$end = $start.AddDays(4)
New-AzureRmADAppCredential -ApplicationId $application.ObjectId -CertValue $keyValue -StartDate $start -EndDate $end
我注意到,如果我尝试使用证书创建新凭据,它会在特定应用程序上失败并出现以下错误:
New-AzureRmADAppCredential : Update to existing credential with KeyId 'keyid' is not allowed.
此应用程序有 2 个凭据,一个是密码,另一个是证书。 keyid 属于证书凭据。奇怪的是,它在其他应用程序上运行良好,即使该应用程序具有多个证书凭据。我试图查看文档,但找不到任何有用的信息。
所以,我的问题是 - 为什么会发生此错误?我该如何解决这个问题?
更新:通过查看 cmdlet 的 code,它似乎总是更新整个列表,所以我认为这可能与权限有关,但我不确定。
谢谢,
奥马尔
好的,所以我们发现发生这种情况是因为第一个证书是通过修改应用程序清单上传到 Azure AD 的。删除它并使用 powershell 再次添加后,一切正常...
是的,New-AzureRmADAppCredential isn't strong enough, if AAD App has keys, it will update the latest key in the key list and of course won't work(Update to existing credential with KeyId is not allowed
), I think it's a bug; if no key existed, it will create a new key. You can use New-AzureADApplicationPasswordCredential。
我正在尝试使用 New-AzureRmADAppCredential cmdlet。我正在尝试使用以下语法创建新凭证:
New-SelfSignedCertificateEx -Subject "CN=$ClientId" -KeySpec "Exchange" -FriendlyName "$ClientId"
$start = (Get-Date).ToUniversalTime()
$end = $start.AddDays(4)
New-AzureRmADAppCredential -ApplicationId $application.ObjectId -CertValue $keyValue -StartDate $start -EndDate $end
我注意到,如果我尝试使用证书创建新凭据,它会在特定应用程序上失败并出现以下错误:
New-AzureRmADAppCredential : Update to existing credential with KeyId 'keyid' is not allowed.
此应用程序有 2 个凭据,一个是密码,另一个是证书。 keyid 属于证书凭据。奇怪的是,它在其他应用程序上运行良好,即使该应用程序具有多个证书凭据。我试图查看文档,但找不到任何有用的信息。
所以,我的问题是 - 为什么会发生此错误?我该如何解决这个问题?
更新:通过查看 cmdlet 的 code,它似乎总是更新整个列表,所以我认为这可能与权限有关,但我不确定。
谢谢,
奥马尔
好的,所以我们发现发生这种情况是因为第一个证书是通过修改应用程序清单上传到 Azure AD 的。删除它并使用 powershell 再次添加后,一切正常...
是的,New-AzureRmADAppCredential isn't strong enough, if AAD App has keys, it will update the latest key in the key list and of course won't work(Update to existing credential with KeyId is not allowed
), I think it's a bug; if no key existed, it will create a new key. You can use New-AzureADApplicationPasswordCredential。