2
votes

For my task I'm using locally persisted data. Until now I've successfully used Path.GetTempPath() to get temp folder and persist data there and perform some computations. The temp folder is on the system drive which is not big enough (around 30GB). I'm using VM with 1000GB HDD.

I'd like to write data to the big C:\ drive instead, but it throws an exception: Access to the path 'C:\whatever_the_path_is' is denied. when I try to access it.

I see that the tasks run under PoolNonAdmin[some-digits] user that obviously doesn't have sufficient permissions.

Are there any special APIs to use local storage with Azure Batch tasks?

EDIT: I'm familiar with %AZ_BATCH_NODE_SHARED_DIR% but for specific reasons I can't use it.

2

2 Answers

2
votes

You can use Azure Batch defined environment variables for paths that refer to the ephemeral disk. For example, %AZ_BATCH_TASK_WORKING_DIR% will target the current task's working directory (and is writable by whatever user the task is running as). Or the %AZ_BATCH_NODE_SHARED_DIR% variable will reference the shared directory path that will always be on the ephemeral disk; all users (for which tasks are run under, be it pool admin, non-admin or ephemeral task users) can write to this directory. You can view all of the environment variables defined by Azure Batch here.

1
votes

I've found a solution here: https://docs.microsoft.com/en-us/azure/batch/batch-user-accounts

In my case, it was to assign the task elevated UserIdentity like this:

task.UserIdentity = new UserIdentity(new AutoUserSpecification(elevationLevel: ElevationLevel.Admin, scope: AutoUserScope.Pool));