Azure Function gives error: System.Drawing is not supported on this platform

It’s not about the CLR, it’s about the sandbox.

System.Drawing relies heavily on GDI/GDI+ to do its thing. Because of the somewhat risky nature of those APIs (large attack surface) they are restricted in the App Service sandbox.

Win32k.sys (User32/GDI32) Restrictions

For the sake of radical attack surface area reduction, the sandbox prevents almost all of the Win32k.sys APIs from being called, which practically means that most of User32/GDI32 system calls are blocked. For most applications this is not an issue since most Azure Web Apps do not require access to Windows UI functionality (they are web applications after all).

Try to find an different library that doesn’t rely on System.Drawing/GDI, like ImageSharp.

Leave a Comment