Loading...

Batch pool with user assigned Managed Identity and Key Vault extension

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:

JerryZhangMS_0-1708057692831.png

 

JerryZhangMS_1-1708057692836.png

 

 

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:

JerryZhangMS_2-1708057692840.png

 

And if we RDP into the node, we should be able to see the expected certificate saved into LocalMachine/My path:

JerryZhangMS_3-1708057692853.png

 

JerryZhangMS_4-1708057692867.png

 

 

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.

JerryZhangMS_5-1708057692869.png

 

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 more
Azure PaaS Blog articles
Azure PaaS Blog articles

Azure PaaS Blog articles

Share post:

Related 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...

1 year ago

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...

1 year ago

[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...

1 year ago

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 ...

1 year ago

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 ...

1 year ago

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...

1 year ago

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...

1 year ago

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...

1 year ago

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...

2 years ago

[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...

2 years ago

Newsletter

Get the latest Dynamics 365 and Power Platform content in your inbox

A curated digest of community blogs, product news, videos, and podcasts — delivered without the noise.

Weekly updates Unsubscribe anytime Fresh community picks
We use your email only for the newsletter and you can unsubscribe at any time.
By subscribing, you agree to the privacy policy.