Skip to content

Commit 0e2d3de

Browse files
Update New-AzADAppCredential.md (Azure#20317)
Clarify examples. Also fixes the "Unable to get certificate thumbprint" issue in the portal, by giving an example of passing $CertificateThumbprint variable to the -CustomKeyIdentifier parameter. Co-authored-by: NanxiangLiu <[email protected]>
1 parent 9b6109c commit 0e2d3de

File tree

1 file changed

+17
-15
lines changed

1 file changed

+17
-15
lines changed

src/Resources/Resources/help/New-AzADAppCredential.md

Lines changed: 17 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -122,28 +122,30 @@ Creates key credentials or password credentials for an application.
122122

123123
## EXAMPLES
124124

125-
### Example 1: Create key credentials for application
125+
### Example 1: Create key credentials for an application
126+
126127
```powershell
127-
# ObjectId is the string representation of a GUID for directory object, application, in Azure AD.
128-
$Id = "00000000-0000-0000-0000-000000000000"
129-
# $cert is Base64 encoded content of certificate
130-
$credential = New-Object -TypeName "Microsoft.Azure.PowerShell.Cmdlets.Resources.MSGraph.Models.ApiV10.MicrosoftGraphKeyCredential" `
131-
-Property @{'Key' = $cert;
132-
'Usage' = 'Verify';
133-
'Type' = 'AsymmetricX509Cert'
134-
}
135-
New-AzADAppCredential -ObjectId $Id -KeyCredentials $credential
128+
# $ObjectId should be the the 'Object ID' GUID associated with the Azure app registration.
129+
# $CertificateThumbprint should be the thumbprint of the certificate.
130+
# $Cert is the base64 encoded content of the certificate.
131+
$ObjectId = "00000000-0000-0000-0000-000000000000"
132+
$Credential = New-Object -TypeName `
133+
"Microsoft.Azure.PowerShell.Cmdlets.Resources.MSGraph.Models.ApiV10.MicrosoftGraphKeyCredential" `
134+
-Property @{'Key' = $Cert;
135+
'Usage' = 'Verify';
136+
'Type' = 'AsymmetricX509Cert'
137+
}
138+
New-AzADAppCredential -ObjectId $ObjectId -KeyCredentials $Credential -CustomKeyIdentifier $CertificateThumbprint
136139
```
137140

138-
Create key credentials for application with object Id $Id
141+
### Example 2: Create password credentials for an application
139142

140-
### Example 2: Create password credentials for application
141143
```powershell
142-
# ApplicationId is AppId of Application object which is different from directory id in Azure AD.
143-
Get-AzADApplication -ApplicationId $appId | New-AzADAppCredential -StartDate $startDate -EndDate $endDate
144+
# $ApplicationId` should be the the 'Application ID' GUID associated with the Azure app registration.
145+
$ApplicationId = "00000000-0000-0000-0000-000000000000"
146+
Get-AzADApplication -ApplicationId $ApplicationId | New-AzADAppCredential -StartDate $startDate -EndDate $endDate
144147
```
145148

146-
Create password credentials for application
147149

148150
## PARAMETERS
149151

0 commit comments

Comments
 (0)