title: KeyVault - How do I get the pfx file stored in keyvault from my C# app?
body: <p>This is a keyvault related question.
  I stored a pfx cert (with private key) in keyvault.
  From my service principal I am trying to access the keyvault to get the cert.
  I am writing the following code to retrieve the pfx cert. But the cert file does not have private key ☹ 
  I can’t get the private key file that I put in with all the authentications working:</p>
  
  <pre><code>        var keyVaultService = new KeyVaultService(keyVaultSettings);
          var pfx = await keyVaultService.GetKeyVaultSecretValue("test-cert");
  
          Assert.IsTrue(!string.IsNullOrEmpty(pfx));
  
          var bytes = Convert.FromBase64String(pfx);
          var coll = new X509Certificate2Collection();
          coll.Import(bytes, null, X509KeyStorageFlags.Exportable);
          var cert = coll[0];
          Assert.IsTrue(cert.HasPrivateKey); // Assert FAILS!!!
          var key = cert.PrivateKey.ToString();
          Console.WriteLine("private key: " + key);
  </code></pre>