You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: docs/relational-databases/security/ledger/ledger-digest-management.md
+42-11Lines changed: 42 additions & 11 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -1,7 +1,7 @@
1
1
---
2
2
title: "Digest management"
3
3
description: This article provides information on digest management for a ledger database.
4
-
ms.date: "05/24/2022"
4
+
ms.date: "07/22/2022"
5
5
ms.service: sql-database
6
6
ms.subservice: security
7
7
ms.custom:
@@ -30,15 +30,46 @@ The verification process and the integrity of the database depend on the integri
30
30
### Automatic generation and storage of database digests
31
31
32
32
> [!NOTE]
33
-
> Automatic generation and storage of database digests is currently available in Azure SQL Database, but not supported on SQL Server.
33
+
> Automatic generation and storage of database digests in SQL Server only supports Azure Storage accounts.
34
34
35
35
Ledger integrates with the [immutable storage feature of Azure Blob Storage](/azure/storage/blobs/immutable-storage-overview) and [Azure Confidential Ledger](/azure/confidential-ledger/index). This integration provides secure storage services in Azure to help protect the database digests from potential tampering. This integration provides a simple and cost-effective way for users to automate digest management without having to worry about their availability and geographic replication. Azure Confidential Ledger has a stronger integrity guarantee for customers who might be concerned about privileged administrators access to the digest. [This table](/azure/architecture/guide/technology-choices/multiparty-computing-service#confidential-ledger-and-azure-blob-storage) compares the immutable storage feature of Azure Blob Storage with Azure Confidential Ledger.
36
36
37
-
You can configure automatic generation and storage of database digests through the Azure portal, PowerShell, or the Azure CLI. For more information, see [Enable automatic digest storage](ledger-how-to-enable-automatic-digest-storage.md). When you configure automatic generation and storage, database digests are generated on a predefined interval of 30 seconds and uploaded to the selected storage service. If no transactions occur in the system in the 30-second interval, a database digest won't be generated and uploaded. This mechanism ensures that database digests are generated only when data has been updated in your database. When the endpoint is an Azure Blob Storage, the database server will create a new container, named **sqldbledgerdigests** and use a naming pattern like:
38
-
ServerName/DatabaseName/CreationTime. The creation time is needed because a database with the same name can be dropped and recreated or restored, allowing for different “incarnations” of the database under the same name. See [Digest Management Considerations](ledger-digest-management.md)
37
+
You can configure automatic generation and storage of database digests through the Azure portal, PowerShell, or the Azure CLI. For more information, see [Enable automatic digest storage](ledger-how-to-enable-automatic-digest-storage.md). When you configure automatic generation and storage, database digests are generated on a predefined interval of 30 seconds and uploaded to the selected storage service. If no transactions occur on the system in the 30-second interval, a database digest won't be generated and uploaded. This mechanism ensures that database digests are generated only when data has been updated in your database. When the endpoint is an Azure Blob Storage, the Azure SQL database server will create a new container, named **sqldbledgerdigests** and use a naming pattern like:
38
+
ServerName/DatabaseName/CreationTime. The creation time is needed because a database with the same name can be dropped and recreated or restored, allowing for different “incarnations” of the database under the same name. See [Digest Management Considerations](ledger-digest-management.md).
39
39
40
-
> [!IMPORTANT]
41
-
> If you use Azure Blob Storage, configure an [immutability policy](/azure/storage/blobs/immutable-policy-configure-version-scope) on your container after provisioning to ensure that database digests are protected from tampering.
40
+
> [!NOTE]
41
+
> For SQL Server, the container needs to be created manually by the user.
42
+
43
+
#### Azure Storage Account Immutability Policy
44
+
45
+
If you use an Azure Storage account for the storage of the database digests, configure an [immutability policy](/azure/storage/blobs/immutable-policy-configure-version-scope) on your container after provisioning to ensure that database digests are protected from tampering. Make sure the immutability policy allows protected append writes to append blobs and that the policy is locked.
46
+
47
+
#### Azure Storage account permission
48
+
49
+
If you use **Azure SQL Database**, make sure that your logical server (System Identity) has sufficient RBAC permissions to write digests by adding it to the [Storage Blob Data Contributor](/azure/role-based-access-control/built-in-roles#storage-blob-data-contributor) role.
50
+
51
+
If you use **SQL Server**, you have to create a shared access signature (SAS) key on the digest container to allow SQL Server to connect and authenticate against the Azure Storage account.
52
+
53
+
- Create a container on the Azure Storage account, named **sqldbledgerdigests**.
54
+
- Create a policy on a container with the *Read*, *Add*, *Create*, *Write*, and *List* permissions, and generate a shared access signature key.
55
+
- For each container used for digest file storage, create a [SQL Server credential](/sql/relational-databases/security/authentication-access/credentials-database-engine) whose name matches the container path.
56
+
57
+
The following example assumes that an Azure Storage container, a policy, and a SAS key have been created. This is needed by SQL Server to access the digest files in the container.
58
+
59
+
In the following code snippet, replace `<your SAS key>` with the SAS key. The SAS key will look like `'sr=c&si=<MYPOLICYNAME>&sig=<THESHAREDACCESSSIGNATURE>'`.
If you use **Azure SQL Database**, make sure that your logical server (System Identity) has sufficient RBAC permissions to write digests by adding it to the **Contributor** role.
70
+
71
+
> [!NOTE]
72
+
> Automatic generation and storage of database digests in SQL Server only supports Azure Storage accounts.
42
73
43
74
### Manual generation and storage of database digests
44
75
@@ -64,19 +95,19 @@ The returned result set is a single row of data. It should be saved to the trust
64
95
```
65
96
66
97
## Digest management considerations
67
-
> [!NOTE]
68
-
> This section only applies to Azure SQL Database, and not SQL Server.
69
98
70
99
### Database restore
71
100
72
-
Restoring the database back to an earlier point in time, also known as [Point in Time Restore](/azure/azure-sql/database/recovery-using-backups#point-in-time-restore), is an operation frequently used when a mistake occurs and users need to quickly revert the state of the database back to an earlier point in time. When uploading the generated digests to Azure Storage or Azure Confidential Ledger, the *create time* of the database is captured that these digests map to. Every time the database is restored, it's tagged with a new *create time* and this technique allows us to store the digests across different “incarnations” of the database. Ledger preserves the information regarding when a restore operation occurred, allowing the verification process to use all the relevant digests across the various incarnations of the database. Additionally, users can inspect all digests for different create times to identify when the database was restored and how far back it was restored to. Since this data is written in immutable storage, this information will be protected as well.
101
+
Restoring the database back to an earlier point in time, also known as [Point in Time Restore](/azure/azure-sql/database/recovery-using-backups#point-in-time-restore), is an operation frequently used when a mistake occurs and users need to quickly revert the state of the database back to an earlier point in time. When uploading the generated digests to Azure Storage or Azure Confidential Ledger, the *create time* of the database is captured that these digests map to. Every time the database is restored, it's tagged with a new *create time* and this technique allows us to store the digests across different “incarnations” of the database. For SQL Server, the *create time* is the current UTC time when the digest upload is enabled for the first time. Ledger preserves the information regarding when a restore operation occurred, allowing the verification process to use all the relevant digests across the various incarnations of the database. Additionally, users can inspect all digests for different create times to identify when the database was restored and how far back it was restored to. Since this data is written in immutable storage, this information will be protected as well.
73
102
74
-
### Active geo-replication
103
+
### Active geo-replication and Always On Availability Groups
75
104
76
-
Replication across geographic regions is asynchronous for performance reasons and, thus, allows the secondary database to be slightly behind compared to the primary. In the event of a geographic failover, any latest data that hasn't yet been replicated is lost. Ledger will only issue database digests for data that has been replicated to geographic secondaries to guarantee that digests will never reference data that might be lost in case of a geographic failover. This only applies for automatic generation and storage of database digests.
105
+
Active geo-replication can be configured for an Azure SQL Database. Replication across geographic regions is asynchronous for performance reasons and, thus, allows the secondary database to be slightly behind compared to the primary. In the event of a geographic failover, any latest data that hasn't yet been replicated is lost. Ledger will only issue database digests for data that has been replicated to geographic secondaries to guarantee that digests will never reference data that might be lost in case of a geographic failover. This only applies for automatic generation and storage of database digests.
77
106
78
107
Dropping the link between the primary and the secondaries when ledger digests are configured isn't supported. You should first disable the *Enable automatic digest storage* database setting, remove the synchronization between the primary and the secondary and re-enable the *Enable automatic digest storage* database setting.
79
108
109
+
When your database is part of an Always On Availability Group in SQL Server, the same principle as active geo-replication is used. The upload of the digests is only done if all transactions have been replicated to the secondary replicas.
In this article, we'll describe how you can configure automatic generation and storage of database digests through the Azure portal, PowerShell, or the Azure CLI.
22
25
23
26
## Prerequisites
@@ -79,6 +82,35 @@ az sql db ledger-digest-uploads enable \
79
82
```
80
83
81
84
---
85
+
::: zone-end
86
+
87
+
::: zone pivot="as1-sql-server"
88
+
89
+
In this article, we'll describe how you can configure automatic generation and storage of database digests through using T-SQL in **SQL Server 2022**. For information on configuring automatic generation and storage of database digests in Azure SQL Database, use the switch at the top of this page to toggle over to Azure SQL Database.
90
+
91
+
## Prerequisites
92
+
93
+
- SQL Server 2022
94
+
-[SQL Server Management Studio (SSMS)](/sql/ssms/download-sql-server-management-studio-ssms) or [Azure Data Studio](/sql/azure-data-studio/download-azure-data-studio)
95
+
- An Azure Blob Storage
96
+
- An Azure Storage container
97
+
- A [SQL Server credential](/sql/relational-databases/security/authentication-access/credentials-database-engine). For more information, see [Digest Management](ledger-digest-management.md).
98
+
99
+
## Enable database digest uploads using T-SQL
100
+
101
+
To enable uploading ledger digests, specify the endpoint of an Azure Blob storage account. To disable uploading ledger digests, set the option value to `OFF`. The default is `OFF`.
102
+
103
+
1. Sign into your SQL Server 2022 instance using SSMS or Azure Data Studio.
104
+
1. Configure automatic generation and storage of database digests using the following T-SQL statement:
105
+
106
+
```sql
107
+
ALTERDATABASE SCOPED CONFIGURATION
108
+
SET LEDGER_DIGEST_STORAGE_ENDPOINT ='https://mystorage.blob.core.windows.net';
109
+
```
110
+
111
+
For more information, see [ALTER DATABASE SCOPED CONFIGURATION (Transact-SQL)](/sql/t-sql/statements/create-database-transact-sql).
[!INCLUDE [SQL Server 2022 Azure SQL Database](../../../includes/applies-to-version/sqlserver2022-asdb.md)]
19
+
20
+
::: zone pivot="as1-azure-sql-database"
21
+
22
+
You can monitor failed and successful ledger digest uploads in the [Azure portal](https://portal.azure.com) in the **Metrics** view of your Azure SQL Database.
23
+
24
+
:::image type="content" source="media/ledger/monitor-ledger-digest-uploads.png" alt-text="Metrics view of the Azure SQL Database failed and successful ledger digest uploads in the Azure portal.":::
25
+
26
+
::: zone-end
27
+
28
+
::: zone pivot="as1-sql-server"
29
+
30
+
You can monitor failed and successful ledger digest uploads with [Extended Events](../../extended-events/extended-events.md) in SQL Server. Select the events *ledger_digest_upload_failed* and *ledger_digest_upload_success* in the Extended Event session.
31
+
32
+
::: zone-end
33
+
34
+
## Digest upload alerts recommendation
35
+
36
+
::: zone pivot="as1-azure-sql-database"
37
+
38
+
We recommend you configure alerts on failed ledger digest uploads if you want to be notified when a digest upload failed. Failures might occur due to revoked permissions on the storage account or network configuration that makes the storage account inaccessible. Optionally, you could also configure an alert on successful ledger digest uploads. If the number of successful ledger digest uploads drops under a certain value or zero due to someone disabling the automatic digest upload, the alert can help raise attention to this matter. Digest uploads that are explicitly disabled wouldn't be considered a failure in this case.
39
+
40
+
::: zone-end
41
+
42
+
::: zone pivot="as1-sql-server"
43
+
44
+
We recommend you configure an alert on event number *37417 - Uploading ledger digest failed*. The alert can be configured using [SQL Agent Alert](../../../ssms/agent/create-an-alert-using-an-error-number.md) or your favorite third-party monitoring tool.
0 commit comments