I was excited to hear about the v12 Azure databases supporting CLR assemblies. Mainly because I’ve been doing testing work with tSQLt and wanted to run tests in an Azure database.
I upgraded a SQL Azure database to v12 and connected in SSMS. My first step was to open the tSQLt file.
I had the file open, connected to Azure. This was the easy part. Now I need to actually send the batch across and compile the code:
My next step was to execute it. However that didn’t work as well as I expected.
There are multiple errors here, but it’s possible that one error causes others. I pinged Sebastian Meine, the creator of tSQLt about the External_Access and he noted there was only one method that needs it.
So I decided to make a change. First, a search.
That got me the assembly installation.
I decided to try and change this to something that’s contained inside the database. Since Azure is a bit of a black box, I thought safe was the way to go.
With that change made, I compiled the entire file again. This was the only change I made.
That’s cool, but does it work? I connected in Object Explorer and then opened SQL Test. I saw my database, and I could create a test.
However I got an error on the connection and creation of a procedure.
Even from Object Explorer, I refreshed the procedures, but got this:
This appears to be a SQL Server 2014 RTM error. Actually I was on a CU, but not SP1. It is supposed to be corrected in SP1.
However the procedure was created, and I could alter it.
More importantly, I can execute it.
If I change the code.
Now it fails.
It appears that tSQLt can now work in v12 databases in Azure, so start adding those unit tests to your database projects.