Can't access to Azure Storage folder using Lucene.Net -


we decided implement search functionality in our api developed in servicestack, decided use lucene.net since heard great indexer make searches.

we created worker role job create indexes in azure storage folder, guided ourselves using leon cullen's tutorial. use azuredirectory library specified in post, use latest azure sdk.

then in our api project added references lucene.net , azuredirectory too, our endpoint ended looking this:

    public object post(searchindex request)     {                     list<product> products = new list<product>();          var pagesize = -1;         var totalpages = -1;         int.tryparse(configurationmanager.appsettings["pagesize"], out pagesize);          if (request.page.equals(0))         {              request.page = 1;         }          // azure settings         azuredirectory azuredirectory ;          try         {             // line access denied exception thrown @             azuredirectory = new azuredirectory(microsoft.windowsazure.storage.cloudstorageaccount.parse(configurationmanager.appsettings["connectionstringazuresearch"]), "indexsearch");               indexsearcher searcher;             using (new autostopwatch("creating searcher"))             {                 searcher = new indexsearcher(azuredirectory);             }              using (new autostopwatch(string.format("search {0}", request.searchstring)))             {                 string[] searchfields = new string[] { "id", "name", "description" };                  var hits = searcher.search(querymaker(request.searchstring, searchfields), request.page * pagesize);                  int count = hits.scoredocs.count();                 float temp_totalpages = 0;                 temp_totalpages = (float)hits.scoredocs.count() / (float)pagesize;                  if (temp_totalpages > (int)temp_totalpages)                 {                     totalpages = (int)temp_totalpages + 1;                 }                 else                 {                     totalpages = (int)temp_totalpages;                 }                  foreach (scoredoc match in hits.scoredocs)                 {                     document doc = searcher.doc(match.doc);                      int producid = int.parse(doc.get("id"));                      product product = db.select<product>("id={0}", producid).firstordefault();                      products.add(product);                 }              }              return new searchindexresult { result = products.skip((int)((request.page - 1) * 10)).take(pagesize).tolist(), pagesize = pagesize, totalpages = totalpages };         }         catch (exception e)         {              return new httpresult(httpstatuscode.nocontent, "azuredirectory. parameter: " + request.searchstring + ". e: " + e.message);         }        } 

if run locally works expected, returning results expecting. when published our api azure , tried access search endpoint received 403 error message message 'access path "d:/azuredirectory" denied".

we're confused why trying access such folder @ all, name of folder wrong , think it's trying access local route, don't know why work fine locally once it's deployed azure stops working.

the worker role runs without problems, it's api side cannot access folder in azure storage. missing important step in configuration? tutorial followed wasn't clear beginners using lucene.net or azure storage fear might have missed important step. we've checked our connection strings , seems ok though.

as reference: https://github.com/azure-contrib/azuredirectory/blob/master/azuredirectory/azuredirectory.cs

when this

azuredirectory = new azuredirectory(microsoft.windowsazure.storage.cloudstorageaccount.parse(configurationmanager.appsettings["connectionstringazuresearch"]), "indexsearch");  

this executes

var cachepath = path.combine(path.getpathroot(environment.systemdirectory), "azuredirectory"); var azuredir = new directoryinfo(cachepath); if (!azuredir.exists)     azuredir.create();  var catalogpath = path.combine(cachepath, _containername); var catalogdir = new directoryinfo(catalogpath); if (!catalogdir.exists)     catalogdir.create();  _cachedirectory = fsdirectory.open(catalogpath); 

so simple solution might have directory on site root

directoryinfo info = new directoryinfo(hostingenvironment.mappath("~/")); azuredirectory = new azuredirectory(storageaccount, containername, new simplefsdirectory(info), true); 

Comments

Popular posts from this blog

how to proxy from https to http with lighttpd -

android - Automated my builds -

python - Flask migration error -