title: Azure Function Create Word Document
body: <p>(.NetCore/C#)
  I am trying to create an Azure Function that will be triggered when changes are made in CosmosDB. The goal of the function is to generate a report word document file based on data from CosmosDB. The current way I am approaching this task is to use DocX library to generate the word file. I managed to create a test file that can create a local file and upload it to Azure storage. However, when I tried to apply it to my main Azure Function code I realized that I do not have a place to store the word document file that I want to generate and upload to Azure Storage. Is there a way around this issue?</p>
  
  <p><div class="snippet" data-lang="js" data-hide="false" data-console="true" data-babel="false">
  <div class="snippet-code">
  <pre class="snippet-code-html lang-html prettyprint-override"><code>static void Main(string[] args)
  {
  
      string Directory = @"C:\Project";
      string Filename = @"\report.docx";
      string FilenamePath = Directory + Filename;
  
      var Doc = DocX.Create(FilenamePath);
  
      Formatting Format = new Formatting();
      Format.FontFamily = new Font("Gotham Office");  
      Format.Size = 18;
      Format.FontColor = System.Drawing.Color.Black;
      Format.Bold = true;
  
      string Text = "Text";
      Doc.InsertParagraph(Text, false, Format);
  
      Doc.Save();
      try
      {
          Process.Start("WINWORD.EXE", FilenamePath);
      }
      catch (Win32Exception e)
      {
      }
      SaveToBlob(FilenamePath);
  }
  public static void SaveToBlob(string FilenamePath)
  {
      CloudStorageAccount storageAccount = CloudStorageAccount.Parse("Connection String");
      CloudBlobClient blobClient = storageAccount.CreateCloudBlobClient();
      CloudBlobContainer container = blobClient.GetContainerReference("report");
      CloudBlockBlob blockBlob = container.GetBlockBlobReference("report.docx");
      using (var fileStream = System.IO.File.OpenRead(FilenamePath))
      {
          blockBlob.UploadFromStream(fileStream);
      }
  }</code></pre>
  </div>
  </div>
  </p>
  
  <p>Another concern I have for this current approach is that it is using WINWORD.EXE, which I am afraid might not work with the Azure Function Environment. Are there any better libraries that I should use for the task?</p>