I want to create an Azure function (C# API Generic HTTP) method that uploads a file to an Office365 Sharepoint document library.
Because OneDrive API allows me to upload large files (using daemon process & certificate authentication), I have succeeded in achieving the goal with a C# Console Application.
The idea would be now to move the code into an Azure function.
However, I receive an error during runtime of the function on the loading of the pfx-certificate.
public static async Task<bool> Run(HttpRequestMessage req, TraceWriter log)
{
string certfile = System.IO.Path.Combine(Environment.ExpandEnvironmentVariable??s("%HOME%"), @"sitewwwroot<functionname>mykeyfile.pfx");
X509Certificate2 cert = new X509Certificate2(certfile, "<myinsanepwd>");
return true; //temporary
}
The line X509Certificate2 cert = new X509Certificate2(certfile, ""); throws an Exception
System.Security.Cryptography.CryptographicException: The system cannot find the file specified.
This is really strange because the file exists on the specified path (I checked using File.Exists() in the method :) )
Could this error have something to do with support.microsoft.com/en-us/kb/948154 ? How can I solve this?
Best regards,
Jens
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…