title: Create an Azure AD application with KeyVault & Azure PowerShell Certificate authentication
body: <p>I was trying to Create a Application in Azure AD with Azure PowerShell Certificate authentication, below is the Powershell snippet:</p>
  
  <pre><code>Login-AzureRmAccount
  
  $certPassword = ConvertTo-SecureString $CertPassword -AsPlainText -Force
  
  $x509 = New-Object System.Security.Cryptography.X509Certificates.X509Certificate2 -ArgumentList     $certPath,$certPassword
  
  $credValue = [System.Convert]::ToBase64String($x509.GetRawCertData())
  
  $adapp = New-AzureRmADApplication -DisplayName $ApplicationName -HomePage $URL -IdentifierUris $URL -CertValue $credValue -StartDate $startDate -EndDate $endDate     
  
  $sp = New-AzureRmADServicePrincipal -ApplicationId $adapp.ApplicationId
  
  Set-AzureRmKeyVaultAccessPolicy -VaultName $VaultName  -ServicePrincipalName $sp.ServicePrincipalNames[1] -PermissionsToKeys all –PermissionsToSecrets all -ResourceGroupName $ResourceGroupName
  </code></pre>
  
  <p>The Azure AD application was created successfully, however for Azure AD application with Certificate Authentication, the customKeyIdentifier and value of in the keyCredentials is null after creation, this is the portion of manifest of my application I downloaded from Azure portal:</p>
  
  <pre><code>"keyCredentials": [{
        "customKeyIdentifier": null,
        "endDate": "2018-01-25T11:55:35.7680698Z",
        "keyId": "ca1e536c-2220-478b-af73-1198d125bb5f",
        "startDate": "2017-01-25T11:55:35.7680698Z",
        "type": "AsymmetricX509Cert",
        "usage": "Verify",
        "value": null
      } ]
  </code></pre>
  
  <p>The certificate is a self signed certificate created using makecert command generated locally.
  I am using Powershell Version of 2.0.1</p>
  
  <p>C# Code to retrieve the token with Application Id &amp; Thumbprint</p>
  
  <blockquote>
    <p>public static async Task GetAccessToken(string authority,
    string resource, string scope) {
        var context = new AuthenticationContext(authority, TokenCache.DefaultShared);
        var result = await context.AcquireTokenAsync(resource, AssertionCert);
        return result.AccessToken; }</p>
  </blockquote>
  
  <p>This Code errors out at var result with "Keyset does not exists"</p>
  
  <p>Is there any way to resolve this issue?</p>
  
  <p>Thank you :)</p>