I have created a SQLCLR UDF and am deploying it (using SSDT) to SQL Server 2019 on Linux. When I try to execute the function it returns the following error:
Request for the permission of type 'System.Net.WebPermission, System, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089' failed.
The SQLCLR UDF is calling a web API.
SQL Server on Linux, for whatever reason (likely not a good one, or at least not a good reason anymore), only allows SAFE code (i.e. code that can execute when the assembly has
PERMISSION_SET
set toSAFE
. This means no code that reaches outside of the database, either for file system, network (including http, ftp, etc), etc.