Use NetOffice.PowerPointApi on azure app service

109 views Asked by At

I have written a code to save all the slides in a presentation as jpeg. It works well in visual studio locally on my system, but when I deploy it on Azure app service, I get 500 internal server error.

  • IIS received the request; however, an internal error occurred during the processing of the request. The root cause of this error depends on which module handles the request and what was happening in the worker process when this error occurred.
  • IIS was not able to access the web.config file for the Web site or application. This can occur if the NTFS permissions are set incorrectly.
  • IIS was not able to process configuration for the Web site or application.
  • The authenticated user does not have permission to use this DLL.
  • The request is mapped to a managed handler but the .NET Extensibility Feature is not installed.
  • The code:

    using pptd = NetOffice.PowerPointApi;
    using NetOffice.PowerPointApi.Enums;
    using NetOffice.OfficeApi.Enums;
    
     public void genThumbnails(string originalfileName,string renamedFilename, string dirPath)
                {
                
                    
                    pptd.Application pptApplication = new pptd.Application();
                    pptd.Presentation pptPresentation = pptApplication.Presentations.Open(dirPath + renamedFilename, MsoTriState.msoFalse, MsoTriState.msoFalse, MsoTriState.msoFalse);
                    int i = 0;
                    foreach (pptd.Slide pptSlide in pptPresentation.Slides)
                    {
    
                        pptSlide.Export(dirPath + originalfileName + "_slide" + i + ".jpg", "jpg", 1280, 720);
                        i++;
    
    
                    }
                    pptPresentation.Close();
                }
    

    What is the mistake that I am doing? Does NetOffice package also need MS Office installed on the server like Office.Interop?

    1

    There are 1 answers

    1
    Bryan Trach-MSFT On BEST ANSWER

    The standard windows and Linux web apps used blessed operating system images. As part of the PaaS design, customers are limited as to what they can run as there is no MS Office inter-op present and also because Azure Web Apps is a sandbox.

    My suggestion would be to create a container image that has the necessary dependencies that you need and then deploy your custom container to an Azure Web App Container.