Search code examples
azure-batch

Batch Environment Variables returning null


I am trying to use the Batch service-defined environment variables, but I keep getting a null error. Similar to what I saw in the samples, I am trying to get the jobID for a job that I created through Azure portal as follows:

private readonly string jobID = Environment.GetEnvironmentVariable("AZ_BATCH_JOB_ID");

But jobID returns null. Why so? What am I missing here?

Thanks!


Solution

  • Azure Batch environment variables set on the compute node are only set when the task executes and is not set for remotely logged in users (since there is no job/task context for a remotely logged in user).