Skip to content

Commit 6ce4f1f

Browse files
authored
Merge SQL Server 2022 CU 17 release branch (#32847)
1 parent 539cad3 commit 6ce4f1f

35 files changed

Lines changed: 415 additions & 73 deletions

File tree

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
---
2+
author: VanMSFT
3+
ms.author: vanto
4+
ms.date: 01/16/2025
5+
ms.service: azure-vm-sql-server
6+
ms.topic: include
7+
---
8+
9+
[!INCLUDE [applies-md](applies-md.md)] :::image type="icon" source="../media/applies-to/yes-icon.svg" border="false"::: [SQL Server on Azure VM (Windows only)](/sql/sql-server/sql-docs-navigation-guide#applies-to)

azure-sql/includes/appliesto-sqlvm.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
author: WilliamDAssafMSFT
33
ms.author: wiassaf
44
ms.date: 07/21/2023
5-
ms.service: azure-sql-database
5+
ms.service: azure-vm-sql-server
66
ms.topic: include
77
---
88

azure-sql/toc.yml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1712,6 +1712,10 @@
17121712
href: virtual-machines/windows/azure-key-vault-integration-configure.md
17131713
- name: Migrate storage to Ultradisk
17141714
href: virtual-machines/windows/storage-migrate-to-ultradisk.md
1715+
- name: Backup and restore using managed identities
1716+
href: virtual-machines/windows/backup-restore-to-url-using-managed-identities.md
1717+
- name: EKM with AKV using managed identities
1718+
href: virtual-machines/windows/managed-identity-extensible-key-management.md
17151719
- name: SQL IaaS Agent extension
17161720
displayName: resource provider, registration, sql vm rp
17171721
items:
Lines changed: 133 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,133 @@
1+
---
2+
title: Backup and restore to URL using managed identities
3+
description: Learn how to back up and restore SQL Server databases to Azure Blob storage using managed identities for SQL Server on Azure VMs.
4+
author: GithubMirek
5+
ms.author: mireks
6+
ms.reviewer: vanto, mathoma
7+
ms.date: 01/16/2025
8+
ms.service: azure-vm-sql-server
9+
ms.subservice: security
10+
ms.topic: how-to
11+
---
12+
# Backup and restore to URL using managed identities
13+
14+
[!INCLUDE [appliesto-sqlvm-windows-only](../../includes/appliesto-sqlvm-windows-only.md)]
15+
16+
This article teaches you to back up to and restore [SQL Server on Azure Virtual Machines (VM)](sql-server-on-azure-vm-iaas-what-is-overview.md) databases from a URL by using Microsoft Entra managed identities.
17+
18+
## Overview
19+
20+
Starting with SQL Server 2022 Cumulative Update 17 (CU17), you can use managed identities with [SQL Server credentials](/sql/t-sql/statements/create-credential-transact-sql) to back up to and restore SQL Server on Azure VM databases from Azure Blob storage. [Managed identities](/entra/identity/managed-identities-azure-resources/overview) provide an identity for applications to use when connecting to resources that support Microsoft Entra authentication.
21+
22+
Using managed identities in the credentials for the `BACKUP TO URL` and `RESTORE FROM URL` T-SQL operations is only supported by SQL Server on Azure VMs. Using managed identities with SQL Server on-premises to `BACKUP TO URL` and `RESTORE FROM URL` isn't supported.
23+
24+
## Prerequisites
25+
26+
- A SQL Server on Azure VM with SQL Server 2022 CU17 or later, [configured with Microsoft Entra authentication](configure-azure-ad-authentication-for-sql-vm.md).
27+
- An [Azure Blob storage account](/azure/storage/common/storage-account-create).
28+
- Valid network access to the Azure Blob storage and Windows Firewall permissions on the host to allow the outbound connection, and valid storage account service endpoints.
29+
- The primary managed identity for the SQL Server on Azure VM needs:
30+
- To be assigned with a user-assigned managed identity or system-assigned managed identity. For more information, see [Configure managed identities on Azure virtual machines (VMs)](/entra/identity/managed-identities-azure-resources/how-to-configure-managed-identities).
31+
- To have the `Storage Blob Data Contributor` role for the primary managed identity assigned to the storage account.
32+
33+
## Create a server credential using managed identities
34+
35+
In order to use the T-SQL commands `BACKUP DATABASE <database name> TO URL` and `RESTORE <database name> FROM URL` with managed identities, you need to create a server credential that uses the managed identity. The credential name represents the Azure storage URL and indicates where the database backup will be stored.
36+
37+
The following example shows how to create a credential for a managed identity:
38+
39+
```sql
40+
CREATE CREDENTIAL [https://<storage-account-name>.blob.core.windows.net/<container-name>]
41+
WITH IDENTITY = 'Managed Identity'
42+
```
43+
44+
The `WITH IDENTITY = 'Managed Identity'` clause requires a primary managed identity assigned to the SQL Server on Azure VM.
45+
46+
For more information on error messages that can occur if the primary managed identity isn't assigned or given proper permissions, see the [Error messages](#error-messages) section.
47+
48+
## `BACKUP` to URL with a managed identity
49+
50+
After you create the credential, you can use it to back up and restore databases to Azure Blob storage. Make sure that the primary managed identity for the SQL Server on Azure VM has the `Storage Blob Data Contributor` role assigned to the storage account.
51+
52+
The following example shows how to back up a database to Azure Blob storage using the managed identity credential:
53+
54+
```sql
55+
BACKUP DATABASE [AdventureWorks]
56+
TO URL = 'https://<storage-account-name>.blob.core.windows.net/<container-name>/AdventureWorks.bak'
57+
```
58+
59+
## `RESTORE` from URL with a managed identity
60+
61+
The following example shows how to restore a database from Azure Blob storage using the managed identity credential:
62+
63+
```sql
64+
RESTORE DATABASE [AdventureWorks]
65+
FROM URL = 'https://<storage-account-name>.blob.core.windows.net/<container-name>/AdventureWorks.bak'
66+
```
67+
68+
## Error messages
69+
70+
[Trace flag 4675](/sql/t-sql/database-console-commands/dbcc-traceon-trace-flags-transact-sql#tf4675) can be used to check credentials created with a managed identity. If the `CREATE CREDENTIAL` statement was executed without trace flag 4675 enabled, no error message is issued if the primary managed identity isn't set for the server. To troubleshoot this scenario, the credential must be deleted and recreated again once the trace flag is enabled.
71+
72+
### No primary managed identity assigned
73+
74+
If a primary managed identity isn't assigned to the SQL Server on Azure VM, the backup and restore operations will fail with an error message indicating that the managed identity isn't selected.
75+
76+
```sql
77+
Msg 37563, Level 16, State 2, Line 14
78+
The primary managed identity is not selected for this server. Enable the primary managed identity for Microsoft Entra authentication for this server. For more information see (https://aka.ms/sql-server-managed-identity-doc).`
79+
```
80+
81+
### No `Storage Blob Data Contributor` role assigned
82+
83+
If the primary managed identity for the SQL Server on Azure VM isn't given the `Storage Blob Data Contributor` role to the storage account, the **BACKUP** operation will fail with an error message indicating that access is denied.
84+
85+
```sql
86+
Msg 3201, Level 16, State 1, Line 31
87+
Cannot open backup device 'https://<storage-account-name>.blob.core.windows.net/<container-name>/AdventureWorks.bak'. Operating system error 5(Access is denied.).
88+
Msg 3013, Level 16, State 1, Line 31
89+
BACKUP DATABASE is terminating abnormally.
90+
```
91+
92+
If the managed identity for the SQL Server on Azure VM isn't given the `Storage Blob Data Contributor` role to the storage account, the **RESTORE** operation will fail with an error message indicating that access is denied.
93+
94+
```sql
95+
Msg 3201, Level 16, State 1, Line 31
96+
Cannot open backup device 'https://<storage-account-name>.blob.core.windows.net/<container-name>/AdventureWorks.bak'. Operating system error 5(Access is denied.).
97+
Msg 3013, Level 16, State 1, Line 31
98+
RESTORE DATABASE is terminating abnormally.
99+
```
100+
101+
### Duplicate database name
102+
103+
When the original database with the same name exists in the storage, the backup of a new database to the same storage path will fail with the following error:
104+
105+
```sql
106+
Msg 1834, Level 16, State 1, Line 35
107+
RESTORE DATABASE AdventureWorks
108+
from URL = 'https://<storage-account-name>.blob.core.windows.net/<container-name>/AdventureWorks.bak'
109+
Msg 1834, Level 16, State 1, Line 35
110+
The file 'C:\Server\sqlservr\data\AdventureWorks.mdf' cannot be overwritten. It is being used by the database 'AdventureWorks'.
111+
Msg 3156, Level 16, State 4, Line 35
112+
File 'AdventureWorks' cannot be restored to 'C:\Server\sqlservr\data\AdventureWorks.mdf'. Use WITH MOVE to identify a valid location for the file.
113+
```
114+
115+
To resolve this issue, drop the original database or move the used files to a different location before restoring the database. For more information, see [Restore a database to a new location (SQL Server)](/sql/relational-databases/backup-restore/restore-a-database-to-a-new-location-sql-server).
116+
117+
## Limitations
118+
119+
- Server-level managed identity is only supported for SQL Server on Azure VM, and not on SQL Server on-premises. Server-level managed identity isn't supported for Linux.
120+
121+
- `BACKUP TO URL` or `RESTORE FROM URL` with a managed identity is only supported for SQL Server on Azure VM. `BACKUP TO URL` or `RESTORE FROM URL` isn't supported by SQL Server on-premises.
122+
123+
- Managed identities aren't supported with failover cluster instance (FCI).
124+
125+
- `BACKUP TO URL` can only be executed with the same managed identity used for the SQL Server on Azure VM, whether the server has one or many instances of SQL Server on the VM.
126+
127+
## Related content
128+
129+
- [Enable Microsoft Entra authentication for SQL Server on Azure VMs](configure-azure-ad-authentication-for-sql-vm.md)
130+
- [Create an Azure storage account](/azure/storage/common/storage-account-create)
131+
- [SQL Server backup to URL for Microsoft Azure Blob Storage](/sql/relational-databases/backup-restore/sql-server-backup-to-url)
132+
- [CREATE CREDENTIAL (Transact-SQL)](/sql/t-sql/statements/create-credential-transact-sql)
133+
- [Trace flag 4675](/sql/t-sql/database-console-commands/dbcc-traceon-trace-flags-transact-sql#tf4675)
Lines changed: 143 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,143 @@
1+
---
2+
title: Managed Identity Support for Extensible Key Management (EKM) with Azure Key Vault (AKV)
3+
description: Learn how to use managed identities with SQL Server on Azure Virtual Machines and Transparent Data Encryption (TDE) Extensible Key Management with Azure Key Vault.
4+
author: GithubMirek
5+
ms.author: mireks
6+
ms.reviewer: vanto, mathoma
7+
ms.date: 01/16/2025
8+
ms.service: azure-vm-sql-server
9+
ms.subservice: security
10+
ms.topic: how-to
11+
---
12+
# Managed Identity support for Extensible Key Management with Azure Key Vault
13+
14+
[!INCLUDE [appliesto-sqlvm-windows-only](../../includes/appliesto-sqlvm-windows-only.md)]
15+
16+
This article shows you how to use managed identities for Extensible Key Management (EKM) with Azure Key Vault (AKV) on [SQL Server on Azure Virtual Machines (VM)](sql-server-on-azure-vm-iaas-what-is-overview.md).
17+
18+
## Overview
19+
20+
Starting with SQL Server 2022 Cumulative Update 17 (CU17), managed identities are supported for EKM with AKV and Managed Hardware Security Modules (HSM) on SQL Server on Azure VMs. Managed identities are the recommended authentication method to allow different Azure services to authenticate the SQL Server on Azure VM resource without using passwords or secrets. For more information on managed identities, see [Managed identity types](/entra/identity/managed-identities-azure-resources/overview#managed-identity-types).
21+
22+
> [!NOTE]
23+
> Managed identities are only supported for SQL Server on Azure VMs and not for SQL Server on-premises.
24+
>
25+
> For information on setting up EKM with AKV for SQL Server on-premises, see [Set up SQL Server TDE Extensible Key Management by using Azure Key Vault](/sql/relational-databases/security/encryption/setup-steps-for-extensible-key-management-using-the-azure-key-vault).
26+
27+
## Prerequisites
28+
29+
- A SQL Server on Azure VM with SQL Server 2022 CU17 or later, [configured with Microsoft Entra authentication](configure-azure-ad-authentication-for-sql-vm.md).
30+
- An Azure Key Vault and key created in the key vault. For more information, see [Create a key vault](/sql/relational-databases/security/encryption/setup-steps-for-extensible-key-management-using-the-azure-key-vault?tabs=portal#step-2-create-a-key-vault).
31+
- Managed identities are supported for EKM with AKV. The primary managed identity for the SQL Server on Azure VM needs:
32+
- To be assigned with a user-assigned managed identity or system-assigned managed identity. For more information, see [Configure managed identities on Azure virtual machines (VMs)](/entra/identity/managed-identities-azure-resources/how-to-configure-managed-identities) and [Enable Microsoft Entra authentication](configure-azure-ad-authentication-for-sql-vm.md#enable-microsoft-entra-authentication).
33+
- To have the `Key Vault Crypto Service Encryption User` role for the primary managed identity assigned to the key vault if you're using [Azure role-based access control](/sql/relational-databases/security/encryption/setup-steps-for-extensible-key-management-using-the-azure-key-vault?tabs=portal#azure-role-based-access-control) or the *Unwrap Key* and *Wrap Key* permissions if you're using [vault access policy](/sql/relational-databases/security/encryption/setup-steps-for-extensible-key-management-using-the-azure-key-vault?tabs=portal#vault-access-policy).
34+
- Download the latest version of the SQL Server Connector from the [Microsoft Download Center](https://www.microsoft.com/download/details.aspx?id=45344).
35+
36+
## Add registry key for the EKM provider
37+
38+
Before you can create a credential using a managed identity, you need to add a registry key to enable the EKM provider to use managed identities. This step needs to be performed by the computer administrator. For detailed steps, see [Step 4: Add registry key to support EKM provider](/sql/relational-databases/security/encryption/setup-steps-for-extensible-key-management-using-the-azure-key-vault?tabs=portal#step-4-add-registry-key-to-support-ekm-provider).
39+
40+
## Create a server credential using managed identities
41+
42+
The following example shows how to create a credential for a managed identity to use with the AKV:
43+
44+
```sql
45+
CREATE CREDENTIAL [<akv-name>.vault.azure.net]
46+
WITH IDENTITY = 'Managed Identity'
47+
FOR CRYPTOGRAPHIC PROVIDER AzureKeyVault_EKM_Prov
48+
```
49+
50+
You can check the AKV name by querying `sys.credentials`:
51+
52+
```sql
53+
SELECT name, credential_identity
54+
FROM sys.credentials
55+
```
56+
57+
The `WITH IDENTITY = 'Managed Identity'` clause requires a primary managed identity assigned to the SQL Server on Azure VM.
58+
59+
For more information on setting up EKM with AKV, see [Set up SQL Server TDE Extensible Key Management by using Azure Key Vault](/sql/relational-databases/security/encryption/setup-steps-for-extensible-key-management-using-the-azure-key-vault).
60+
61+
## Creating a credential to use with Managed Hardware Security Modules (HSMs)
62+
63+
To create a credential to use with Azure Key Vault Managed Hardware Security Modules (HSMs), use the following syntax:
64+
65+
```sql
66+
CREATE CREDENTIAL [<akv-name>.managedhsm.azure.net]
67+
WITH IDENTITY = 'Managed Identity'
68+
FOR CRYPTOGRAPHIC PROVIDER AzureKeyVault_EKM_Prov
69+
```
70+
71+
For more information on setting up EKM with AKV, see [Set up SQL Server TDE Extensible Key Management by using Azure Key Vault](/sql/relational-databases/security/encryption/setup-steps-for-extensible-key-management-using-the-azure-key-vault).
72+
73+
## T-SQL commands to upgrade existing EKM configuration to use managed identities
74+
75+
If your current configuration is using EKM with AKV using a secret, you'll need to drop the existing credential and create a new credential using a managed identity. The following T-SQL commands show how to upgrade your existing EKM configuration to use managed identities:
76+
77+
1. Create the credential using a managed identity:
78+
79+
```sql
80+
CREATE CREDENTIAL [<akv-name>.vault.azure.net]
81+
WITH IDENTITY = 'Managed Identity'
82+
FOR CRYPTOGRAPHIC PROVIDER AzureKeyVault_EKM_Prov
83+
```
84+
85+
1. If there's a credential using a secret associated with the SQL Server administration domain login, drop the existing credential:
86+
87+
```sql
88+
ALTER LOGIN [<domain>\<login>]
89+
DROP CREDENTIAL [<existing-credential-name>]
90+
```
91+
92+
1. Associate the new credential with the SQL Server administration domain login:
93+
94+
```sql
95+
ALTER LOGIN [<domain>\<login>]
96+
ADD CREDENTIAL [<akv-name>.vault.azure.net]
97+
```
98+
99+
You can check the encrypted database view to verify the database encryption using the following query:
100+
101+
```sql
102+
SELECT *
103+
FROM sys.dm_database_encryption_keys
104+
WHERE database_id=db_id('<your-database-name>')
105+
```
106+
107+
For more information on setting up EKM with AKV, see [Set up SQL Server TDE Extensible Key Management by using Azure Key Vault](/sql/relational-databases/security/encryption/setup-steps-for-extensible-key-management-using-the-azure-key-vault).
108+
109+
## Error messages
110+
111+
[Trace flag 4675](/sql/t-sql/database-console-commands/dbcc-traceon-trace-flags-transact-sql#tf4675) can be used to check credentials created with a managed identity. If the `CREATE CREDENTIAL` statement was executed without trace flag 4675 enabled, no error message is issued if the primary managed identity isn't set for the server. To troubleshoot this scenario, the credential must be deleted and recreated again once the trace flag is enabled.
112+
113+
### No primary managed identity assigned
114+
115+
If a primary managed identity isn't assigned to the SQL Server on Azure VM, the backup and restore operations will fail with an error message indicating that the managed identity isn't selected.
116+
117+
```sql
118+
Msg 37563, Level 16, State 2, Line 14
119+
The primary managed identity is not selected for this server. Enable the primary managed identity for Microsoft Entra authentication for this server. For more information see (https://aka.ms/sql-server-managed-identity-doc).`
120+
```
121+
122+
### SQL Server Connector version does not support the managed identity for EKM with AKV
123+
124+
If a previous SQL Server Connector version is used, the following error occurs when executing the T-SQL `CREATE ASYMMETRIC KEY` statement using a server credential with managed identity:
125+
126+
```sql
127+
Msg 37576, Level 16, State 2, Line 60
128+
The current SQL Server Connector version for Microsoft Azure Key Vault does not support the managed identity (see https://aka.ms/sql-server-managed-identity-doc). Upgrade the SQL Server Connector to its latest version
129+
```
130+
131+
## Limitations
132+
133+
- Server-level managed identity is only supported for SQL Server on Azure VM, and not on SQL Server on-premises. Server-level managed identity isn't supported for Linux.
134+
- Managed identity support for EKM with AKV and [Backup and restore to URL using managed identities](backup-restore-to-url-using-managed-identities.md) are the only Azure services that support managed identity for SQL Server on Azure VMs.
135+
- Managed identity support for EKM with AKV requires the latest SQL Server Connector version. Make sure you download and install the latest version from the [Microsoft Download Center](https://www.microsoft.com/download/details.aspx?id=45344).
136+
- Microsoft Entra authentication can only be enabled with one primary managed identity for the SQL Server on Azure VM. The primary managed identity is used for all SQL Server instances on the VM.
137+
138+
## Related content
139+
140+
- [Backup and restore to URL using managed identities](backup-restore-to-url-using-managed-identities.md)
141+
- [Enable Microsoft Entra authentication for SQL Server on Azure VMs](configure-azure-ad-authentication-for-sql-vm.md)
142+
- [CREATE CREDENTIAL (Transact-SQL)](/sql/t-sql/statements/create-credential-transact-sql)
143+
- [Trace flag 4675](/sql/t-sql/database-console-commands/dbcc-traceon-trace-flags-transact-sql#tf4675)

docs/relational-databases/errors-events/database-engine-events-and-errors-0-to-999.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,10 +3,10 @@ title: "Database Engine events and errors (0 to 999)"
33
description: "Consult this SQL Server error code list (between 0 and 999) to find explanations for error messages for SQL Server database engine events."
44
author: rwestMSFT
55
ms.author: randolphwest
6-
ms.date: 09/12/2024
6+
ms.date: 01/16/2025
77
ms.service: sql
88
ms.subservice: supportability
9-
ms.topic: reference
9+
ms.topic: error-reference
1010
monikerRange: "=azuresql || =azuresql-db || =azuresql-mi || >=aps-pdw-2016-au7 || >=sql-server-2016 || >=sql-server-linux-2017"
1111
---
1212
# Database Engine events and errors (0 to 999)

0 commit comments

Comments
 (0)