1
votes

Got an Azure Function that is supposed to call the context to update the values of DbGeography. I keep getting this exception:

Spatial types and functions are not available for this provider because the assembly 'Microsoft.SqlServer.Types' version 10 or higher could not be found.

I installed the NuGet package in the Azure Function project. Currently, the Azure Function is not published, I run it locally. It would be nice to solve these issues, even when the function is deployed.

1

1 Answers

2
votes

According to your error message, I suppose your issue is about when you try to deploy to a machine that does not have the CLR Types for SQL Server installed.

You said you have installed the Nuget package, so I suggest you could also check whether the appropriate version of the native SqlServerSpatial110.dll assembly is copied to the output directory and deployed with your application. For more details about this issue, you could refer to this article.

You could also check whether you have installed the Microsoft System CLR Types. Fore more details ,you could read this SO thread.

After a lot of research I just installed "Microsoft System CLR Types for SQL Server 2012" from:

X86 - http://go.microsoft.com/fwlink/?LinkID=239643&clcid=0x409

X64 - http://go.microsoft.com/fwlink/?LinkID=239644&clcid=0x409

Worked like a charm!

Besides, If I use SqlGeography in Microsoft.SqlServer.Types package, it works fine on my side:

The code in Azure function:

enter image description here

The result in Azure portal:

enter image description here