tSQLt tests from Visual Studio with Azure SQL
Hi I followed the tutorial and it seems this is not applicable for Azure SQL because Azure SQL doesn't support/allow CLR assemblies. I get below errors while setting up the tests project. First while attempting to enabling clr and second while attempting to import test cases from development db by clicking refresh.
Error1:
EXEC sp_configure 'clr enabled', 1;
RECONFIGURE;
Error: Msg 40510, Level 16, State 1, Line 24
(when I comment/remove the code the shadow db fails. So I handled it by adding a condition. However it fails during refreshing the project with below error message.)
Error2:
I wonder if I need to do any other steps for working with Azure SQL. Please help.
Error1:
EXEC sp_configure 'clr enabled', 1;
RECONFIGURE;
Error: Msg 40510, Level 16, State 1, Line 24
Statement 'CONFIG' is not supported in this version of SQL Server
(when I comment/remove the code the shadow db fails. So I handled it by adding a condition. However it fails during refreshing the project with below error message.)
Error2:
Msg 10343, Level 14, State 1, Server XXXXX\LOCALDB#969D222D, Line 1
CREATE or ALTER ASSEMBLY for assembly 'tSQLtCLR' with the SAFE or EXTERNAL_ACCESS option failed because the 'clr strict security' option of sp_configure is set to 1. Microsoft recommends that you sign the assembly with a certificate or asymmetric key that has a corresponding login with UNSAFE ASSEMBLY permission. Alternatively, you can trust the assembly using sp_add_trusted_assembly.
I wonder if I need to do any other steps for working with Azure SQL. Please help.
Tagged:
Best Answer
-
Alex B Posts: 1,158 Diamond 4You don't actually need to enable CLR assemblies to get tSQLt working - tSQLt is allowed by Microsoft on Azure SQL databases - see https://github.com/tSQLt-org/tSQLt/issues/36 and also the quickstart guide from tSQLt https://tsqlt.org/user-guide/quick-start/
There is https://www.sqlservercentral.com/blogs/tsqlt-in-azure-sql-database which goes through getting tSQLt set up in Azure SQL to be able to use SQL Test with it, which may help.