Edit

Share via


Managed identity (preview) for SQL Server enabled by Azure Arc

Applies to: SQL Server 2025 (17.x) Preview

This article describes how to configure a managed identity for SQL Server enabled by Azure Arc.

SQL Server 2025 (17.x) Preview includes managed identity support for SQL Server on Windows. Use a managed identity to interact with resources in Azure by using Microsoft Entra authentication.

Note

Using a managed identity with SQL Server 2025 is currently in preview.

Overview

SQL Server 2025 (17.x) Preview introduces support for Microsoft Entra managed identities. Use managed identities to authenticate to Azure services without needing to manage credentials. Managed identities are automatically managed by Azure and can be used to authenticate to any service that supports Microsoft Entra authentication. With SQL Server 2025 (17.x) Preview, you can use managed identities both to authenticate inbound connections, and also to authenticate outbound connections to Azure services.

When you connect your SQL Server instance to Azure Arc, a system-assigned managed identity is automatically created for the SQL Server hostname. After the managed identity is created, you must associate the identity with the SQL Server instance and the Microsoft Entra tenant ID by updating the registry.

When using managed identity with SQL Server enabled by Azure Arc, consider the following:

  • The managed identity is assigned at the Azure Arc server level.
  • Only system-assigned managed identities are supported.
  • SQL Server uses this Azure Arc server level managed identity as the primary managed identity.
  • SQL Server can use this primary managed identity in either inbound and/or outbound connections.
    • Inbound connections are logins and users connecting to SQL Server. Inbound connections can also be achieved by using App Registration available from SQL Server 2022.
    • Outbound connections are SQL Server connections to Azure resources, like backup to URL, or connecting to Azure Key Vault.
  • App Registration can't enable a SQL Server to make outbound connections. Outbound connections need a primary managed identity assigned to the SQL Server.

Prerequisites

Before you can use a managed identity with SQL Server enabled by Azure Arc, ensure that you meet the following prerequisites:

Enable the primary managed identity

If you've installed the Azure Extension for SQL Server to your server, you can enable the primary managed identity for your SQL Server instance directly from the Azure portal. It's also possible to enable the primary managed identity manually by updating the registry, but should be done with extreme caution.

To enable the primary managed identity in the Azure portal, follow these steps:

  1. Go to your SQL Server enabled by Azure Arc resource in the Azure portal.

  2. Under Settings, select Microsoft Entra ID and Purview to open the Microsoft Entra ID and Purview page.

    Note

    If you don't see the Enable Microsoft Entra ID authentication option, ensure that your SQL Server instance is connected to Azure Arc and that you have the latest SQL extension installed.

  3. On the Microsoft Entra ID and Purview page, check the box next to Use a primary managed identity and then use Save to apply your configuration:

    Screenshot of the Microsoft Entra option in the Azure portal.

Grant application permissions to the identity

The system-assigned managed identity, which uses the Arc-enabled machine name, must have the following Microsoft Graph application permissions (app roles): User.Read.All, GroupMember.Read.All, and Application.Read.All.

You can use PowerShell to grant required permissions to the managed identity. Alternatively, you can create a role-assignable group. After the group is created, assign the Directory readers role to the group, and add all system-assigned managed identities for your Arc-enabled machines to the group.

The following PowerShell script grants the required permissions to the managed identity:

# Update these variables to match your Azure & Arc machine setup
$tenantID = '<Enter-Your-Azure-Tenant-Id>'
$managedIdentityName = '<Enter-Your-Arc-HostMachine-Name>'

# Install and connect to AzureAD
try {
    Install-Module -Name AzureAD -Force -Scope CurrentUser -ErrorAction Stop
    Import-Module AzureAD
    Connect-AzureAD -TenantId $tenantID
    Write-Output "Connected to AzureAD successfully."
} catch {
    Write-Error "Failed to install or connect to AzureAD: $_"
    return
}

# Get Microsoft Graph API service principal
$graphAppId = '00000003-0000-0000-c000-000000000000'
$graphSP = Get-AzureADServicePrincipal -Filter "appId eq '$graphAppId'"
if (-not $graphSP) {
    Write-Error "Microsoft Graph service principal not found."
    return
}

# Get the managed identity
$managedIdentity = Get-AzureADServicePrincipal -SearchString $managedIdentityName | Where-Object { $_.DisplayName -eq $managedIdentityName }

if (-not $managedIdentity) {
    Write-Error "Managed identity '$managedIdentityName' not found."
    return
}

# Define roles to assign
$requiredRoles = @(
    "User.Read.All",
    "GroupMember.Read.All",
    "Application.Read.All"
)

# Assign roles
foreach ($roleValue in $requiredRoles) {
    $appRole = $graphSP.AppRoles | Where-Object { $_.Value -eq $roleValue -and $_.AllowedMemberTypes -contains "Application" }
    if ($appRole) {
        try {
            New-AzureADServiceAppRoleAssignment `
                -ObjectId $managedIdentity.ObjectId `
                -PrincipalId $managedIdentity.ObjectId `
                -ResourceId $graphSP.ObjectId `
                -Id $appRole.Id
            Write-Output "Successfully assigned role '$roleValue' to '$managedIdentityName'."
        } catch {
            Write-Warning "Failed to assign role '$roleValue': $_"
        }
    } else {
        Write-Warning "Role '$roleValue' not found in Microsoft Graph AppRoles."
    }
}

Create logins and users

Follow the steps in the Microsoft Entra tutorial to create logins and users for the managed identity.

Limitations

Consider the following limitations when using a managed identity with SQL Server 2025:

  • Microsoft Entra authentication is only supported with Arc enabled SQL Server 2025 running on Windows Server.
  • Using Microsoft Entra authentication with failover cluster instances isn't supported.
  • The identity you choose to authenticate to SQL Server has to have either the Directory Readers role in Microsoft Entra ID or the following three Microsoft Graph application permissions (app roles): User.Read.All, GroupMember.Read.All, and Application.Read.All.
  • Once Microsoft Entra authentication is enabled, disabling isn't advisable. Disabling Microsoft Entra authentication forcefully by deleting registry entries can result in unpredictable behavior with SQL Server 2025.
  • Authenticating to SQL Server on Arc machines through Microsoft Entra authentication using the FIDO2 method isn't currently supported.