How to enable MSI (Managed Service Identity) for Batch compute nodes in User Subscription Mode
Published Nov 30 2020 01:25 AM 4,880 Views


Currently we can enable Azure Managed Identity to use platform-managed keys or customer-managed keys to encrypt the customer data which is stored in Azure Batch: However, the managed identity on the Batch account is not available on the compute nodes. There was an active feature request submitted to Azure Batch team and Azure Active Directory team asking for supporting MSI in Azure Batch environment: The implementation of this feature has begun but there is no ETA at this time. As an optional plan,  we could enable MSI for compute nodes in user subscription mode which means that user would need to manage his own Virtual Machine Scale Sets (VMSS) and those nodes are in MSI enabled environment.



In user subscription mode, customer can enable MSI for compute nodes directly by their own. Please note the following limitations:

  1. Right now this optional plan is only valid when the pool allocation mode is user subscription which means all the compute nodes are going to be provisioned in your subscription. Please check this document for the details:
  2. When these Batch VMs are provisioned every time,  for example, Batch Service creates a new Virtual Machine Scale Sets due to some scale out activity, you are required to enable the MSI manually. You can do it via Portal, PowerShell or REST API .


  • Prepare an Azure Batch account with User Subscription mode




  1. Create a new pool in the Batch account, the VMSS will be added to your subscription in a different resource group.



  1. Access to the resource group and select VMSS.


  1. Access to the VMSS and select the Identity tab to enable the MSI. This document provides more information about enabling system-assigned managed identify and user-assigned managed identity:


  1. You will be able to modify the role assignments. In my example, I assigned Owner role of subscription in the Azure role assignments.


  1. RDP to the VMSS to test if the MSI works or not. Now I can get the token to list the information of my resource group. This document lists the PowerShell command that I used in this example:


$response = Invoke-WebRequest -Uri '' -Method GET -Headers @{Metadata=”true”}

$content = $response.Content | ConvertFrom-Json

$ArmToken = $content.access_token

(Invoke-WebRequest -Uri '' -Method GET -ContentType "application/json" -Headers @{ Authorization="Bearer $ArmToken"}).content


Version history
Last update:
‎Nov 30 2020 01:27 AM
Updated by: