Reputation: 121
I'm trying to automate the registration of Azure AD apps. However, it looks that managing Azure app registration keys with the Azure Portal and with the AzureAD PowerShell module is incompatible. Here is what I am doing:
AzurePortalKey
New-AzureADApplicationPasswordCredential -ObjectId <object id here> -CustomKeyIdentifier "PowerShellKey"
Failed to update application test-bug keys.
Error detail: Unable to complete the request due to data validation error.
PowerShellKey
(either with the key management screen or in the manifest file)The problem might be due to different encodings of the CustomKeyIdentifier used by Powershell and the Azure Portal:
PowerShellKey
is retrieved as 80, 111, 119, 101, 114, 83, 104, 101, 108, 108, 75, 101, 121
(likely UTF-8 or some other 8-bits encoding)AzurePortalKey
is retrieved as 65, 0, 122, 0, 117, 0, 114, 0, 101, 0, 80, 0, 111, 0, 114, 0, 116, 0, 97, 0, 108, 0, 75, 0, 101, 0, 121, 0
(note the intermediary 0's, likely UTF-16 or some other 16-bits encoding)Is there a way to manage keys with PowerShell without breaking the Azure Portal ?
Edit
Since it looks like a bug I've filed a suggestion in the Microsoft Azure feedback forums. Please upvote it if fixing this problem is important for you !
Upvotes: 1
Views: 1547
Reputation: 9401
You can manage keys through Manifest.
Go to Azure portal > You Application > Manifest > Find and select the Key you want to remove > Delete it and save manifest.
Then you can success remove the Key.
As you considered, two different keys have different customKeyIdentifier
format. So, you should not apply customKeyIdentifier
in Powershell.
You can just use New-AzureADApplicationPasswordCredential -ObjectId 53f6e6ea-xxxx-4ebe-xxxx-8309dad5003d
to add keys from powershell.
This key's customKeyIdentifier
in Manifest is null
. You can see the key in portal which has Description with Key description
.
Then you can add or remove keys from portal or powershell without breaking.
The following picture shows that I had added keys from portal after adding a key from Powershell.
Upvotes: 1