Batch pool with user assigned Managed Identity and Key Vault extension
On Feb 29th, 2024, the certificate feature in Azure Batch Account will be retired. To continue using the certificate with Batch task, user will need to migrate the Batch account certificates to Azure Key Vault. But since there is not an existing example provided, that might be a little difficult.
This blog will mainly focus on providing an example about how to recreate the Batch pool with required user assigned Managed Identity and Key Vault extension. Currently the Batch pool with user assigned Managed Identity and extension is only supported by ARM template and REST API call. Creating a pool with extension is unsupported in Azure Portal. Creating a pool with user assigned Managed Identity is unsupported in Az PowerShell module and Azure CLI.
Pre-requisite:
To follow this blog, please prepare the following points:
- A Batch Account
- A Key Vault
- Upload the certificates which was saved in Batch Account/Certificate, into Key Vault/Certificates
- A user assigned Managed Identity (The msiClientId in ARM template and REST API payload is the client ID of this Managed Identity)
- Assign enough permission to get the certificate from Key Vault on the user assigned Managed Identity (You can also use RBAC assignment to allow permission in Key Vault)
Reminder:
In this blog, a sample Batch pool with the only necessary setup is created. If any additional feature is needed, please kindly modify the related part in ARM/bicep template or REST API request payload.
The pool created in this blog contains the following properties:
- OS: Windows Server 2019 Datacenter with latest version
- Node Agent: batch.node.windows amd64
- Key Vault extension version 3.0: Install one certificate with thumbprint FDBB….F3A0 into LocalMachine/My certificate store
- Scale: 1 fixed dedicated node
- VM SKU: standard_ds2_v2
The expected result:
Created pool’s node can be in a healthy status:
And if we RDP into the node, we should be able to see the expected certificate saved into LocalMachine/My path:
Sample REST API call: (The parts in red need to be replaced by own resource information)
HTTP method: PUT
URL: https://management.azure.com/subscriptions/{subscription ID}/resourceGroups/{resource group name}/providers/Microsoft.Batch/batchAccounts/{batch account name}/pools/{pool name}?api-version=2023-11-01
Request headers: Authorization header with Microsoft Entra ID authentication Bearer token is required. Please refer to this document, or just simply search for API Playground in Azure Portal. The second way is easier because it will automatically generate the Authorization header.
Request body:
{
"identity": {
"type": "UserAssigned",
"userAssignedIdentities": {
"/subscriptions/5102xxxx-xxxx-xxxx-xxxx-xxxxa4473453/resourceGroups/Batch/providers/Microsoft.ManagedIdentity/userAssignedIdentities/usedbybatch": {}
}
},
"properties": {
"vmSize": "STANDARD_DS2_V2",
"deploymentConfiguration": {
"virtualMachineConfiguration": {
"imageReference": {
"publisher": "microsoftwindowsserver",
"offer": "windowsserver",
"sku": "2019-datacenter",
"version": "latest"
},
"nodeAgentSkuId": "batch.node.windows amd64",
"extensions": [
{
"name": "KeyVaultExtension",
"type": "KeyVaultForWindows",
"publisher": "Microsoft.Azure.KeyVault",
"typeHandlerVersion": "3.0",
"autoUpgradeMinorVersion": true,
"enableAutomaticUpgrade": true,
"settings": {
"secretsManagementSettings": {
"pollingIntervalInS": "300",
"linkOnRenewal": true,
"requireInitialSync": true,
"observedCertificates": [
{
"url": "https://batchusermode.vault.azure.net/secrets/classiccs ",
"certificateStoreName": "My",
"certificateStoreLocation": "LocalMachine",
"accounts": ["Network Service", "Local Service"],
"keyExportable": true
}
]
},
"authenticationSettings": {
"msiEndpoint": "http://169.254.169.254/metadata/identity/oauth2/token",
"msiClientId": "58eaxxxx-xxxx-xxxx-xxxx-xxxxf2d41227"
}
}
}
]
}
},
"scaleSettings": {
"fixedScale": {
"targetDedicatedNodes": 1,
"targetLowPriorityNodes": 0
}
}
}
}
Sample ARM template: (The parts in red need to be replaced by own resource information.)
Attention! According to the ARM template rule, to deploy a Batch pool which is child resource type, we must give the Batch Account name in the name property as well. The name here should be {BatchAccountName}/{PoolName}.
{
"$schema": "https://schema.management.azure.com/schemas/2015-01-01/deploymentTemplate.json#",
"contentVersion": "1.0.0.0",
"parameters": {},
"resources": [
{
"name": "jerrybatchmode/MIwithKVextARM",
"apiVersion": "2023-11-01",
"type": "Microsoft.Batch/batchAccounts/pools",
"identity": {
"type": "UserAssigned",
"userAssignedIdentities": {
"/subscriptions/5102xxxx-xxxx-xxxx-xxxx-xxxxa4473453/resourceGroups/Batch/providers/Microsoft.ManagedIdentity/userAssignedIdentities/usedbybatch": {}
}
},
"properties": {
"vmSize": "STANDARD_DS2_V2",
"deploymentConfiguration": {
"virtualMachineConfiguration": {
"imageReference": {
"publisher": "microsoftwindowsserver",
"offer": "windowsserver",
"sku": "2019-datacenter",
"version": "latest"
},
"nodeAgentSkuId": "batch.node.windows amd64",
"extensions": [
{
"name": "KeyVaultExtension",
"type": "KeyVaultForWindows",
"publisher": "Microsoft.Azure.KeyVault",
"typeHandlerVersion": "3.0",
"autoUpgradeMinorVersion": true,
"enableAutomaticUpgrade": true,
"settings": {
"secretsManagementSettings": {
"pollingIntervalInS": "300",
"linkOnRenewal": true,
"requireInitialSync": true,
"observedCertificates": [
{
"url": "https://batchusermode.vault.azure.net/secrets/classiccs ",
"certificateStoreName": "My",
"certificateStoreLocation": "LocalMachine",
"accounts": [ Network Service", Local Service" ],
"keyExportable": true
}
]
},
"authenticationSettings": {
"msiEndpoint": "http://169.254.169.254/metadata/identity/oauth2/token",
"msiClientId": "58eaxxxx-xxxx-xxxx-xxxx-xxxxf2d41227"
}
}
}
]
}
},
"scaleSettings": {
"fixedScale": {
"targetDedicatedNodes": 1,
"targetLowPriorityNodes": 0
}
}
}
}
]
}
Published on:
Learn moreRelated posts
Azure Storage - TLS 1.0 and 1.1 retirement
Overview TLS 1.0 and 1.1 retirement on Azure Storage was previously announced for Nov 1st, 2024, and it was postponed recently to 1 year later...
Efficient Management of Append and Page Blobs Using Azure Storage Actions
Overview In Azure Storage, Blob Lifecycle Management (BLM) allows you to automate the management of your data based on rules defined by...
[Azure AI Search] Internal Server Error when creating CMK encrypted objects
Scenario Customers follow the Microsoft doc to create CMK encrypted objects (data source, index etc.), but get the 500 Internal Serv...
Optimizing Azure Table Storage: Automated Data Cleanup using a PowerShell script with Azure Automate
Scenario This blog’s aim is to manage Table Storage data efficiently. Imagine you have a large Azure Table Storage that accumulates logs from ...
Optimizing Azure Table Storage: Automated Data Clean-up using a PowerShell script with Azure Automat
Scenario This blog’s aim is to manage Table Storage data efficiently. Imagine you have a large Azure Table Storage that accumulates logs from ...
Restoring Soft-Deleted Blobs with multithreading in Azure Storage Using C#
Blob soft delete is an essential feature that safeguards your data against accidental deletions or overwrites. By retaining deleted data for a...
Performing simple Azure Table Storage REST API operations using curl command.
The blog provides guidance to perform simple Table Storage REST API operations such as Create table, Delete Table, Insert entity, Delete entit...
Bulk delete all the old jobs from the batch account
Deleting a Job also deletes all Tasks that are part of that Job, and all Job statistics. This also overrides the retention period for Task dat...
Utilizing Azure Storage and Runbooks for scheduled automated backups of Azure SQL Databases
In this article, we are going to provide detailed steps to create a scheduled Azure SQL Database backup to storage account using automation. T...
[Azure Service Bus] JMS messages getting dead-lettered
The article discusses a problem where numerous messages end up in the dead letter queue (DLQ) when the JMS service bus consumer connects to th...