RoleManager GetLocalResource
- Hi,
I am trying to copy files from blob storage and cache them in the localstorage. I am using RoleManager.GetLocalResource("webstorage"). I have defined "webstorage" as localstorage inside the service definition file. I have a very simple web page with the code below in the Page_Load. This all works fine locally against the development fabric. It reports the folder exists. When I publish the project to the live ctp the page says the folder doesnt exist. It reports the path as "Folder: C:\Resources\directory\81adf70899784875ab2cee208bec78ee.WebRole.webstorage\".
Can anyone tell me if I need to initialise the localstorage somehow or if it works at all on the live system?
Regards
David
ILocalResource
myIO = RoleManager.GetLocalResource("webstorage");
Response.Write("Role Manager running: " + RoleManager.IsRoleManagerRunning.ToString() + "<br/>");
Response.Write("Folder: " + myIO.RootPath + "<br/>");
Response.Write("Exists: " + Directory.Exists(myIO.RootPath).ToString());
All Replies
- Hello, this scenario works fine for me in the cloud. One possible cause is you haven't done any actual IO. Looks like the directory is created the first time you put some files into it. Try to create some files. You can also try to run your role in full trust.
Lante, shanaolanxing This posting is provided "AS IS" with no warranties, and confers no rights. I have tried creating a file before testing to see if the folder exists and it still doesnt work. Below is the code for a very simple test page. On the development fabric it returns true for all the Directory.Exists and File.Exists. In the cloud both the Directory.Exists return false. The File.Exists returns true. It makes no sense to me. As far as I was aware if it runs on the development fabric it should run in the cloud. The web role is running in full trust.
ILocalResource
myIO = RoleManager.GetLocalResource("webstorage");
Response.Write("Folder: " + myIO.RootPath + "<br/>");
Response.Write("Exists: " + Directory.Exists(myIO.RootPath).ToString() + "<br/><br/>");
string PathToFile = Path.Combine(myIO.RootPath, "init.xml");
StreamWriter writer = File.CreateText(PathToFile);
writer.Write("<init></init>");
writer.Flush();
writer.Close();
Response.Write("File: " + Path.Combine(myIO.RootPath, "init.xml") + "<br/>");
Response.Write("File exists: " + File.Exists(Path.Combine(myIO.RootPath, "init.xml")) + "<br/><br/>");
Response.Write("Folder: " + myIO.RootPath + "<br/>");
Response.Write("Exists: " + Directory.Exists(myIO.RootPath).ToString() + "<br/>");


