问题
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