Microsoft Entra-only authentication for Azure SQL Database disables SQL authentication across the whole logical server, so only Microsoft Entra ID identities can sign in.
The logical server is the Azure resource that groups databases under one name, one administrator, and one set of firewall rules. Turning the feature on takes one command, but doing it without locking out administrators and applications takes a plan.
This article walks through that plan, tested on a live server: an administrator group and emergency account, managed identities for applications, and then Defender for SQL, auditing, and a private endpoint.
Unless noted otherwise, I ran every command in this article against my own test server on October 27, 2026, using PowerShell in Azure Cloud Shell and the query editor in the Azure portal. A few client-side tests ran on my Windows workstation, and the text says so where it matters. The output is what came back, and all times are Central European Time, one hour ahead of Coordinated Universal Time.
What Entra-only authentication disables in Azure SQL
Once enabled, the feature disables SQL authentication for the entire logical server. This means SQL logins, users with SQL authentication, and the SQL server administrator lose access to every database – and you can only turn the feature on or off after a Microsoft Entra administrator has been set on the server.
Microsoft splits the two jobs on purpose, since they’re both Azure roles as opposed to roles inside SQL Server. Put simply, a SQL Server Contributor sets the administrator, and a SQL Security Manager turns the feature on or off.
Owners, Contributors, or a custom role with both sets of permissions can handle both steps at once – and turning the feature off again brings SQL logins back.
| Task | Azure role needed |
|---|---|
| Set the Microsoft Entra administrator | SQL Server Contributor |
| Turn Entra-only authentication on or off | SQL Security Manager |
| Do both | Owner, Contributor, or a custom role with both sets of permissions |
Some features don’t work with Entra-only at all – or they do work, but with restrictions. These include Elastic Jobs, SQL Data Sync, transactional replication into the database, and EXEC AS for group members. Check that list against your environment before you start.
Microsoft’s list also names change data capture with a mix of SQL and Entra users. SQL Insights was on the list too, but Microsoft retired the service in December 2024.
My test used a Basic-tier database with the AdventureWorksLT sample. In West Europe, Azure rejected the new server with RequestDisallowedByAzure and a note that the region wasn’t accepting new customers.
Germany West Central, meanwhile, deployed without errors, and the resource group stayed in West Europe (important later for the private endpoint.)
Read-Host prompts for the SQL admin password so it never lands in the shell history. The server name has to be globally unique, and the firewall rule needs the public Internet Protocol (IP) address of the admin workstation:
$rg='rg-simpletalk-test'; $loc='germanywestcentral'; $srv='sql-st-joos-1027'; $db='sqldb-st-test'
$pw = Read-Host -Prompt "SQL admin password" -MaskInput
az group create -n $rg -l westeurope # created during the first attempt in West Europe
az sql server create -g $rg -n $srv -l $loc --admin-user sqladminst --admin-password $pw
az sql db create -g $rg -s $srv -n $db --edition Basic --sample-name AdventureWorksLT --backup-storage-redundancy Local
az sql server firewall-rule create -g $rg -s $srv -n AllowAdminPC `
--start-ip-address "<public IP>" --end-ip-address "<public IP>"Azure SQL stores the Entra administrator as a user in master, but a security group with two or three named database administrators (DBAs) is the better choice.
The server then still has an administrator who can sign in after one of them leaves the company.
The block below sets the group with az sql server ad-admin create and also creates sql-sales-readers-st, the reader group I use later:
$grpId = az ad group create --display-name "sql-admins-st-test" --mail-nickname "sql-admins-st-test" --query id -o tsv
az ad group member add --group $grpId --member-id (az ad signed-in-user show --query id -o tsv)
az sql server ad-admin create -g $rg -s $srv --display-name "sql-admins-st-test" --object-id $grpId
az ad group create --display-name "sql-sales-readers-st" --mail-nickname "sql-sales-readers-st" # reader group used laterIn PowerShell, Set-AzSqlServerActiveDirectoryAdministrator does the same thing. The setup fails if master already contains a user with the group’s name:
Set-AzSqlServerActiveDirectoryAdministrator -ResourceGroupName "rg-simpletalk-test" `
-ServerName "sql-st-joos-1027" -DisplayName "sql-admins-st-test"If you create a server with Entra-only enabled from the start, Azure generates an administrator with the prefix CloudSA and a random password, and Microsoft removes that password from the Azure management layer after deployment.
Since nobody knows that password, the account offers no emergency path.
Microsoft recommends two emergency accounts in the tenant, protected with a FIDO2 (Fast IDentity Online 2) passkey and excluded from blocking Conditional Access policies. One of them belongs in the administrator group.
To turn Entra-only off in an emergency, that account also needs an Azure role such as SQL Security Manager on the server.
Test the emergency path at least once before the switch, for example by signing in with the emergency account in SQL Server Management Studio (SSMS) and running SELECT SUSER_SNAME().
I turned the feature on at this point in my test because no application was using the database yet. In production, it comes last: after every application has moved over – and after you have checked your own Entra session with SELECT SUSER_SNAME(), IS_MEMBER('db_owner').
Azure SQL reads group memberships from the access token, the signed sign-in ticket that Entra ID issues to the client, and an older token doesn’t know about a group you were just added to.
The Azure command-line interface (CLI) needs version 2.14.2 or later, and az sql server ad-only-auth disable reverses the change.
enable command and verify itI switched with az sql server ad-only-auth enable. The first block below shows the PowerShell cmdlet that does the same, and the third block shows the CLI commands with their output.
Inside the database, SERVERPROPERTY('IsExternalAuthenticationOnly') returns 1 once the feature is on, and 0 while it is off:
Enable-AzSqlServerActiveDirectoryOnlyAuthentication -ResourceGroupName "rg-simpletalk-test" -ServerName "sql-st-joos-1027"
SELECT SERVERPROPERTY('IsExternalAuthenticationOnly') AS entra_only,
SUSER_SNAME() AS login, DB_NAME() AS db;
PS> az sql server ad-only-auth get -g rg-simpletalk-test -n sql-st-joos-1027 -o table
AzureAdOnlyAuthentication Name ResourceGroup
--------------------------- ------- ------------------
False Default rg-simpletalk-test
PS> az sql server ad-only-auth enable -g rg-simpletalk-test -n sql-st-joos-1027 -o table
AzureAdOnlyAuthentication Name ResourceGroup
--------------------------- ------- ------------------
True Default rg-simpletalk-test
entra_only login db
0 sqladminst sqldb-st-test -- before, SQL login
1 thomas@hof-erbach.de sqldb-st-test -- after, Entra accountFrom then on, every SQL login fails with error 18456 and the message “Login failed for user ‘sqladminst’. Reason: Azure Active Directory only authentication is enabled.”
At 9:07 a.m., a SqlClient script on my workstation with three wrong passwords got exactly the same message as the correct password did.
The message doesn’t tell an attacker whether a password was correct but, even if that message shows up in an application log after the switch, the application still needs to be migrated.
After a page reload, the portal’s query editor checked the setting on its own and stopped sending SQL logins to the server altogether, so test applications in SSMS or a script.
In my test, the query editor had still been connected as sqladminst before the switch, and the server rejected that session with the same message on the next query.
For new servers, az sql server create with --enable-ad-only-auth and the --external-admin-* parameters turns the feature on from the start (az sql server).
Across a subscription, the built-in Azure Policy “Azure SQL Database should have Microsoft Entra-only authentication enabled” checks the setting.
Its default effect is Audit, and with the effect Deny it blocks new logical servers without Entra-only.
A connection string with a password stops working after the switch.
Instead, the application signs in with the managed identity of its App Service, Azure Function, or virtual machine – an identity Azure manages without a stored password.
Authentication=Active Directory Default uses the managed identity in Azure, and the developer’s own sign-in is used on a workstation.
For an application that should use the managed identity and nothing else, Authentication=Active Directory Managed Identity is the stricter option.
I tested the managed identity path with a small Ubuntu virtual machine (VM) that connects through the private endpoint, described further down.
Important note for auditing: SUSER_SNAME() returned the identity’s client ID and tenant ID instead of the VM name.
Server=tcp:sql-st-joos-1027.database.windows.net;Authentication=Active Directory
Default;Database=sqldb-st-test;CREATE USER … FROM EXTERNAL PROVIDERThis is where migrations usually break, since the identity exists in Azure but the database doesn’t know about it yet. A role per application with permissions on its own schema keeps access tighter than db_datareader and db_datawriter.
You create the user with an Entra account that holds the ALTER ANY USER permission:
-- requires an existing managed identity with the display name app-sales-st
CREATE USER [app-sales-st] FROM EXTERNAL PROVIDER;
CREATE ROLE app_sales_rw;
GRANT SELECT, INSERT, UPDATE ON SCHEMA::SalesLT TO app_sales_rw;
ALTER ROLE app_sales_rw ADD MEMBER [app-sales-st];If two objects share a display name, CREATE USER fails with error 33131. Microsoft describes WITH OBJECT_ID as a repair option for exactly that case, and advises against it for unique names.
When a user runs CREATE USER, Azure SQL queries Microsoft Graph with that user’s permissions. My test server had no server identity, and az sql server show reported identity: null.
However, Azure SQL still created the user for the reader group sql-sales-readers-st in 0.7 seconds, and in the afternoon it did the same for the managed identity of my test VM.
I didn’t create app-sales-st itself, so the block above shows the pattern, and the VM section further down shows it with a real identity. For that case, Microsoft suggests the display name plus a suffix as the user name – the first five characters of the object ID, for example, so it stays clear which identity is behind it.
Deployment pipelines and other automation that run under a managed identity behave differently. They need a server identity with User.Read.All, GroupMember.Read.All, and Application.Read.All, or they fail with error 33134.
An application can’t act on behalf of another application, so Azure SQL falls back to the server identity, and the error text reads “Server identity is not configured.”
Instead of the three Graph permissions, a role-assignable group with the Directory Readers role works as well. The same error 33134 also appears when a Conditional Access policy blocks the lookup for a user.
Permissions belong on groups. In my test, the group sql-sales-readers-st can read every table in the SalesLT schema:
CREATE USER [sql-sales-readers-st] FROM EXTERNAL PROVIDER;
CREATE ROLE sales_reader;
GRANT SELECT ON SCHEMA::SalesLT TO sales_reader;
ALTER ROLE sales_reader ADD MEMBER [sql-sales-readers-st];In September 2026, Microsoft’s database support team described a customer case in which group users failed with error 18456 after their logins in master had been deleted. A contained user exists only in its database, while a login-based user depends on a login in master.
The query below shows which model a database uses: contained users have a 16-byte security identifier (SID), login-based users an 18-byte one. Type E stands for external users, X for external groups. Connect to each database in turn and run it there, before and after the switch.
A session of the Entra administrator runs as dbo, the database owner user, and in that session IS_MEMBER() returns 0 for groups even when the group works fine:
SELECT name, type_desc, DATALENGTH(sid) AS sid_length,
CASE WHEN DATALENGTH(sid) = 18 THEN 'LOGIN-BASED' ELSE 'CONTAINED' END AS model
FROM sys.database_principals
WHERE type IN ('E', 'X');
name type_desc sid_length model
-------------------- -------------- ---------- ---------
sql-sales-readers-st EXTERNAL_GROUP 16 CONTAINEDIn my test database, the query returned a single row. The administrator group doesn’t appear in sys.database_principals of the user database at all, because Azure SQL maps it to dbo.
An administrator session, meanwhile, returned 0 for IS_MEMBER(sql-sales-readers-st), and 1 for IS_MEMBER (db_owner).

I couldn’t find any Microsoft documentation on how nested groups behave in Azure SQL, so I put my user into an inner group, and that group into the reader group.
Remove your own user from the administrator group only while a second member, such as the emergency account, remains in it:
$meId = az ad signed-in-user show --query id -o tsv
$adminsId = az ad group show --group "sql-admins-st-test" --query id -o tsv
$readersId = az ad group show --group "sql-sales-readers-st" --query id -o tsv
$innerId = az ad group create --display-name "sql-nested-inner-st" `
--mail-nickname "sql-nested-inner-st" --query id -o tsv
az ad group member add --group $innerId --member-id $meId # user -> inner group
az ad group member add --group $readersId --member-id $innerId # inner group -> reader group
# only with a second member in the admin group, such as the emergency account
az ad group member remove --group $adminsId --member-id $meId # user leaves admin group
az ad group member check --group $adminsId --member-id $meId --query value # false
az ad group member check --group $readersId --member-id $meId --query value # true
# after the test (8:35 a.m. in my run): back into the admin group
az ad group member add --group $adminsId --member-id $meIdThe session kept running as dbo even after a fresh sign-in to the query editor. The two Database Console Commands (DBCC) that clear the caches changed nothing.
Right after the change, the check query further down still returned in_db_owner = 1 and in_sales_reader = 0. Microsoft recommends DBCC FLUSHAUTHCACHE for new group members, and mentions the second command in the context of Entra logins.
Both ran without errors in my test:
DBCC FLUSHAUTHCACHE;
DBCC FREESYSTEMCACHE('TokenAndPermUserStore');The cause was the client’s access token. Signing in to the query editor again evidently reused that token, and it still carried the old group list, staying valid for a random 60 to 90 minutes.
After 66 minutes, the nesting took effect, and an UPDATE on SalesLT.Customer failed with the message “The UPDATE permission was denied.”
SELECT SUSER_SNAME() AS login_name, USER_NAME() AS db_user,
IS_MEMBER('sql-sales-readers-st') AS in_readers_group,
IS_MEMBER('sales_reader') AS in_sales_reader,
IS_MEMBER('db_owner') AS in_db_owner,
(SELECT COUNT(*) FROM SalesLT.Customer) AS customers_readable;
login_name db_user in_readers_group in_sales_reader in_db_owner customers_readable
-------------------- -------------------- ---------------- --------------- ----------- ------------------
thomas@hof-erbach.de thomas@hof-erbach.de 1 1 0 847A revoked permission therefore stays in effect until the token expires, and for managed identities that can take up to 24 hours. Nested memberships also hide who holds a permission, since the database only sees the outer group.
The disableNesting property, which Microsoft added to the beta version of Microsoft Graph in September 2026, keeps other groups out of a security group.
Defender for SQL bundles vulnerability assessment and Advanced Threat Protection. Microsoft recommends enabling the plan for the entire subscription so that servers created later are also covered.
Billing is per logical server. On October 27, 2026, the Azure retail price list showed $15 per server per month in West Europe and Germany West Central. Four servers cost $60.
Meanwhile, just one consolidated server costs $15 provided the firewall rules and the administrator fit every database on it – and a server with 20 databases costs the same as one with a single database.
The plan for Azure SQL is called SqlServers. The current CLI returns the plans as an object with a value field, so older guides that query [] instead of value[] come back empty.
In my test subscription, SqlServers was on the Free tier beforehand, meaning the plan was switched off; Standard turns it on. In the portal, the setting sits in Defender for Cloud under “Environment settings” -> subscription -> “Defender plans”.
My test subscription listed 18 plans, with CloudPosture, Discovery, and FoundationalCspm already on Standard.
After the CREATE command, however, SqlServers showed Standard as being active since 7:20:15 a.m:
az security pricing list --query "value[].{name:name, tier:pricingTier}" -o table
az security pricing create --name SqlServers --tier standard
Set-AzSecurityPricing -Name "SqlServers" -PricingTier "Standard"
Get-AzSecurityPricing -Name "SqlServers" | Select-Object Name, PricingTier, FreeTrialRemainingTime
Name PricingTier FreeTrialRemainingTime
---- ----------- ----------------------
SqlServers Standard 29.23:59:00The first activation includes a 30-day free trial.
Note that Microsoft will retire the classic application programming interfaces (APIs) for vulnerability assessment and alert policies on August 16, 2027.
The AuditClassicPolicies.ps1 script finds affected servers. In a test subscription, set the plan back to Free before day 31, when billing per server starts.
AuditClassicPolicies.ps1 only reads, so it needs PowerShell 7 and Az.Accounts 2.9.1 or later. It writes a comma-separated values (CSV) file listing every server that still uses the classic configuration, but won’t write anything if nothing is found.
10 seconds after I enabled the plan, Defender turned on the ‘express configuration of vulnerability’ assessment by itself. This doesn’t require a storage account, and a baseline takes effect without a new scan.
PowerShell doesn’t support it, but the Azure CLI reaches it through az rest with API version 2026-04-01-preview. The first request for scan results returned ResultsAreNotAvailableYet, because Defender schedules the recurring scan itself and doesn’t have any results before the first one.
In the classic configuration, a baseline only takes effect after the next scan – and, according to the vulnerability assessment overview, it’s one rule at a time. Storage accounts from a classic setup stay in place after the switch and still hold the historical scan data.
Running in the background, an on-demand scan took about two minutes and returned two findings across 24 rules. Wait until scans/latest returns a scan with the current start time before you read the results.
The output below is trimmed to the relevant fields:
$api = 'api-version=2026-04-01-preview'
$srvRes = az sql server show -g $rg -n $srv --query id -o tsv
$va = "$srvRes/databases/$db/providers/Microsoft.Security/sqlVulnerabilityAssessments/default"
az rest --method get --uri "$srvRes/providers/Microsoft.Security/sqlVulnerabilityAssessments/default?$api"
az rest --method post --uri "$va/scans/initiateScan?$api" # response 202 Accepted
az rest --method get --uri "$va/scans/latest?$api"
az rest --method get --uri "$va/scans/latest/scanResults?$api" `
--query "value[?properties.status=='Finding'].{Rule:name, Severity:properties.ruleMetadata.severity, Title:properties.ruleMetadata.title}" -o table
Trigger State High Medium Low Failed Total Baseline
OnDemand Failed 0 1 1 2 24 False
Rule Severity Title
VA1281 Medium All memberships for user-defined roles should be intended
VA2130 Low Track all users with access to the database
Both findings concern the group and the role I had just created. Vulnerability assessment flags every new permission until someone approves it.
While the baseline command from the documentation failed in PowerShell 7 with UnsupportedProperties, it did go through with the JavaScript Object Notation (JSON) body in a file.
'{"latestScan": true, "results": {}}' | Set-Content ./baseline.json
az rest --method post --uri "$va/baselineRules?$api" --body '@baseline.json'
az rest --method post --uri "$va/scans/initiateScan?$api"
az rest --method get --uri "$va/scans/latest?$api"
az rest --method get --uri "$va/scans/latest/scanResults?$api" `
--query "value[?properties.status=='Finding'].{Rule:name, Severity:properties.ruleMetadata.severity, Status:properties.status, WithBaseline:properties.baselineAdjustedResult.status}" -o table
Rule Severity Status WithBaseline
VA1281 Medium Finding NonFinding
VA2130 Low Finding NonFinding
Trigger State High Medium Low Failed Total Baseline
OnDemand Passed 0 0 0 0 24 TrueThe baseline took over four rules from the last scan: the two findings, plus VA1143 and VA1219 whose check queries had returned False, and which the scan had counted as passed.
The second scan only served as a check, however, because the baseline works without it when in express mode.

Finding and show NonFinding in the baseline-adjusted result.The raw status stays Finding, so scripts should evaluate baselineAdjustedResult.
Accepting the latest scan wholesale works for a fresh database, but not servers that have grown over the years; on these, it simply turns old mistakes into the target state.
There, only reviewed rules belong in the file, with latestScan set to false.
For single rules, meanwhile, set latestScan to false and list the accepted result rows per rule under results. For my test, that would be {"VA1281": [["sales_reader", "sql-sales-readers-st"]]}.
Advanced Threat Protection raises alerts such as SQL.DB_BruteForce and SQL.DB_PotentialSqlInjection.
In my test, a malformed statement with O'Brien' OR '1'='1 sent from the query editor triggered nothing, and at 10:03 a.m. the subscription showed zero alerts.
SQL.DB_GeoAnomaly then reported a sign-in from an unusual location, and SQL.DB_PrincipalAnomaly reported a principal that hasn’t appeared for 60 days.
For faulty statements from an application, Microsoft lists SQL.DB_VulnerabilityToSqlInjection with medium severity. My statement failed with “Incorrect syntax near ‘Brien’. Defender didn’t react.
Alert simulation only covers SQL Server on virtual machines and Azure Arc-enabled servers. For Azure SQL Database, that leaves a test application with an input field, pointed at a test server.
Failed sign-in series for a brute-force test belong in SSMS or sqlcmd, because the portal query editor doesn’t send SQL logins to the server after the switch.
In my test, four attempts from the query editor never reached it.
A SQLBits 2023 session on Advanced Threat Protection uses a small C# test application for this. An input value with OR 1=1 and an appended UNION ALL returns every email address from the customer table, and Defender reports a potential SQL injection with high severity:
az security alert list --query "[?contains(alertType,'SQL')].{alert:alertDisplayName,
severity:severity, start:startTimeUtc}" -o tableBy default, only subscription owners receive email, and only for high-severity alerts. Defender sends each address at most four emails a day for high severity: two for medium, and one for low.
In my test, the preview command group az security contact set the address and lowered the threshold to Medium.
(In the portal, the recipients sit in Defender for Cloud under “Environment settings” -> subscription -> “Email notifications.”)
Several recipients go into the same quoted string, separated by semicolons. In production, that should be the distribution list of the DBA team:
az security contact list -o json
az security contact update -n default --emails "thomas@hof-erbach.de" `
--alert-notifications "{state:On,minimalSeverity:Medium}" -o json
before: "alertNotifications": { "minimalSeverity": "High", "state": "On" }, "emails": ""
after: "alertNotifications": { "minimalSeverity": "Medium", "state": "On" }, "emails": "thomas@hof-erbach.de"
"notificationsByRole": { "roles": [ "Owner" ], "state": "On" }The default auditing policy records queries as well as successful and failed sign-ins. It writes them to the workspace through a diagnostic setting on master.
The parameters are --lats, short for --log-analytics-target-state, and --lawri, short for --log-analytics-workspace-resource-id. A guessed name such as --lat-workspace-resource-id fails with “unrecognized arguments.”
A plain -o table on the show command prints every property of the policy, so the --query in the last line trims the output to three columns:
az monitor log-analytics workspace create -g $rg -n law-simpletalk-test -l $loc
$lawId = az monitor log-analytics workspace show -g $rg -n law-simpletalk-test --query id -o tsv
az sql server audit-policy update -g $rg -n $srv --state Enabled --lats Enabled --lawri $lawId
az sql server audit-policy show -g $rg -n $srv `
--query "{State:state, LogAnalytics:isAzureMonitorTargetEnabled, Groups:join(', ', auditActionsAndGroups)}" -o table
State LogAnalytics Groups
Enabled True SUCCESSFUL_DATABASE_AUTHENTICATION_GROUP, FAILED_DATABASE_AUTHENTICATION_GROUP, BATCH_COMPLETED_GROUP
DedicatedThe CLI created the diagnostic setting on master with AzureDiagnostics, the old shared table, as its destination. Queries against SQLSecurityAuditEvents then find nothing.
A second command switches the destination to Dedicated, because --export-to-resource-specific exists only when the setting is created. It reuses $srvRes from the vulnerability assessment block.
In my test, the new workspace used the PerGB2018 pricing tier with 30 days of retention, and audit-policy update took about 60 seconds.
If master has several diagnostic settings, the second line of the block below lists all names, while the first takes only the first entry:
$diag = az monitor diagnostic-settings list --resource "$srvRes/databases/master" --query "[0].name" -o tsv
az monitor diagnostic-settings list --resource "$srvRes/databases/master" `
--query "[].{name:name, dest:logAnalyticsDestinationType}" -o table # dest: AzureDiagnostics
az monitor diagnostic-settings update --name $diag --resource "$srvRes/databases/master" `
--set logAnalyticsDestinationType=Dedicated # dest: DedicatedEven then, the workspace stayed empty for hours. At 10:02 a.m., two and a half hours after I enabled auditing, search * returned no records, although the diagnostic setting pointed to the workspace with the destination Dedicated. A test statement from 9:02 a.m. never arrived at all.
The first records in SQLSecurityAuditEvents date from 12:28 p.m., almost four hours after the switch to Dedicated, and from then on new events showed up within a few minutes.
The resource providers Microsoft.Insights, Microsoft.OperationalInsights, and Microsoft.Sql were registered.
In a session on Azure SQL auditing from August 2022, experienced DBA Josephine Bush expects 30 minutes to two hours before the first entries appear, so my test took about twice as long as her upper estimate. Auditing doesn’t record anything retroactively, and the data begins when the policy is switched on.
Allow several hours before the first evaluation. Before you build alert rules, run search * in the Logs view of the workspace to confirm that data is arriving. Log Analytics retains data for 30 days by default, and for up to two years at extra cost.
David Postlethwaite, a DBA at the Copenhagen-based financial services company Banking Circle, sends all diagnostic categories to one shared workspace and passes on a colleague’s warning about large data volumes and costs in a SQL Day 2025 session.
In his audit data, the never-used SQL administrator signs in four times, which he attributes to background work by Microsoft. After the switch to Entra-only, every sign-in of that account fails, so a hit for it deserves attention.
I ran the following Kusto Query Language (KQL) queries in the afternoon, once records were arriving, and checked the column names against the SQLSecurityAuditEvents table reference.
The first counts failed sign-ins per account over the past 24 hours and collects the source IP addresses.
Microsoft states that failed Entra sign-ins don’t appear in the audit log and points to the Entra sign-in logs instead, because wrong Entra credentials never reach the database. Connections that the gateway rejects are a different case.
In my test, the query returned two failures for my Entra account: error 40615 while the firewall didn’t know my new IP address yet, and error 47073 while public access was denied.
After the switch to Entra-only, the query also catches rejected SQL logins, for example from old applications or from attacks on sqladminst.
Failed Entra credentials show up in the Entra ID sign-in logs, in the workspace as the SigninLogs table if the tenant’s diagnostic setting sends them there:
SQLSecurityAuditEvents
| where TimeGenerated > ago(24h)
| where ActionName == "DATABASE AUTHENTICATION FAILED"
| summarize Failures = count(), Sources = make_set(ClientIp)
by ServerPrincipalName, DatabaseName
| order by Failures desc
DatabaseName Failures ServerPrincipalName Sources
------------- -------- -------------------- ---------------
sqldb-st-test 2 thomas@hof-erbach.de ["<client IP>"]
The second lists successful sign-ins outside business hours. EventTime is in Coordinated Universal Time (UTC), so the query converts it with datetime_utc_to_local(), which also handles daylight saving time.
(Replace Europe/London with your own time zone.)
In dayofweek(), 0d is Sunday and 6d is Saturday. All of my test sign-ins fell within business hours, so the query returned no rows:
SQLSecurityAuditEvents
| where TimeGenerated > ago(7d)
| where Succeeded == true
| where ActionName has "AUTHENTICATION"
| extend LocalTime = datetime_utc_to_local(EventTime, "Europe/London")
| where hourofday(LocalTime) < 7 or hourofday(LocalTime) >= 19 or dayofweek(LocalTime) in (0d, 6d)
| project EventTime, ServerPrincipalName, ClientIp, DatabaseName, ApplicationNameThe third finds permission changes such as ALTER ROLE ... ADD MEMBER in the logged statements. It caught the GRANT from the reader group section, which I ran again at 12:37 p.m. for this test, and the record was in the workspace less than four minutes later.
You can save each query as an alert rule in the workspace. The first one then fires when failed sign-ins cross a threshold your team defines, and BATCH_COMPLETED_GROUP records the text of every statement up to 4,000 characters.
If an existing diagnostic setting stays on AzureDiagnostics, the queries start with AzureDiagnostics | where Category == "SQLSecurityAuditEvents", and the columns carry suffixes, for example action_name_s instead of ActionName:
SQLSecurityAuditEvents
| where TimeGenerated > ago(7d)
| where Statement has_any ("GRANT ", "REVOKE ", "DENY ", "ALTER ROLE", "CREATE USER", "DROP USER")
| project EventTime, ServerPrincipalName, DatabaseName, Statement
| order by EventTime desc
EventTime ServerPrincipalName DatabaseName Statement
------------------------ -------------------- ------------- -------------------------------------------------
2026-10-27T11:37:02.928Z thomas@hof-erbach.de sqldb-st-test GRANT SELECT ON SCHEMA::SalesLT TO sales_reader;A private endpoint gives the server an address inside a virtual network, but on its own it doesn’t block public access.
I built mine in the afternoon along the lines of Microsoft’s tutorial, with --group-ids sqlServer and a private Domain Name System (DNS) zone.
Two details differed in my subscription. Clients reach it through Azure ExpressRoute, a virtual private network (VPN), or peering, and the setting “Deny public network access” in the portal’s “Networking” blade stays off until you set it.
The resource group sits in West Europe, where I created it before Azure rejected the first server. Without -l, the endpoint inherited that region and failed with the same RequestDisallowedByAzure error as the first server.
With -l set to the region of the virtual network, however, it went through – and Azure approved the connection to the server automatically.
The private DNS zone then held an A record that pointed sql-st-joos-1027 to 10.20.1.4:
az network vnet create -g $rg -n vnet-simpletalk-test -l $loc --address-prefixes 10.20.0.0/16 `
--subnet-name snet-sql --subnet-prefixes 10.20.1.0/24
$srvRes = az sql server show -g $rg -n $srv --query id -o tsv
az network private-link-resource list --id $srvRes --query "[].properties.groupId" -o tsv
az network private-endpoint create -g $rg -n pe-sql-st-joos-1027 -l $loc `
--vnet-name vnet-simpletalk-test --subnet snet-sql `
--private-connection-resource-id $srvRes `
--group-ids sqlServer --connection-name pe-sql-st-joos-1027
az network private-dns zone create -g $rg -n "privatelink.database.windows.net"
az network private-dns link vnet create -g $rg --zone-name "privatelink.database.windows.net" `
--name link-vnet-simpletalk-test --virtual-network vnet-simpletalk-test --registration-enabled false
az network private-endpoint dns-zone-group create -g $rg --endpoint-name pe-sql-st-joos-1027 `
--name sql-zone-group --private-dns-zone "privatelink.database.windows.net" --zone-name sqlThe second detail concerns the test client. New subnets came up with defaultOutboundAccess set to false, so the VM got a subnet of its own with outbound access to download go-sqlcmd from GitHub.
go-sqlcmd is Microsoft’s newer, Go-based sqlcmd, which supports managed identity sign-in. The Ubuntu 24.04 image I used didn’t include bzip2, which the go-sqlcmd archive needs, so the script installs it first.
The VM doesn’t have a network security group (NSG) or public IP address of its own. Instead, its managed identity got a contained user in the application role from earlier:
# test VM with a system-assigned managed identity and no public IP
az network vnet subnet create -g $rg --vnet-name vnet-simpletalk-test -n snet-vm `
--address-prefixes 10.20.2.0/24 --default-outbound-access true
az vm create -g $rg -n vm-st-test -l $loc --image Ubuntu2404 --size Standard_B1s `
--vnet-name vnet-simpletalk-test --subnet snet-vm --public-ip-address '' --nsg '' `
--assign-identity --admin-username azureuser --generate-ssh-keys
CREATE USER [vm-st-test] FROM EXTERNAL PROVIDER;
ALTER ROLE app_sales_rw ADD MEMBER [vm-st-test];I ran the script inside the VM with az vm run-command invoke, so the VM needs neither a public IP address nor Secure Shell (SSH) access:
# vmtest.sh, run with: az vm run-command invoke -g $rg -n vm-st-test --command-id RunShellScript --scripts '@vmtest.sh'
export HOME=/tmp; cd /tmp
apt-get update -qq && apt-get install -y -qq bzip2
curl -sSL -o sqlcmd.tar.bz2 https://github.com/microsoft/go-sqlcmd/releases/latest/download/sqlcmd-linux-amd64.tar.bz2
tar xjf sqlcmd.tar.bz2 sqlcmd
S=sql-st-joos-1027.database.windows.net
getent hosts $S
./sqlcmd -S $S -d sqldb-st-test --authentication-method ActiveDirectoryManagedIdentity -W \
-Q "SELECT SUSER_SNAME() AS login_name, USER_NAME() AS db_user, IS_MEMBER('app_sales_rw') AS in_app_role,
(SELECT COUNT(*) FROM SalesLT.Customer) AS customers, CONNECTIONPROPERTY('client_net_address') AS client_ip"
10.20.1.4 sql-st-joos-1027.privatelink.database.windows.net sql-st-joos-1027.database.windows.net
login_name db_user in_app_role customers client_ip
<client ID>@<tenant ID> vm-st-test 1 847 10.20.2.4
The VM resolved the server name to the private address and signed in with its managed identity. The server saw 10.20.2.4, the VM’s address in the virtual network, as the client.
The query also read all 847 rows of SalesLT.Customer – which the app_sales_rw role permits – and only then did I close the public path (Microsoft labels --enable-public-network as preview.)
In my test, PublicNetworkAccess changed to Disabled within 30 seconds, and the same sign-in from the VM still worked 30 seconds later:
# only after a successful test over the private path
az sql server update -g $rg -n $srv --enable-public-network falseTest-NetConnection on my Windows workstation still reported success, because the regional gateway, the Azure SQL entry point for all servers in the region, accepts connections on port 1433 and rejects them only at sign-in.
The portal query editor reported “An instance-specific error occurred while establishing a connection to SQL Server. Connection was denied because Deny Public Network Access is set to Yes.”
Clients keep using the regular server name, and name resolution then tells you whether that name already points to the private address.
The output below comes from my workstation that morning, before the endpoint existed, so the name chain still ends at the public gateway.
The port test ran while public access was briefly closed. Inside the virtual network, the same name resolved to 10.20.1.4 (Figure 6).
A test connection with SQL authentication, also from my workstation, got the message “Azure Active Directory only authentication is enabled” in the same state and no hint of the network block.
Sign-ins through the private IP address or the privatelink name fail on purpose, because the gateway needs the regular server name to route the connection:
PS> Test-NetConnection sql-st-joos-1027.database.windows.net -Port 1433
RemoteAddress : 51.116.149.32
RemotePort : 1433
TcpTestSucceeded : True # even with --enable-public-network false
PS> Resolve-DnsName sql-st-joos-1027.database.windows.net
sql-st-joos-1027.database.windows.net CNAME dataslice3.germanywestcentral1.database.windows.net
dataslice3.germanywestcentral1.database.windows.net CNAME dataslice3germanywestcentral.trafficmanager.net
dataslice3germanywestcentral.trafficmanager.net CNAME cr6.germanywestcentral1-a.control.database.windows.net
With a private endpoint, Microsoft recommends the Redirect connection policy, which requires ports 1433 through 65535.
My test server was set to Default, under which connections through a private endpoint run as Proxy over port 1433. I left it on Default, so the update command in the block below is untested.
Admins working from laptops need a point-to-site VPN with private name resolution before the public path closes. Over the public endpoint, Redirect needs ports 11000 to 11999 in addition, according to the connectivity architecture.
A point-to-site VPN into the hub network, a private DNS zone, and Azure DNS Private Resolver let SSMS on an admin workstation resolve the private endpoint, as a walkthrough from August 2024 shows.
Without that path, SSMS fails with error 47073 once the public path is closed:
az sql server conn-policy show -g $rg -s $srv --query connectionType -o tsv # Default
az sql server conn-policy update -g $rg -s $srv --connection-type RedirectBefore the switch, an Entra group that includes an emergency account should be the server administrator, every application should have a contained user, and the SID check should show no login-based users.
az sql server ad-only-auth enable, then az sql server update --enable-public-network false.Allow 90 minutes between revoking a permission and checking it, and 24 hours for managed identities. Defender, alert recipients, auditing with data you have seen arrive, and a tested private path complete the list.
After that, ad-only-auth enable and --enable-public-network false are two short commands – and three more remove the test environment.
The first of them sets Defender for SQL to Free for every server in the subscription, so leave it out if the subscription also holds production databases.
The security contact from the Defender section stays in place at the subscription level, so set it back if you changed it only for the test:
# sets Defender for SQL to Free for every server in the subscription
az security pricing create --name SqlServers --tier free
az group delete -n rg-simpletalk-test --yes --no-wait
"sql-admins-st-test", "sql-sales-readers-st", "sql-nested-inner-st" | ForEach-Object { az ad group delete --group $_ }| Error | What it means in this article |
|---|---|
| 18456 | A SQL login was used after the switch (“Azure Active Directory only authentication is enabled”), so the application still needs migrating. It also appeared for group users whose logins in master had been deleted. |
| 33131 | CREATE USER failed because two objects share a display name. |
| 33134 | “Server identity is not configured”: automation under a managed identity needs a server identity with the Graph permissions. A Conditional Access policy blocking the lookup causes it too. |
| 40615 | The firewall doesn’t know the client’s IP address yet. |
| 47073 | Public network access is denied, so connect through the private path. |
RequestDisallowedByAzure | The region isn’t accepting new customers. Deploy to another region. |
Every SQL login stops working. Entra-only authentication disables SQL authentication for the whole logical server, so SQL logins, SQL-authenticated database users, and the SQL server administrator lose access to every database. Connection attempts fail with error 18456 and a message saying Microsoft Entra-only authentication is enabled. Turning the feature off again brings SQL logins back.
Yes. Running az sql server ad-only-auth disable reverses the change and brings SQL logins back. You need an Azure role that allows it, such as SQL Security Manager on the server, and a Microsoft Entra administrator must already be set. Keep an emergency access account protected with a FIDO2 passkey so someone can always make the change.
Applications sign in with a managed identity instead of a password. Use Authentication=Active Directory Default to use the managed identity in Azure and the developer’s own sign-in on a workstation, or Active Directory Managed Identity for the stricter option. Then, run CREATE USER FROM EXTERNAL PROVIDER in the database and add the user to a role with only the permissions it needs.
Group membership comes from the client’s access token, so a change applies only once a new token is issued. In testing, a nested group took effect after 66 minutes, and Microsoft documents a random token lifetime of 60 to 90 minutes. A revoked permission can stay in effect for up to 24 hours for managed identities. DBCC FLUSHAUTHCACHE didn’t speed it up.
Defender for SQL is billed per logical server, not per database. On October 27, 2026, the Azure retail price list showed $15 per server per month in West Europe and Germany West Central. A server with 20 databases costs the same as one with a single database. The first activation includes a 30-day free trial.
The post How to enable Entra-only authentication on Azure SQL without locking anyone out appeared first on Simple Talk.