Azure Bastion Session Recording – Blob Container URI not configurable via ARM/Bicep/CLI

Vladimir Bannikov 25 Reputation points
2026-05-15T18:58:42.3733333+00:00

We are automating Azure Bastion deployment and session recording configuration using Azure CLI/ARM APIs.

We successfully automated:

  • Azure Bastion Premium creation
  • Session recording enablement
  • System-assigned managed identity
  • Storage account/container creation
  • RBAC assignment (Storage Blob Data Contributor)

However, we cannot automate the final “Blob Container URI” configuration required for session recording storage.

Is there a supported ARM/Bicep/CLI/REST method to configure the Session Recording Blob Container URI for Azure Bastion using Managed Identity?

Azure Bastion
Azure Bastion

An Azure service that provides private and fully managed Remote Desktop Protocol (RDP) and Secure Shell (SSH) access to virtual machines.


Answer accepted by question author

Vallepu Venkateswarlu 10,430 Reputation points Microsoft External Staff Moderator
2026-05-15T20:36:11.25+00:00

Hi @ Vladimir Bannikov,

As there is currently no official Microsoft documents available for this configuration, you can use the below Bicep template to update the Blob Container URI in Azure Bastion Session Recording .

/**
  * Example Bastion Host template for session recording with managed identities
  *
  * Key points:
  *  - Api Version must be 2025-01-01 or later to support session recording with managed identities
  *  - Identity must be assigned to the bastion
  *  - sessionRecordingConfiguration.identity.type must match the identity.type of the bastion
  *  - sessionRecordingConfiguration.identity.userAssignedIdentityId must be provided if using user assigned identities
  *  - sessionRecordingConfiguration.blobContainerUri must be provided
  *  - sessionRecordingConfiguration.identity.userAssignedIdentityId must be present in the identity.userAssignedIdentities of the bastion if using user assigned identities
*/
resource bastionHost 'Microsoft.Network/bastionHosts@2025-01-01' = {
  name: 'bastionName'
  sku: {
    name: 'Premium'
  }
  location: resourceGroup().location
  properties: {
    enableIpConnect: false
    enableTunneling: false
    enableShareableLink: false
    enableKerberos: false
    disableCopyPaste: false
    enableSessionRecording: true
    ipConfigurations: [
      {
        name: 'IpConf'
        properties: {
          subnet: {
            id: azureBastionSubnetId
          }
          publicIPAddress: {
            id: bastionPublicIpAddress.id
          }
        }
      }
    ]
    scaleUnits: 2
    enablePrivateOnlyBastion: false
    sessionRecordingConfiguration: {
      identity: {
        type: 'UserAssigned' // Must match the identity type of the bastion host
        userAssignedIdentityId: '<your user assigned identity resource ID>' // Replace with your user assigned identity resource ID, omit if system assigned
      }
      blobContainerUri: 'https://<your storage account name>.blob.core.windows.net/<your container name>' // Replace values
    }
  }
  identity: {
    type: 'UserAssigned' // Must match the identity type of the bastion host
    userAssignedIdentities: {
      '<your user assigned identity resource ID>': {} // Replace with your user assigned identity resource ID
    }
  }
}
 

I would recommend using user assigned identities and making sure the identity has permissions before deploying.

REST API's

https://management.azure.com/subscriptions/<subid>/resourceGroups/<rg-name>/providers/Microsoft.Network/bastionHosts/<bastion-name>/setsessionrecordingsasurl?api-version=<api-version>


https://management.azure.com/subscriptions/<subid>/resourceGroups/<rg-name>/providers/Microsoft.Network/bastionHosts/<bastion-name>/getsessionrecordingsasurl?api-version=<api-version>

For both requests, please use the following configuration:

  • HTTP Method: POST
  • Authorization Header: Bearer Token

The request body should be configured as follows:

{
  sasUrl: "some-sas-url"
}

Please210246-screenshot-2021-12-10-121802.pngand “up-vote” wherever the information provided helps you, this can be beneficial to other community members.

Was this answer helpful?

1 person found this answer helpful.
0 comments No comments

1 additional answer

Sort by: Most helpful
  1. AI answer

    2026-05-15T18:58:55.5933333+00:00

    There is no documented or supported way in the provided content to configure the Azure Bastion Session Recording Blob Container URI via ARM template, Bicep, CLI, or REST when using managed identity.

    The documentation only describes configuring the Blob Container URI interactively in the Azure portal:

    1. Enable the system-assigned managed identity on the Bastion resource and assign the Storage Blob Data Contributor role on the target storage account/container.
    2. In the Bastion resource, go to ConfigurationSession Recording Configuration.
    3. Select System Assigned Managed Identity and enter the Blob Container URI for the storage container.

    No programmatic interface (ARM/Bicep/CLI/REST) for setting this Blob Container URI is described in the available documentation.


    References:

    AI-generated content may be incorrect. Read our transparency notes for more information.

    Was this answer helpful?

Your answer

Answers can be marked as 'Accepted' by the question author and 'Recommended' by moderators, which helps users know the answer solved the author's problem.