小编Jen*_*ens的帖子

Azure函数中的运行时错误加载证书

我想创建一个Azure函数(C#API通用HTTP)方法,将文件上载到Office365 Sharepoint文档库.

由于OneDrive API允许我上传大文件(使用守护程序进程和证书身份验证),因此我成功地使用C#控制台应用程序实现了目标.

现在的想法是将代码移动到Azure功能中.但是,在加载pfx证书时,我在函数运行期间收到错误.

public static async Task<bool> Run(HttpRequestMessage req, TraceWriter log)
{
   string certfile = System.IO.Path.Combine(Environment.ExpandEnvironmentVariable??s("%HOME%"), @"site\wwwroot\<functionname>\mykeyfile.pfx"); 

    X509Certificate2 cert = new X509Certificate2(certfile, "<myinsanepwd>");

    return true; //temporary 
}
Run Code Online (Sandbox Code Playgroud)

行X509Certificate2 cert = new X509Certificate2(certfile,""); 抛出异常System.Security.Cryptography.CryptographicException:系统找不到指定的文件.

这真的很奇怪,因为文件存在于指定的路径上(我在方法中使用File.Exists()检查:))这个错误可能与support.microsoft.com/en-us/kb/948154有关吗?我怎么解决这个问题?

此致,Jens

c# azure azure-functions

5
推荐指数
1
解决办法
3024
查看次数

标签 统计

azure ×1

azure-functions ×1

c# ×1