# Azure Blob Storage Message Body Storage Azure Blob Storage saves message bodies in a blob container. Set `ServiceControl/MessageBody/StorageType` on an Error instance, or `ServiceControl.Audit/MessageBody/StorageType` on an Audit instance, to `AzureBlob` when the instance uses [SQL Server](/servicecontrol/storage/sqlserver/index.md) or [PostgreSQL](/servicecontrol/storage/postgresql/index.md) storage. ## Authentication Azure Blob Storage supports two mutually exclusive authentication methods. Configure exactly one: - **Connection string** — authenticates with shared key or shared access signature (SAS) credentials. - **Service URI with Microsoft Entra credentials** — authenticates using the Azure SDK's `DefaultAzureCredential`, which can use managed identity. Set `ManagedIdentityClientId` to select a user-assigned managed identity. ## Required settings ### ServiceControl/MessageBody/Azure/ConnectionString _Added in version 7.0.0_ The Azure Storage connection string used to authenticate with shared key or shared access signature (SAS) credentials when `MessageBody/StorageType` is `AzureBlob`. Configure either this setting or `ServiceControl/MessageBody/Azure/ServiceUri`, but not both. | Context | Name | | --- | --- | | **Environment variable** | `SERVICECONTROL_MESSAGEBODY_AZURE_CONNECTIONSTRING` | | **App config key** | `ServiceControl/MessageBody/Azure/ConnectionString` | | **SCMU field** | N/A | | Type | Default value | | --- | --- | | string | None | ### ServiceControl.Audit/MessageBody/Azure/ConnectionString _Added in version 7.0.0_ The Azure Storage connection string used to authenticate with shared key or shared access signature (SAS) credentials when `MessageBody/StorageType` is `AzureBlob`. Configure either this setting or `ServiceControl.Audit/MessageBody/Azure/ServiceUri`, but not both. | Context | Name | | --- | --- | | **Environment variable** | `SERVICECONTROL_AUDIT_MESSAGEBODY_AZURE_CONNECTIONSTRING` | | **App config key** | `ServiceControl.Audit/MessageBody/Azure/ConnectionString` | | **SCMU field** | N/A | | Type | Default value | | --- | --- | | string | None | ### ServiceControl/MessageBody/Azure/ServiceUri _Added in version 7.0.0_ The Azure Blob Storage service URI used with managed identity when `MessageBody/StorageType` is `AzureBlob`. Configure either this setting or `ServiceControl/MessageBody/Azure/ConnectionString`, but not both. | Context | Name | | --- | --- | | **Environment variable** | `SERVICECONTROL_MESSAGEBODY_AZURE_SERVICEURI` | | **App config key** | `ServiceControl/MessageBody/Azure/ServiceUri` | | **SCMU field** | N/A | | Type | Default value | | --- | --- | | string | None | ### ServiceControl.Audit/MessageBody/Azure/ServiceUri _Added in version 7.0.0_ The Azure Blob Storage service URI used with managed identity when `MessageBody/StorageType` is `AzureBlob`. Configure either this setting or `ServiceControl.Audit/MessageBody/Azure/ConnectionString`, but not both. | Context | Name | | --- | --- | | **Environment variable** | `SERVICECONTROL_AUDIT_MESSAGEBODY_AZURE_SERVICEURI` | | **App config key** | `ServiceControl.Audit/MessageBody/Azure/ServiceUri` | | **SCMU field** | N/A | | Type | Default value | | --- | --- | | string | None | `ServiceUri` must be an absolute URI. ## Optional settings ### ServiceControl/MessageBody/Azure/ContainerName _Added in version 7.0.0_ The Azure Blob Storage container used to store message bodies. | Context | Name | | --- | --- | | **Environment variable** | `SERVICECONTROL_MESSAGEBODY_AZURE_CONTAINERNAME` | | **App config key** | `ServiceControl/MessageBody/Azure/ContainerName` | | **SCMU field** | N/A | | Type | Default value | | --- | --- | | string | `error-bodies` | ### ServiceControl.Audit/MessageBody/Azure/ContainerName _Added in version 7.0.0_ The Azure Blob Storage container used to store message bodies. Every Audit instance has the same default, so set a different container name for each Audit instance that uses the same storage account. The exception is Audit instances that [share a database](/servicecontrol/audit-instances/scaling-out-ingestion.md#sql-storage-shared-database), which must all use the same container. | Context | Name | | --- | --- | | **Environment variable** | `SERVICECONTROL_AUDIT_MESSAGEBODY_AZURE_CONTAINERNAME` | | **App config key** | `ServiceControl.Audit/MessageBody/Azure/ContainerName` | | **SCMU field** | N/A | | Type | Default value | | --- | --- | | string | `audit-bodies` | > [!WARNING] > Audit instances with different retention periods must use separate containers, even when they share an Azure Storage account. Audit instances use the same default container name, so explicitly configure a different `ServiceControl.Audit/MessageBody/Azure/ContainerName` for each instance. Retention cleanup deletes blobs by time prefix across the container. An instance with shorter retention can delete bodies that another instance still needs, leaving message records visible but their bodies unavailable. ### ServiceControl/MessageBody/Azure/ManagedIdentityClientId _Added in version 7.0.0_ The client ID of the user-assigned managed identity used to access Azure Blob Storage. When this setting is not specified, the default Azure credential chain is used. | Context | Name | | --- | --- | | **Environment variable** | `SERVICECONTROL_MESSAGEBODY_AZURE_MANAGEDIDENTITYCLIENTID` | | **App config key** | `ServiceControl/MessageBody/Azure/ManagedIdentityClientId` | | **SCMU field** | N/A | | Type | Default value | | --- | --- | | string | None | ### ServiceControl.Audit/MessageBody/Azure/ManagedIdentityClientId _Added in version 7.0.0_ The client ID of the user-assigned managed identity used to access Azure Blob Storage. When this setting is not specified, the default Azure credential chain is used. | Context | Name | | --- | --- | | **Environment variable** | `SERVICECONTROL_AUDIT_MESSAGEBODY_AZURE_MANAGEDIDENTITYCLIENTID` | | **App config key** | `ServiceControl.Audit/MessageBody/Azure/ManagedIdentityClientId` | | **SCMU field** | N/A | | Type | Default value | | --- | --- | | string | None | ### ServiceControl/MessageBody/Azure/AuthorityHost _Added in version 7.0.0_ The Microsoft Entra authority host URI used for managed identity authentication in sovereign clouds. When this setting is not specified, the Azure SDK uses the `AZURE_AUTHORITY_HOST` environment variable or its default authority host. | Context | Name | | --- | --- | | **Environment variable** | `SERVICECONTROL_MESSAGEBODY_AZURE_AUTHORITYHOST` | | **App config key** | `ServiceControl/MessageBody/Azure/AuthorityHost` | | **SCMU field** | N/A | | Type | Default value | | --- | --- | | string | None | ### ServiceControl.Audit/MessageBody/Azure/AuthorityHost _Added in version 7.0.0_ The Microsoft Entra authority host URI used for managed identity authentication in sovereign clouds. When this setting is not specified, the Azure SDK uses the `AZURE_AUTHORITY_HOST` environment variable or its default authority host. | Context | Name | | --- | --- | | **Environment variable** | `SERVICECONTROL_AUDIT_MESSAGEBODY_AZURE_AUTHORITYHOST` | | **App config key** | `ServiceControl.Audit/MessageBody/Azure/AuthorityHost` | | **SCMU field** | N/A | | Type | Default value | | --- | --- | | string | None | ## Setup and runtime Setup creates the configured container if it does not exist. The identity used for setup needs permission to create the container, and the runtime identity needs read, write, and delete permissions on blobs in the container: - **Service URI with Microsoft Entra ID:** assign the `Storage Blob Data Contributor` role on the storage account, or on the container if it is created in advance. This role covers both setup and normal operation. - **Connection string:** the account key, or the shared access signature's permissions, must allow creating the container during setup, and reading, writing, and deleting blobs at runtime. Setup always sends a create request, even when the container already exists, so a SAS scoped to a single container cannot be used for setup; use the account key or an account SAS that allows creating containers. The retention sweeper deletes body blobs before removing the corresponding database records. Set these variables in the instance's environment to use a connection string. Replace the account and credential placeholders with values supplied by the deployment environment: ```text SERVICECONTROL_MESSAGEBODY_STORAGETYPE=AzureBlob SERVICECONTROL_MESSAGEBODY_AZURE_CONNECTIONSTRING="DefaultEndpointsProtocol=https;AccountName=storageaccount;AccountKey=..." ``` Example environment variables using a service URI with managed identity: ```text SERVICECONTROL_MESSAGEBODY_STORAGETYPE=AzureBlob SERVICECONTROL_MESSAGEBODY_AZURE_SERVICEURI=https://storageaccount.blob.core.windows.net ``` Audit instances use the same settings with the `SERVICECONTROL_AUDIT_` prefix. Set a container name for each Audit instance that uses the same storage account, except Audit instances that [share a database](/servicecontrol/audit-instances/scaling-out-ingestion.md#sql-storage-shared-database): ```text SERVICECONTROL_AUDIT_MESSAGEBODY_STORAGETYPE=AzureBlob SERVICECONTROL_AUDIT_MESSAGEBODY_AZURE_SERVICEURI=https://storageaccount.blob.core.windows.net SERVICECONTROL_AUDIT_MESSAGEBODY_AZURE_CONTAINERNAME=audit-bodies-instance1 ``` See the [external message body storage overview](/servicecontrol/storage/external-body/index.md) for shared configuration, retention, and backup guidance.