I'm looking to use DbGeography via EntityFramework communicating with a SQL Server database, within an Azure Worker Role. As I understand it, DbGeography uses Microsoft.SqlServer.Types / SqlServerSpatial110.dll in the background, so in order to get it to work in Azure, I've followed:
http://blogs.msdn.com/b/adonet/archive/2013/12/09/microsoft-sqlserver-types-nuget-package-spatial-on-azure.aspx and installed the nuget package, then I've specified loading the SQL Server types in the OnStart method in WorkerRole.cs:
public override bool OnStart()
{
// Load SQL Server Types
SqlServerTypes.Utilities.LoadNativeAssemblies(AppDomain.CurrentDomain.BaseDirectory);
I also then followed this blogpost https://alastaira.wordpress.com/2011/08/19/spatial-applications-in-windows-azure-redux-including-denali/ where I explicitly added SqlServerSpatial110.dll to the project and set it to Copy always.
So the real issue is - immediately after deployment, everything works as expected. However, if I leave the Azure Worker role alone for a bit (~30 mins) and it receives no requests, the DbGeography portions of my code no longer function.
- Is there something else I need to do?
- Have I put the LoadNativeAssemblies call in the wrong place (should it be on Run() ?)
- Do Azure Worker Roles get recycled?
- Has anyone come across this before / managed to use DbGeography with an Azure Worker Role, or have any insight as to what might be happening?