0

I would like to convert my windows services to Azure web jobs. Currently my windows service does the following tasks

  1. It connects to the database and fetches data (using entity framework)
  2. It creates a PDF using wkhtmltopdf exe and saves it to the folder.
  3. This PDF which is saved in the folder will be sent to the customer by email

Is it possible to achieve the above mentioned tasks in Azure web jobs? If not are there any other alternatives to accomplish this?

Golda
  • 3,823
  • 10
  • 34
  • 67
  • 2
    Yes, it can achieve in webjob.First, [SQL Database access from a WebJob in Azure](https://stackoverflow.com/questions/24941001/sql-database-access-from-a-webjob-in-azure). Second,use [run.cmd](https://stackoverflow.com/questions/32821347/azure-webjob-multiple-executables) to run whatever exe you want. Third, [use Sendgrid to send email](https://www.vivien-chevallier.com/Articles/how-to-send-emails-with-sendgrid-in-azure-webjobs-using-the-sendgrid-extension). – Joey Cai Jun 13 '18 at 07:11
  • How is this job triggered? by a schedule? a possible alternative would be creating a container and use Azure Container Instances. Might be cheaper than using a web job for which you have to pay using an app service plan. – Peter Bons Jun 13 '18 at 07:27

1 Answers1

1

This is possible, but most probably not with your current setup.

The problem you are hitting is not in running an exe, it's something specific to wkhtml2pdf.exe itself. That exe uses a bunch of GDI+ calls on Windows for rendering the PDF and that is what's not allowed in Azure Websites sandbox (the GDI+ calls, not running an exe).

More details here: Process.Start in Azure Website

If you use a PDF NuGet package that doesn't do GDI+ you're good to go.

EDIT:
OK, I missed this one. Like the article @joey-cai refers to (Azure websites and wkhtmltopdf ) states:

Running wkhtmltopdf is now supported in Azure Web Apps - just make sure you are using Basic, Standard, or Premium App Service Plan. Consumption Service Plan and Free App Service Plan have a more limited sandbox and are NOT supported in my testing. MS confirms supportability of wkhtmltopdf in Azure Web Apps.

rickvdbosch
  • 14,105
  • 2
  • 40
  • 53
  • 1
    According to [WebApp sandbox](https://github.com/projectkudu/kudu/wiki/Azure-Web-App-sandbox#unsupported-frameworks), now wkhtmltopdf is supported. `Rotativa / wkhtmltopdf: requires the site to run in Basic or higher`. – Tom Sun - MSFT Jun 13 '18 at 07:13
  • 1
    Refer to [Azure websites and wkhtmltopdf](https://stackoverflow.com/questions/28682110/azure-websites-and-wkhtmltopdf) – Joey Cai Jun 13 '18 at 07:15