Error when using CmdLet New-AzureRmADAppCredential to create new credential with certificates

让人想犯罪 __ 提交于 2019-12-23 02:57:15

问题


I am trying to use the New-AzureRmADAppCredential cmdlet. I am trying to create a new credential using the following syntax: 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 I've noticed that if I try to create a new credential with a certificate, it failed on a specific apps with the following error: New-AzureRmADAppCredential : Update to existing credential with KeyId 'keyid' is not allowed. This app has 2 credentials, one is a password and the other is a certificate. The keyid belong to the certificate credential. The weird part is that on other app it worked fine, even if the app has multiple certificate credentials. I've tried to look at the documentation, but couldn't find anything useful.
So, my question is - why this error happens? and how I can solve this?
Update: By looking in the code of the cmdlet, it seems like it always updating the whole list, so I think it might be something related to permission, but I am not sure.
Thanks,
Omer


回答1:


Yeah, 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 instead.




回答2:


Ok, so we found out this happens because the first certificate was uploaded to Azure AD by modifying the application manifest. After deleting it and adding it again using powershell everything worked...



来源:https://stackoverflow.com/questions/39220516/error-when-using-cmdlet-new-azurermadappcredential-to-create-new-credential-with

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!