Shaul Behr
Shaul Behr

Reputation: 38033

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

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?

Upvotes: 1

Views: 733

Answers (1)

Gaurav Mantri
Gaurav Mantri

Reputation: 136306

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.

Upvotes: 4

Related Questions