Search code examples
c#.netazureazure-batch

How to create Azure Batch Job with AutoPool and Managed Identity


CAVEAT: THIS APP USES .NET FRAMEWORK 4.7

I am familiar with the need to use Microsoft.Azure.Management.Batch for creating batch pools with managed identity: see: https://learn.microsoft.com/en-us/azure/batch/managed-identity-pools

We have code that creates a job with Microsoft.Azure.Batch library and also creates an AutoPool see: https://learn.microsoft.com/en-us/azure/batch/nodes-and-pools#autopools

var poolInformation = new PoolInformation
{
    AutoPoolSpecification = new AutoPoolSpecification
    {
        AutoPoolIdPrefix = this.autoPoolIdPrefix,
        PoolLifetimeOption = PoolLifetimeOption.Job,
        PoolSpecification = GetPoolSpec(),
        KeepAlive = false
    }
};
job = batchClient.JobOperations.CreateJob(autoPoolJobId, poolInformation);

is there a way to create this job with a batch pool that uses a managed identity?


Solution

  • Microsoft Azure Batch API does not allow to assign Managed Identity to an Autopool. Or if it does then it is not documented nor implemented in the client libraries.

    This functionality is also not supported out of the box by the client for regular Azure Batch Pool's. To achieve this, one needs to craft a json file based on the json used inside of the portal, and use advanced methods to post it. See question How do I specify a managed service identity when creating an Azure Batch Pool via the Azure CLI?

    I also don't know if underneath the Autopool is same as regular Pool and if it supports managed identities at all.