I'm having trouble accessing a certificate I uploaded to Azure to manage my account in code.
I've followed this tutorial: http://azure.microsoft.com/blog/2014/10/27/using-certificates-in-azure-websites-applications/
Uploaded the cert to Azure settings:
I've configured a web app on Azure to be a basic plan and uploaded the pfx of that same cert to the web app:
Then I run this code (both locally and after publishing):
X509Store certStore = new X509Store(StoreName.My, StoreLocation.CurrentUser);
certStore.Open(OpenFlags.ReadOnly);
X509Certificate2Collection certCollection = certStore.Certificates.Find(
X509FindType.FindByThumbprint,
// Replace below with your cert's thumbprint
“XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX”,
false);
// Get the first cert with the thumbprint
if (certCollection.Count > 0)
{
X509Certificate2 cert = certCollection[0];
// Use certificate
Console.WriteLine(cert.FriendlyName);
}
certStore.Close();
Locally on my development machine, this runs fine, I send a create database command off to Azure REST API and voila, my command works.
When I publish however, certCollection
is empty so I cannot attempt to issue commands against the Azure Management APIs.
Why is this happening?