Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/csharp/312.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
C# Azure是否支持NReco pdf生成器?_C#_Azure_Azure Functions - Fatal编程技术网

C# Azure是否支持NReco pdf生成器?

C# Azure是否支持NReco pdf生成器?,c#,azure,azure-functions,C#,Azure,Azure Functions,我已经为pdf生成创建了一个C#Azure函数,并且正在使用NReco pdf生成器,但它在Aazure上不起作用 你能建议一种方法让它在azure中运行吗 我已通过NuGet Package Manager控制台安装了NReco Pdf generator,出现以下错误: “对路径“D:\Program Files(x86)\SiteExtensions\Functions\1.0.12599\wkhtmltopdf”的访问被拒绝 这是引发的异常的堆栈跟踪: at System.IO.__Er

我已经为pdf生成创建了一个C#Azure函数,并且正在使用NReco pdf生成器,但它在Aazure上不起作用

你能建议一种方法让它在azure中运行吗

我已通过NuGet Package Manager控制台安装了NReco Pdf generator,出现以下错误:

“对路径“D:\Program Files(x86)\SiteExtensions\Functions\1.0.12599\wkhtmltopdf”的访问被拒绝

这是引发的异常的堆栈跟踪:

at System.IO.__Error.WinIOError(Int32 errorCode, String maybeFullPath)
at System.IO.Directory.InternalCreateDirectory(String fullPath, String path, Object dirSecurityObj, Boolean checkHost)
at System.IO.Directory.InternalCreateDirectoryHelper(String path, Boolean checkHost)
at System.IO.Directory.CreateDirectory(String path)
at NReco.PdfGenerator.HtmlToPdfConverter.EnsureWkHtmlLibs()
at NReco.PdfGenerator.HtmlToPdfConverter.GeneratePdfInternal(WkHtmlInput[] htmlFiles, String inputContent, String coverHtml, String outputPdfFilePath, Stream outputStream)
at NReco.PdfGenerator.HtmlToPdfConverter.GeneratePdfFromFile(String htmlFilePath, String coverHtml)
at VRProductions.Repository.PdfGenerationRepository.<SendMail>d__1.MoveNext()

我可以使用以下函数代码生成pdf..看看这是否有帮助..Azure函数V1

using System.IO;
using System.Linq;
using System.Net;
using System.Net.Http;
using System.Net.Http.Headers;
using System.Threading.Tasks;
using Microsoft.Azure.WebJobs;
using Microsoft.Azure.WebJobs.Extensions.Http;
using Microsoft.Azure.WebJobs.Host;

namespace FunctionApp41
{
    public static class Function1
    {
        [FunctionName("Function1")]
        public static async Task<HttpResponseMessage> Run([HttpTrigger(AuthorizationLevel.Function, "get", "post", Route = null)]HttpRequestMessage req, TraceWriter log)
        {
            log.Info("C# HTTP trigger function processed a request.");


            var htmlToPdf = new NReco.PdfGenerator.HtmlToPdfConverter();
            var pdfBytes = htmlToPdf.GeneratePdfFromFile("<file_path_including_sas_token>", "");

            var response = req.CreateResponse(HttpStatusCode.OK);
            response.Content = new StreamContent(new MemoryStream(pdfBytes));
            response.Content.Headers.ContentType = new MediaTypeHeaderValue("application/pdf");

            return response;
        }
    }
}

“无法工作”不是问题的技术描述这与我使用的相同,但我仍然收到此错误。请查看此错误。我尝试了此错误,但仍然无法工作。我将在Azure上尝试。我尚未尝试在Azure上部署
using System.IO;
using System.Linq;
using System.Net;
using System.Net.Http;
using System.Net.Http.Headers;
using System.Threading.Tasks;
using Microsoft.Azure.WebJobs;
using Microsoft.Azure.WebJobs.Extensions.Http;
using Microsoft.Azure.WebJobs.Host;

namespace FunctionApp41
{
    public static class Function1
    {
        [FunctionName("Function1")]
        public static async Task<HttpResponseMessage> Run([HttpTrigger(AuthorizationLevel.Function, "get", "post", Route = null)]HttpRequestMessage req, TraceWriter log)
        {
            log.Info("C# HTTP trigger function processed a request.");


            var htmlToPdf = new NReco.PdfGenerator.HtmlToPdfConverter();
            var pdfBytes = htmlToPdf.GeneratePdfFromFile("<file_path_including_sas_token>", "");

            var response = req.CreateResponse(HttpStatusCode.OK);
            response.Content = new StreamContent(new MemoryStream(pdfBytes));
            response.Content.Headers.ContentType = new MediaTypeHeaderValue("application/pdf");

            return response;
        }
    }
}
http://localhost:7071/api/Function1