Question

In an ASP.net MVC 5 WebRole I`m using MaxMind Geo IP Database whose API use a string like this:

  var reader = new DatabaseReader    (@"C:\Users\User\Source\Workspaces\myproject\Contents\db.mmdb");

It needs a full physical path, a relative path does not work. The question is: deploying the WebRole in the cloud, how can I have retrieve the database?

Entering via remote connection in the instance, I can see that the file is there and the path is:

var reader = new DatabaseReader(@"E:\sitesroot\0\Contents\db.mmdb");

But this does not work and I have an exception Could not find file 'E:\sitesroot\0\Contents\db.mmdb'.

How can I do? Should I use a BLOB? The database needs to be fast accessible since it could be called hundreds of millions of times a day, I do not know if the BLOB can support these amount of simultaneous connections, so I prefer to have it in the VM instance. Thanks

Was it helpful?

Solution

Using a file based DB in a CloudService WebRole is a really bad idea - every time you deploy the WebRole, the DB will get overwritten. There is no easy way to guarantee concurrency. That said, it would be better to use Azure Sql or MySql (or any other database not subject to being overwritten every time you deploy new code. The BLOB is OK for file storage, but not dynamic DBs and the size limitations will get you into trouble as well.

To access files in the contents folder though, see this SO post.

Path.Combine(AppDomain.CurrentDomain.BaseDirectory, "Contents");
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top