DocumentFormat.openxml, похоже, не работает с функциями Azure - PullRequest
1 голос
/ 03 июля 2019

Я пытался интегрировать пакет openxml в функцию Azure.Код компилируется нормально, но когда я пытаюсь добраться до функции url, он не загружает файл, но не выполняет вызов, и в коде нет ошибки выполнения.

public static async Task<HttpResponseMessage> Run([HttpTrigger(AuthorizationLevel.Function, "get", "post", Route = null)]HttpRequestMessage req, TraceWriter log, [Inject]TrainingManager trainingManager)
    {

        //dynamic data = await req.Content.ReadAsAsync<object>();
        //string trainingCourseId = data?.trainingCourseId;
        log.Info("Function App Started");
        HttpResponseMessage response = req.CreateResponse(HttpStatusCode.OK);
        using (MemoryStream mem = new MemoryStream())
        {
            // Create Document
            using (WordprocessingDocument wordDocument =
                WordprocessingDocument.Create(mem, WordprocessingDocumentType.Document, true))
            {
                // Add a main document part. 
                MainDocumentPart mainPart = wordDocument.AddMainDocumentPart();

                // Create the document structure and add some text.
                mainPart.Document = new DocumentFormat.OpenXml.Wordprocessing.Document();
                Body docBody = new Body();

                // Add your docx content here
                Paragraph para = docBody.AppendChild(new Paragraph());
                Run run = para.AppendChild(new Run());
                run.AppendChild(new Text("Hi"));

                mainPart.Document.Save();
            }
            mem.Seek(0, SeekOrigin.Begin);
            response.Content = new StreamContent(mem);

        }

        response.Content.Headers.ContentDisposition = new System.Net.Http.Headers.ContentDispositionHeaderValue("attachment")
        {
            FileName = "AttendanceList.docx"
        };
        response.Content.Headers.ContentType = new System.Net.Http.Headers.MediaTypeHeaderValue("application/msword");

        log.Info("Sending Response");
        return response;
    }

Дайте мне знать, если кто-нибудь сталкивалсяЭта проблема или есть решение.

Вот что я вижу на вкладке сети ![enter image description here] 1 Спасибо!

enter image description here

...