Skip to content

Commit 048e20c

Browse files
authored
Add script, add error 13822, and permission reference (#35676)
1 parent a0f8640 commit 048e20c

1 file changed

Lines changed: 113 additions & 38 deletions

File tree

Lines changed: 113 additions & 38 deletions
Original file line numberDiff line numberDiff line change
@@ -1,53 +1,91 @@
11
---
2-
title: "Configure PolyBase Support for Managed Identity"
3-
description: "Explains how to configure PolyBase to query resources in Azure with managed identity."
2+
title: Configure PolyBase Support for Managed Identity
3+
description: Learn to configure PolyBase to query Azure resources by using managed identity.
44
author: MikeRayMSFT
55
ms.author: mikeray
6-
ms.date: 08/08/2025
6+
ms.reviewer: randolphwest
7+
ms.date: 10/30/2025
78
ms.service: sql
89
ms.topic: concept-article
910
---
1011

11-
# Connect to Azure storage with managed identity from PolyBase
12+
# Connect to Azure Storage with managed identity from PolyBase
1213

13-
Beginning with [!INCLUDE [sssql25-md](../../includes/sssql25-md.md)] you can use managed identities to access:
14+
[!INCLUDE [sqlserver2025-and-later](../../includes/applies-to-version/sqlserver2025-and-later.md)]
1415

15-
- Microsoft Azure Blob Storage
16-
- Microsoft Azure Data Lake
16+
Starting with [!INCLUDE [sssql25-md](../../includes/sssql25-md.md)], you can use [managed identity](../../sql-server/azure-arc/managed-identity.md) to access the following Azure resources:
17+
18+
- Azure Blob Storage
19+
- Azure Data Lake
1720

1821
## Prerequisites
1922

2023
- [!INCLUDE [sssql25-md](../../includes/sssql25-md.md)]
2124
- [SQL Server enabled by Azure Arc](../../sql-server/azure-arc/managed-identity.md)
22-
- Enable `sp_configure 'allow server scoped db credentials'`
25+
- Enable the `allow server scoped db credentials` server configuration option
26+
- Give the managed identity access to the Azure Blob Storage resource.
2327

2428
## Update the registry
2529

2630
> [!WARNING]
27-
> Incorrectly editing the registry can severely damage your system. Before making changes to the registry, we recommend you back up any valued data on the computer.
31+
> [!INCLUDE [ssnoteregistry-md](../../includes/ssnoteregistry-md.md)]
2832
29-
Update the registry subkey `\HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Microsoft SQL Server\MSSQL17.MSSQLSERVER\MSSQLServer\FederatedAuthentication`. Add the following entries for your data storage types.
33+
Update the registry subkey `\HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Microsoft SQL Server\MSSQL17.MSSQLSERVER\MSSQLServer\FederatedAuthentication`. Add the following entries for your data storage types:
3034

3135
| Entry | Value |
3236
| --- | --- |
3337
| `AADDataLakeEndPoint` | `datalake.azure.net` |
34-
| `AADAzureStorageEndPoint` | `storage.azure.com` |
38+
| `AADAzureStorageEndpoint` | `storage.azure.com` |
39+
40+
### Registry example
41+
42+
The following example script inserts the registry keys for a [!INCLUDE [sssql25-md](../../includes/sssql25-md.md)] named instance called `SQL25Inst`, if it doesn't already exist:
43+
44+
```powershell
45+
$yourinstance = "MSSQL17.SQL25Inst"
46+
47+
# Define the registry path
48+
$regPath = "HKLM:\SOFTWARE\Microsoft\Microsoft SQL Server\$($yourinstance)\MSSQLServer\FederatedAuthentication"
49+
Write-Host "Path to be updated: $regPath"
50+
51+
# Ensure the path exists
52+
if (-not (Test-Path $regPath)) {
53+
New-Item -Path $regPath -Force | Out-Null
54+
}
55+
56+
# Define the values to create
57+
$values = @{
58+
"AADDataLakeEndPoint" = "datalake.azure.net"
59+
"AADAzureStorageEndpoint" = "storage.azure.com"
60+
}
61+
62+
foreach ($name in $values.Keys) {
63+
$existing = Get-ItemProperty -Path $regPath -Name $name -ErrorAction SilentlyContinue
64+
if ($null -eq $existing) {
65+
New-ItemProperty -Path $regPath -Name $name -Value $values[$name] -PropertyType String -Force
66+
Write-Host "Created registry value '$name' with '$($values[$name])'"
67+
}
68+
else {
69+
Write-Host "Registry value '$name' already exists. Skipping..."
70+
}
71+
}
72+
```
3573

36-
These keys are in addition to the registry keys required as described in [Managed identity (preview) for SQL Server enabled by Azure Arc](../../sql-server/azure-arc/managed-identity.md?tabs=manual#update-the-registry).
74+
Add these keys along with the keys described in [Managed identity (preview) for SQL Server enabled by Azure Arc](../../sql-server/azure-arc/managed-identity.md?tabs=manual#update-the-registry).
3775

3876
## Create database scoped credentials
3977

4078
Add a database scoped credential for managed identity.
4179

42-
1. Allow server scoped database credentials. Run the following command.
80+
1. Allow server scoped database credentials. Run the following Transact-SQL query:
4381

4482
```sql
45-
EXECUTE sp_configure 'allow server scoped db credentials',1;
83+
EXECUTE sp_configure 'allow server scoped db credentials', 1;
4684
GO
4785
RECONFIGURE;
4886
```
4987

50-
1. Create a database scoped credential. The example uses the name `managed_id`.
88+
1. Create a database scoped credential. This example uses the name `managed_id`:
5189

5290
```sql
5391
CREATE DATABASE SCOPED CREDENTIAL [managed_id]
@@ -56,18 +94,49 @@ Add a database scoped credential for managed identity.
5694

5795
## Create external data source
5896

59-
Create the external data source.
97+
Create the external data source with the following settings.
98+
99+
### [Azure Storage account (V2)](#tab/asav2)
100+
101+
- **Connector location prefix**
102+
- `abs`
103+
104+
- **Location path**
105+
- `abs://<container_name>@<storage_account_name>.blob.core.windows.net/`, or
106+
- `abs://<storage_account_name>.blob.core.windows.net/<container_name>`
107+
108+
- **Supported locations by product / service**
109+
- [!INCLUDE [sssql25-md](../../includes/sssql25-md.md)] enabled by Azure Arc
110+
- [!INCLUDE [sssql22-md](../../includes/sssql22-md.md)]: Hierarchical namespace supported
111+
112+
- **Authentication**
113+
- Shared access signature (SAS), or
114+
- Managed identity
60115

61-
| External data source | Connector location prefix | Location path | Supported locations by product / service | Authentication |
62-
| --- | --- | --- | --- | --- |
63-
| Azure Storage Account (V2) | `abs` | `abs://<container_name>@<storage_account_name>.blob.core.windows.net/`<br />or<br />`abs://<storage_account_name>.blob.core.windows.net/<container_name>` | - [!INCLUDE [sssql22-md](../../includes/sssql22-md.md)]: Hierarchical Namespace supported<br />- [!INCLUDE [sssql25-md](../../includes/sssql25-md.md)] enabled by Azure Arc | Shared access signature (SAS)<br />or<br />Managed Identity |
64-
| Azure Data Lake Storage | `adls` | `adls://<container_name>@<storage_account_name>.dfs.core.windows.net/`<br />or<br />`adls://<storage_account_name>.dfs.core.windows.net/<container_name>` | - [!INCLUDE [sssql22-md](../../includes/sssql22-md.md)]<br />- [!INCLUDE [sssql25-md](../../includes/sssql25-md.md)] enabled by Azure Arc | Shared access signature (SAS)<br />or<br />Managed Identity |
116+
### [Azure Data Lake Storage](#tab/adls)
117+
118+
- **Connector location prefix**
119+
- `adls`
120+
121+
- **Location path**
122+
- `adls://<container_name>@<storage_account_name>.dfs.core.windows.net/`, or
123+
- `adls://<storage_account_name>.dfs.core.windows.net/<container_name>`
124+
125+
- **Supported locations by product / service**
126+
- [!INCLUDE [sssql25-md](../../includes/sssql25-md.md)] enabled by Azure Arc
127+
- [!INCLUDE [sssql22-md](../../includes/sssql22-md.md)]
128+
129+
- **Authentication**
130+
- Shared access signature (SAS), or
131+
- Managed identity
132+
133+
---
65134

66-
## Query a parquet file in Azure Blob Storage
135+
## Query a Parquet file in Azure Blob Storage
67136

68-
[!INCLUDE [sssql25-md](../../includes/sssql25-md.md)] supports for Manage Identity through Azure Arc. For instructions, review [Managed identity (preview) for SQL Server enabled by Azure Arc](../../sql-server/azure-arc/managed-identity.md).
137+
[!INCLUDE [sssql25-md](../../includes/sssql25-md.md)] supports for managed identity through Azure Arc. For instructions, see [Managed identity (preview) for SQL Server enabled by Azure Arc](../../sql-server/azure-arc/managed-identity.md).
69138

70-
The following example queries a parquet file in Azure Blob Storage
139+
The following example queries a Parquet file in Azure Blob Storage:
71140

72141
```sql
73142
EXECUTE sp_configure 'allow server scoped db credentials', 1;
@@ -86,32 +155,38 @@ WITH (
86155

87156
## Errors and solutions
88157

89-
[!INCLUDE [sssql25-md](../../includes/sssql25-md.md)] enabled by Azure Arc fails to authenticate using Managed Identity.
158+
### External table isn't accessible (Error 16562)
90159

91-
To use managed identity, [!INCLUDE [sssql25-md](../../includes/sssql25-md.md)] must be enabled by Azure Arc. For instructions on how to enable by Azure Arc, review [Managed identity (preview) for SQL Server enabled by Azure Arc](../../sql-server/azure-arc/managed-identity.md).
92-
93-
Enable `sp_configure 'allow server scoped db credentials'`.
94-
95-
If any of the following are true, the PolyBase query fails:
96-
97-
- The SQL Server instance isn't properly configured for Azure Arc
98-
- Registry entries are missing
99-
- `allow server scoped db credentials` is disabled
100-
101-
The query will return one of the following errors when trying to access Azure Blob Storage or Azure Data Lake:
160+
You might encounter error 16562 when trying to access Azure Blob Storage or Azure Data Lake if you're missing prerequisites:
102161

103162
```output
104163
Msg 16562, Level 16, State 1, Line 79
105164
External table <name> is not accessible because location does not exist or it is used by another process.
106165
```
107166

108-
Or
167+
Check the following items:
168+
169+
- The SQL Server instance is properly configured for Azure Arc. For more information, see [Managed identity (preview) for SQL Server enabled by Azure Arc](../../sql-server/azure-arc/managed-identity.md).
170+
171+
- The required registry entries exist.
172+
173+
- `allow server scoped db credentials` is enabled.
174+
175+
### File can't be opened (Error 16562)
176+
177+
You might encounter error 13822 when you access Azure Blob Storage or Azure Data Lake if the managed identity lacks permissions on the storage account, or network access to storage is blocked.
109178

110179
```output
111-
Msg 16562, Level 16, State 1, Line 79
112-
External table <name> is not accessible because location does not exist or it is used by another process.
180+
Msg 13822, Level 16, State 1, Line 9
181+
File <file> cannot be opened because it does not exist or it is used by another process.
113182
```
114183

184+
Check the following items:
185+
186+
- Does the managed identity have permissions to the storage container?
187+
- Can the managed identity access the storage container outside SQL Server?
188+
- Is the file locked exclusively?
189+
115190
## Related content
116191

117192
- [Managed identity (preview) for SQL Server enabled by Azure Arc](../../sql-server/azure-arc/managed-identity.md)

0 commit comments

Comments
 (0)