Open

Description
Description
When attempting to create a new certificate-based credential for an existing service principal, the certificate is created, but does not show in the portal (App registrations > {app_name} > certificates & secrets), whereas, using the same technique to create the certificate but generating a new service principal, the certificate shows up.
Steps to reproduce
As per your docs:
- https://docs.microsoft.com/en-us/azure/active-directory/develop/howto-authenticate-service-principal-powershell#create-service-principal-with-self-signed-certificate
- https://docs.microsoft.com/en-us/powershell/module/az.resources/new-azadappcredential?view=azps-3.8.0 (Example 3, where you get an existing application)
# Create self-signed cert:
$oCert = New-SelfSignedCertificate `
-CertStoreLocation "cert:\CurrentUser\My" `
-Subject "CN=Test2020" `
-KeySpec KeyExchange
$KeyValue = [System.Convert]::ToBase64String($oCert.GetRawCertData())
# Get AD APP
$MyApp = Get-AzADApplication -DisplayName "Test2020"
#Create and assign credential
$MyApp | New-AzADAppCredential -CertValue $KeyValue -StartDate $oCert.NotBefore -EndDate $oCert.NotAfter
# Check portal - not showing.
# Check with PowerShell
Get-AzADAppCredential -ApplicationObject $oAADApp
#Output
StartDate EndDate KeyId Type
--------- ------- ----- ----
06/05/2020 22:45:11 06/05/2021 23:05:11 46a3d10d-a65d-266a-55d5-0ddae26a6a3a AsymmetricX509Cert
Environment data
Name Value
---- -----
PSVersion 5.1.18362.752
PSEdition Desktop
PSCompatibleVersions {1.0, 2.0, 3.0, 4.0...}
BuildVersion 10.0.18362.752
CLRVersion 4.0.30319.42000
WSManStackVersion 3.0
PSRemotingProtocolVersion 2.3
SerializationVersion 1.1.0.1
Module versions
ModuleType Version Name ExportedCommands
---------- ------- ---- ----------------
Script 1.13.0 Az.Resources {Add-AzADGroupMember, Export-AzResourceGroup, Get-AzADAppCredential, Get-AzADApplication...}
Debug output
Happy to share privately with MS.
Error output
No errors produced.
Discussed in https://github.com/MicrosoftDocs/azure-docs/issues/41433