Where in the file system is a Worker Role's Local Storage?

本小妞迷上赌 提交于 2020-01-16 15:21:10

问题


I've created a log file in a Worker Role, which is being stored in Local Storage. Where in the file system of the instance can I find that log now? IOW, where is the root of Local Storage for a worker role?


回答1:


To find the path of the local storage, you can use LocalResource.RootPath. This will give you the full directory path of the local storage resource.

For example:

try 
{

    LocalResource myConfigsStorage = RoleEnvironment.GetLocalResource("local-resource-setting-name");

    string s = System.IO.File.ReadAllText(myConfigStorage.RootPath + "myFile.txt"); 
    //… do your work with s 
} 
catch (Exception myException) 
{ 
    …    
}

Please look under C:\Resources directory in the Azure VM running your Worker Role and you should be able to find the log file you created. Please note that Azure SDK creates folders inside this directory for your worker role instance id and deployment id.



来源:https://stackoverflow.com/questions/48486033/where-in-the-file-system-is-a-worker-roles-local-storage

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!