{"id":114118,"date":"2026-12-04T12:00:00","date_gmt":"2026-12-04T12:00:00","guid":{"rendered":"https:\/\/www.red-gate.com\/simple-talk\/?p=114118"},"modified":"2026-11-11T13:48:36","modified_gmt":"2026-11-11T13:48:36","slug":"azure-sql-entra-only-authentication-defender","status":"publish","type":"post","link":"https:\/\/www.red-gate.com\/simple-talk\/databases\/azure-sql-entra-only-authentication-defender\/","title":{"rendered":"How to enable Entra-only authentication on Azure SQL without locking anyone out"},"content":{"rendered":"\n<blockquote class=\"wp-block-quote is-layout-flow wp-block-quote-is-layout-flow\">\n<p class=\"wp-block-paragraph\"><strong>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. <\/strong><\/p>\n\n\n\n<p class=\"wp-block-paragraph\">The logical server is the <a href=\"https:\/\/www.red-gate.com\/simple-talk\/cloud\/azure\/\" target=\"_blank\" rel=\"noreferrer noopener\">Azure<\/a> 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. <\/p>\n\n\n\n<p class=\"wp-block-paragraph\"><strong>This article walks through that plan<\/strong>, 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.<\/p>\n\n\n\n<div id=\"callout-block_5c36b2c12ce8a2af1232bc5866b34c8f\" class=\"callout alignnone\">\n    <div class=\"child-last:mb-0 child-first:mt-0 bg-gray-50 dark:bg-gray-950 p-4xl my-3xl\">\n\n<p class=\"wp-block-paragraph\"><em>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.<\/em><\/p>\n\n<\/div>\n<\/div> \n\n\n<h2 id=\"h-what-entra-only-authentication-disables-in-azure-sql\" class=\"wp-block-heading\">What Entra-only authentication disables in Azure SQL<\/h2>\n\n\n\n<p class=\"wp-block-paragraph\" id=\"h-what-entra-only-authentication-disables-in-azure-sqlonce-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\">Once enabled, the feature <strong>disables SQL authentication for the entire logical server<\/strong>. This means SQL logins, users with SQL authentication, and the SQL server administrator <a href=\"https:\/\/learn.microsoft.com\/en-us\/azure\/azure-sql\/database\/authentication-azure-ad-only-authentication?view=azuresql\" target=\"_blank\" rel=\"noreferrer noopener\">lose access to every database<\/a> &#8211; and you can only turn the feature on or off <strong><em>after<\/em> a Microsoft Entra administrator has been set on the server<\/strong>.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\" id=\"h-what-entra-only-authentication-disables-in-azure-sqlonce-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&#8217;re both Azure roles as opposed to roles <em>inside<\/em> <a href=\"https:\/\/www.red-gate.com\/simple-talk\/databases\/sql-server\/\" target=\"_blank\" rel=\"noreferrer noopener\">SQL Server<\/a>. Put simply, a SQL Server Contributor sets the administrator, and a SQL Security Manager turns the feature on or off.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\" id=\"h-what-entra-only-authentication-disables-in-azure-sqlonce-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\">Owners, Contributors, or a custom role with both sets of <a href=\"https:\/\/www.red-gate.com\/simple-talk\/databases\/sql-server\/sql-server-security-guide-access-control-permissions-roles-logins\/\" target=\"_blank\" rel=\"noreferrer noopener\">permissions<\/a> can handle both steps at once &#8211; and <strong>turning the feature off again brings SQL logins back.<\/strong><\/p>\n<\/blockquote>\n\n\n\n<figure class=\"wp-block-table\"><table class=\"has-fixed-layout\"><thead><tr><th>Task<\/th><th>Azure role needed<\/th><\/tr><\/thead><tbody><tr><td>Set the Microsoft Entra administrator<\/td><td>SQL Server Contributor<\/td><\/tr><tr><td>Turn Entra-only authentication on or off<\/td><td>SQL Security Manager<\/td><\/tr><tr><td>Do both<\/td><td>Owner, Contributor, or a custom role with both sets of permissions<\/td><\/tr><\/tbody><\/table><\/figure>\n\n\n\n<h3 id=\"h-features-that-don-t-work-with-entra-only-authentication\" class=\"wp-block-heading\">Features that don\u2019t work with Entra-only authentication<\/h3>\n\n\n\n<p class=\"wp-block-paragraph\">Some features don&#8217;t work with Entra-only at all &#8211; or they <em>do<\/em> work, but with restrictions. These include <a href=\"https:\/\/docs.azure.cn\/en-us\/azure-sql\/database\/elastic-jobs-overview?view=azuresql\" target=\"_blank\" rel=\"noreferrer noopener\">Elastic Jobs<\/a>, SQL Data Sync, <a href=\"https:\/\/www.red-gate.com\/simple-talk\/databases\/sql-server\/database-administration-sql-server\/how-to-set-up-transactional-replication\/\" target=\"_blank\" rel=\"noreferrer noopener\">transactional replication<\/a> into the database, and <a href=\"https:\/\/learn.microsoft.com\/en-us\/sql\/t-sql\/statements\/execute-as-transact-sql?view=sql-server-ver17\" target=\"_blank\" rel=\"noreferrer noopener\">EXEC AS<\/a> for group members. Check that list against your environment before you start. <\/p>\n\n\n\n<p class=\"wp-block-paragraph\">Microsoft&#8217;s list also names change data capture with a mix of SQL and Entra users. SQL Insights was on the list too, but Microsoft <a href=\"https:\/\/learn.microsoft.com\/en-us\/azure\/azure-sql\/database\/sql-insights-overview?view=azuresql\" target=\"_blank\" rel=\"noreferrer noopener\">retired the service in December 2024<\/a>.<\/p>\n\n\n\n<h3 id=\"h-create-the-test-server\" class=\"wp-block-heading\">Create the test server<\/h3>\n\n\n\n<p class=\"wp-block-paragraph\">My test used a Basic-tier database with the <code>AdventureWorksLT<\/code> sample. In West Europe, Azure rejected the new server with <code>RequestDisallowedByAzure<\/code> and a note that the region wasn&#8217;t accepting new customers. <\/p>\n\n\n\n<p class=\"wp-block-paragraph\">Germany West Central, meanwhile, deployed without errors, and the resource group stayed in West Europe (important later for the private endpoint.)<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">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:<\/p>\n\n\n\n<div class=\"wp-block-urvanov-syntax-highlighter-code-block\"><pre class=\"lang:tsql decode:true \">$rg='rg-simpletalk-test'; $loc='germanywestcentral'; $srv='sql-st-joos-1027'; $db='sqldb-st-test'\n$pw = Read-Host -Prompt \"SQL admin password\" -MaskInput\n \naz group create -n $rg -l westeurope   # created during the first attempt in West Europe\naz sql server create -g $rg -n $srv -l $loc --admin-user sqladminst --admin-password $pw\naz sql db create -g $rg -s $srv -n $db --edition Basic --sample-name AdventureWorksLT --backup-storage-redundancy Local\naz sql server firewall-rule create -g $rg -s $srv -n AllowAdminPC `\n  --start-ip-address \"&lt;public IP&gt;\" --end-ip-address \"&lt;public IP&gt;\"<\/pre><\/div>\n\n\n\n<h2 id=\"h-use-a-microsoft-entra-group-as-the-azure-sql-administrator\" class=\"wp-block-heading\">Use a Microsoft Entra group as the Azure SQL administrator<\/h2>\n\n\n\n<p class=\"wp-block-paragraph\">Azure SQL stores the Entra administrator as a user in <code>master<\/code>, but a security group with two or three named <a href=\"https:\/\/www.red-gate.com\/simple-talk\/career\/what-does-a-modern-dba-actually-do-6-key-points-from-a-senior-dba\/\" target=\"_blank\" rel=\"noreferrer noopener\">database administrators (DBAs)<\/a> is the better choice. <\/p>\n\n\n\n<p class=\"wp-block-paragraph\">The server then still has an administrator who can sign in after one of them leaves the company. <\/p>\n\n\n\n<p class=\"wp-block-paragraph\">The block below sets the group with <a href=\"https:\/\/learn.microsoft.com\/en-us\/cli\/azure\/sql\/server\/ad-admin?view=azure-cli-latest\" target=\"_blank\" rel=\"noreferrer noopener\"><code>az sql server ad-admin create<\/code><\/a> and also creates <code>sql-sales-readers-st<\/code>, the reader group I use later:<\/p>\n\n\n\n<div class=\"wp-block-urvanov-syntax-highlighter-code-block\"><pre class=\"lang:tsql decode:true \">$grpId = az ad group create --display-name \"sql-admins-st-test\" --mail-nickname \"sql-admins-st-test\" --query id -o tsv\naz ad group member add --group $grpId --member-id (az ad signed-in-user show --query id -o tsv)\n \naz sql server ad-admin create -g $rg -s $srv --display-name \"sql-admins-st-test\" --object-id $grpId\n \naz ad group create --display-name \"sql-sales-readers-st\" --mail-nickname \"sql-sales-readers-st\"   # reader group used later\n<\/pre><\/div>\n\n\n\n<p class=\"wp-block-paragraph\">In <a href=\"https:\/\/www.red-gate.com\/simple-talk\/sysadmin\/powershell\/\" target=\"_blank\" rel=\"noreferrer noopener\">PowerShell<\/a>, <code>Set-AzSqlServerActiveDirectoryAdministrator<\/code> does the same thing. The setup fails if <code>master<\/code> already contains a user with the group&#8217;s name:<\/p>\n\n\n\n<div class=\"wp-block-urvanov-syntax-highlighter-code-block\"><pre class=\"lang:tsql decode:true \">Set-AzSqlServerActiveDirectoryAdministrator -ResourceGroupName \"rg-simpletalk-test\" `\n  -ServerName \"sql-st-joos-1027\" -DisplayName \"sql-admins-st-test\"<\/pre><\/div>\n\n\n\n<h2 id=\"h-set-up-an-emergency-access-account-first\" class=\"wp-block-heading\">Set up an emergency access account first<\/h2>\n\n\n\n<p class=\"wp-block-paragraph\">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. <\/p>\n\n\n\n<p class=\"wp-block-paragraph\">Since nobody knows that password, the account offers no emergency path.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">Microsoft recommends <a href=\"https:\/\/learn.microsoft.com\/en-us\/entra\/identity\/role-based-access-control\/security-emergency-access\" target=\"_blank\" rel=\"noreferrer noopener\">two emergency accounts in the tenant<\/a>, protected with a <a href=\"https:\/\/www.microsoft.com\/en-gb\/security\/business\/security-101\/what-is-fido2\" target=\"_blank\" rel=\"noreferrer noopener\">FIDO2 (Fast IDentity Online 2)<\/a> passkey and excluded from blocking <a href=\"https:\/\/learn.microsoft.com\/en-us\/entra\/identity\/conditional-access\/overview\" target=\"_blank\" rel=\"noreferrer noopener\">Conditional Access<\/a> policies. One of them belongs in the administrator group. <\/p>\n\n\n\n<p class=\"wp-block-paragraph\">To turn Entra-only off in an emergency, that account also needs an Azure role such as SQL Security Manager on the server. <\/p>\n\n\n\n<p class=\"wp-block-paragraph\"><strong>Test the emergency path at least once before the switch<\/strong>, for example by signing in with the emergency account in <a href=\"https:\/\/www.red-gate.com\/simple-talk\/opinion\/editorials\/sql-server-management-studio-is-as-relevant-as-ever\/\" target=\"_blank\" rel=\"noreferrer noopener\">SQL Server Management Studio (SSMS)<\/a> and running <code>SELECT SUSER_SNAME()<\/code>.<\/p>\n\n\n\n<h2 id=\"h-enable-entra-only-authentication-with-the-azure-cli-or-powershell\" class=\"wp-block-heading\">Enable Entra-only authentication with the Azure CLI or PowerShell<\/h2>\n\n\n\n<p class=\"wp-block-paragraph\">I turned the feature on at this point in my test because no application was using the database yet. <strong>In production, it comes last: after every application has moved over<\/strong> &#8211; and <em>after<\/em> you have checked your own Entra session with <code>SELECT SUSER_SNAME(), IS_MEMBER('db_owner')<\/code>. <\/p>\n\n\n\n<p class=\"wp-block-paragraph\">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&#8217;t know about a group you were just added to. <\/p>\n\n\n\n<p class=\"wp-block-paragraph\">The Azure command-line interface (CLI) needs version 2.14.2 or later, and <a href=\"https:\/\/learn.microsoft.com\/en-us\/cli\/azure\/sql\/server\/ad-only-auth?view=azure-cli-latest\" target=\"_blank\" rel=\"noreferrer noopener\"><code>az sql server ad-only-auth disable<\/code><\/a> reverses the change.<\/p>\n\n\n\n<h3 id=\"h-run-the-enable-command-and-verify-it\" class=\"wp-block-heading\">Run the <code>enable<\/code> command and verify it<\/h3>\n\n\n\n<p class=\"wp-block-paragraph\">I switched with <code>az sql server ad-only-auth enable<\/code>. The first block below shows the PowerShell cmdlet that does the same, and the third block shows the CLI commands with their output. <\/p>\n\n\n\n<p class=\"wp-block-paragraph\">Inside the database, <code>SERVERPROPERTY('IsExternalAuthenticationOnly')<\/code> returns 1 once the feature is on, and 0 while it is off:<\/p>\n\n\n\n<div class=\"wp-block-urvanov-syntax-highlighter-code-block\"><pre class=\"lang:tsql decode:true \">Enable-AzSqlServerActiveDirectoryOnlyAuthentication -ResourceGroupName \"rg-simpletalk-test\" -ServerName \"sql-st-joos-1027\"\nSELECT SERVERPROPERTY('IsExternalAuthenticationOnly') AS entra_only,\n       SUSER_SNAME() AS login, DB_NAME() AS db;\nPS&gt; az sql server ad-only-auth get -g rg-simpletalk-test -n sql-st-joos-1027 -o table\nAzureAdOnlyAuthentication    Name     ResourceGroup\n---------------------------  -------  ------------------\nFalse                        Default  rg-simpletalk-test\n \nPS&gt; az sql server ad-only-auth enable -g rg-simpletalk-test -n sql-st-joos-1027 -o table\nAzureAdOnlyAuthentication    Name     ResourceGroup\n---------------------------  -------  ------------------\nTrue                         Default  rg-simpletalk-test\nentra_only  login                 db\n0           sqladminst            sqldb-st-test    -- before, SQL login\n1           thomas@hof-erbach.de  sqldb-st-test    -- after, Entra account<\/pre><\/div>\n\n\n\n<h3 id=\"h-what-do-sql-logins-see-after-the-switch\" class=\"wp-block-heading\">What do SQL logins see after the switch?<\/h3>\n\n\n\n<p class=\"wp-block-paragraph\">From then on, every SQL login fails with error 18456 and the message &#8220;Login failed for user &#8216;sqladminst&#8217;. Reason: Azure Active Directory only authentication is enabled.&#8221; <\/p>\n\n\n\n<p class=\"wp-block-paragraph\">At 9:07 a.m., a <code>SqlClient<\/code> script on my workstation with three wrong passwords got exactly the same message as the correct password did. <\/p>\n\n\n\n<p class=\"wp-block-paragraph\">The message doesn&#8217;t tell an attacker whether a password was correct but, even if that message shows up in an application log <em>after<\/em> the switch, the application still needs to be migrated.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">After a page reload, the portal&#8217;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.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">In my test, the query editor had still been connected as <code>sqladminst<\/code> before the switch, and the server rejected that session with the same message on the next query. <\/p>\n\n\n\n<h3 id=\"h-enable-entra-only-on-new-servers-and-enforce-it-with-azure-policy\" class=\"wp-block-heading\">Enable Entra-only on new servers and enforce it with Azure Policy<\/h3>\n\n\n\n<p class=\"wp-block-paragraph\">For new servers, <code>az sql server create<\/code> with <code>--enable-ad-only-auth<\/code> and the <code>--external-admin-*<\/code> parameters turns the feature on from the start (<a href=\"https:\/\/learn.microsoft.com\/en-us\/cli\/azure\/sql\/server?view=azure-cli-latest)\" target=\"_blank\" rel=\"noreferrer noopener\"><code>az sql server<\/code><\/a>). <\/p>\n\n\n\n<p class=\"wp-block-paragraph\">Across a subscription, the built-in Azure Policy &#8220;Azure SQL Database should have Microsoft Entra-only authentication enabled&#8221; checks the setting.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">Its default effect is Audit, and with the effect Deny it <a href=\"https:\/\/learn.microsoft.com\/en-us\/azure\/azure-sql\/database\/authentication-azure-ad-only-authentication-policy-how-to?view=azuresql\" target=\"_blank\" rel=\"noreferrer noopener\">blocks new logical servers without Entra-only<\/a>.<\/p>\n\n\n\n<h2 id=\"h-connect-applications-with-managed-identities\" class=\"wp-block-heading\">Connect applications with managed identities<\/h2>\n\n\n\n<p class=\"wp-block-paragraph\"><strong>A connection string with a password stops working after the switch. <\/strong><\/p>\n\n\n\n<p class=\"wp-block-paragraph\">Instead, the application signs in with the managed identity of its App Service, Azure Function, or virtual machine &#8211; an identity Azure manages <em>without<\/em> a stored password. <\/p>\n\n\n\n<p class=\"wp-block-paragraph\"><code><a href=\"https:\/\/learn.microsoft.com\/en-us\/azure\/app-service\/tutorial-connect-msi-sql-database\" target=\"_blank\" rel=\"noreferrer noopener\">Authentication=Active Directory Default<\/a> <\/code>uses the managed identity in Azure, and the developer&#8217;s own sign-in is used on a workstation.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">For an application that should use the managed identity and nothing else, <code>Authentication=Active Directory Managed Identity<\/code> is the stricter option. <\/p>\n\n\n\n<p class=\"wp-block-paragraph\">I tested the managed identity path with a small <a href=\"https:\/\/ubuntu.com\/tutorials\/how-to-run-ubuntu-desktop-on-a-virtual-machine-using-virtualbox#1-overview\" target=\"_blank\" rel=\"noreferrer noopener\">Ubuntu virtual machine (VM)<\/a> that connects through the private endpoint, described further down. <\/p>\n\n\n\n<p class=\"wp-block-paragraph\"><em>Important note for auditing: <code>SUSER_SNAME()<\/code> returned the identity&#8217;s client ID and tenant ID instead of the VM name.<\/em><\/p>\n\n\n\n<div class=\"wp-block-urvanov-syntax-highlighter-code-block\"><pre class=\"lang:tsql decode:true \">Server=tcp:sql-st-joos-1027.database.windows.net;Authentication=Active Directory \nDefault;Database=sqldb-st-test;<\/pre><\/div>\n\n\n\n<h2 id=\"h-add-database-users-with-create-user-from-external-provider\" class=\"wp-block-heading\">Add database users with <code>CREATE USER \u2026 FROM EXTERNAL PROVIDER<\/code><\/h2>\n\n\n\n<p class=\"wp-block-paragraph\">This is where migrations usually break, since the identity <em>exists<\/em> in Azure but the database doesn&#8217;t know about it yet. A role per application with permissions on its own schema keeps access tighter than <code>db_datareader<\/code> and <code>db_datawriter<\/code>. <\/p>\n\n\n\n<p class=\"wp-block-paragraph\">You create the user with an Entra account that holds the <code>ALTER ANY USER<\/code> permission:<\/p>\n\n\n\n<div class=\"wp-block-urvanov-syntax-highlighter-code-block\"><pre class=\"lang:tsql decode:true \">-- requires an existing managed identity with the display name app-sales-st\nCREATE USER [app-sales-st] FROM EXTERNAL PROVIDER;\nCREATE ROLE app_sales_rw;\nGRANT SELECT, INSERT, UPDATE ON SCHEMA::SalesLT TO app_sales_rw;\nALTER ROLE app_sales_rw ADD MEMBER [app-sales-st];<\/pre><\/div>\n\n\n\n<h3 id=\"h-fix-error-33131-when-two-objects-share-a-display-name\" class=\"wp-block-heading\">Fix error 33131 when two objects share a display name<\/h3>\n\n\n\n<p class=\"wp-block-paragraph\">If two objects share a display name, <code>CREATE USER<\/code> fails with error 33131. Microsoft describes <a href=\"https:\/\/learn.microsoft.com\/en-us\/sql\/t-sql\/statements\/create-user-transact-sql?view=azuresqldb-current\" target=\"_blank\" rel=\"noreferrer noopener\"><code>WITH OBJECT_ID<\/code><\/a> as a repair option for exactly that case, and advises <em>against<\/em> it for unique names. <\/p>\n\n\n\n<p class=\"wp-block-paragraph\">When a user runs <code>CREATE USER<\/code>, Azure SQL queries Microsoft Graph with that user&#8217;s permissions. My test server had no server identity, and <code>az sql server show<\/code> reported <code>identity: null<\/code>. <\/p>\n\n\n\n<p class=\"wp-block-paragraph\">However, Azure SQL still created the user for the reader group <code>sql-sales-readers-st<\/code> in 0.7 seconds, and in the afternoon it did the same for the managed identity of my test VM. <\/p>\n\n\n\n<p class=\"wp-block-paragraph\">I didn&#8217;t create <code>app-sales-st<\/code> 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 &#8211; the first five characters of the object ID, for example, so it stays clear which identity is behind it.<\/p>\n\n\n\n<h3 id=\"h-set-up-a-server-identity-for-automation-error-33134\" class=\"wp-block-heading\">Set up a server identity for automation (error 33134)<\/h3>\n\n\n\n<p class=\"wp-block-paragraph\">Deployment pipelines and other automation that run under a managed identity behave differently. They need a <a href=\"https:\/\/learn.microsoft.com\/en-us\/azure\/azure-sql\/database\/authentication-aad-service-principal?view=azuresql\" target=\"_blank\" rel=\"noreferrer noopener\">server identity with <code>User.Read.All<\/code>, <code>GroupMember.Read.All<\/code>, and <code>Application.Read.All<\/code><\/a>, or they fail with error 33134. <\/p>\n\n\n\n<p class=\"wp-block-paragraph\">An application can&#8217;t act on behalf of another application, so Azure SQL falls back to the server identity, and the error text reads &#8220;Server identity is not configured.&#8221; <\/p>\n\n\n\n<p class=\"wp-block-paragraph\">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.<\/p>\n\n\n\n<section id=\"my-first-block-block_44d92923aa52f7686f590c2faff58892\" class=\"my-first-block alignwide\">\n    <div class=\"bg-brand-600 text-base-white py-5xl px-4xl rounded-sm bg-gradient-to-r from-brand-600 to-brand-500 red\">\n        <div class=\"gap-4xl items-start md:items-center flex flex-col md:flex-row justify-between\">\n            <div class=\"flex-1 col-span-10 lg:col-span-7\">\n                <h3 class=\"mt-0 font-display mb-2 text-display-sm\">Subscribe to the Simple Talk newsletter<\/h3>\n                <div class=\"child:last-of-type:mb-0\">\n                                            All the latest articles, guides, podcasts, and more &#8211; delivered straight to your inbox.                                    <\/div>\n            <\/div>\n                                            <a href=\"https:\/\/www.red-gate.com\/simple-talk\/subscribe\/\" class=\"btn btn--secondary btn--lg\" aria-label=\"Subscribe now: Subscribe to the Simple Talk newsletter\">Subscribe now<\/a>\n                    <\/div>\n    <\/div>\n<\/section>\n\n\n<h2 id=\"h-grant-permissions-to-entra-groups-and-plan-for-token-delays\" class=\"wp-block-heading\">Grant permissions to Entra groups and plan for token delays<\/h2>\n\n\n\n<p class=\"wp-block-paragraph\">Permissions belong on groups. In my test, the group <code>sql-sales-readers-st<\/code> can read <em>every table<\/em> in the <code>SalesLT<\/code> schema:<\/p>\n\n\n\n<div class=\"wp-block-urvanov-syntax-highlighter-code-block\"><pre class=\"lang:tsql decode:true \">CREATE USER [sql-sales-readers-st] FROM EXTERNAL PROVIDER;\nCREATE ROLE sales_reader;\nGRANT SELECT ON SCHEMA::SalesLT TO sales_reader;\nALTER ROLE sales_reader ADD MEMBER [sql-sales-readers-st];<\/pre><\/div>\n\n\n\n<p class=\"wp-block-paragraph\">In September 2026, Microsoft&#8217;s database support team described <a href=\"https:\/\/techcommunity.microsoft.com\/blog\/azuredbsupport\/troubleshoot-azure-sql-error-18456-for-microsoft-entra-group-users\/4552130\" target=\"_blank\" rel=\"noreferrer noopener\">a customer case in which group users failed with error 18456<\/a> after their logins in <code>master<\/code> had been deleted. A contained user exists only in its database, while a login-based user depends on a login in <code>master<\/code>. <\/p>\n\n\n\n<p class=\"wp-block-paragraph\">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 <em>and<\/em> after the switch. <\/p>\n\n\n\n<p class=\"wp-block-paragraph\">A session of the Entra administrator runs as <code>dbo<\/code>, the <a href=\"https:\/\/www.red-gate.com\/simple-talk\/other\/securing-access-administrator\/\" target=\"_blank\" rel=\"noreferrer noopener\">database owner user<\/a>, and in that session <code>IS_MEMBER()<\/code> returns 0 for groups even when the group works fine:<\/p>\n\n\n\n<div class=\"wp-block-urvanov-syntax-highlighter-code-block\"><pre class=\"lang:tsql decode:true \">SELECT name, type_desc, DATALENGTH(sid) AS sid_length,\n       CASE WHEN DATALENGTH(sid) = 18 THEN 'LOGIN-BASED' ELSE 'CONTAINED' END AS model\nFROM sys.database_principals\nWHERE type IN ('E', 'X');\nname                  type_desc       sid_length  model\n--------------------  --------------  ----------  ---------\nsql-sales-readers-st  EXTERNAL_GROUP  16          CONTAINED<\/pre><\/div>\n\n\n\n<p class=\"wp-block-paragraph\">In my test database, the query returned a single row. The administrator group doesn&#8217;t appear in <code>sys.database_principals<\/code> of the user database at all, because Azure SQL maps it to <code>dbo<\/code>. <\/p>\n\n\n\n<p class=\"wp-block-paragraph\">An administrator session, meanwhile, returned 0 for <code>IS_MEMBER<\/code>(<code>sql-sales-readers-st<\/code>), and 1 for <code>IS_MEMBER<\/code> (<code>db_owner<\/code>).<\/p>\n\n\n\n<figure class=\"wp-block-image size-full is-resized\"><img loading=\"lazy\" decoding=\"async\" width=\"930\" height=\"251\" src=\"https:\/\/www.red-gate.com\/simple-talk\/wp-content\/uploads\/2026\/10\/image-1.jpg\" alt=\"The SID check shows the reader group as a contained user with a 16-byte SID\" class=\"wp-image-114120\" style=\"aspect-ratio:3.712574850299401;width:620px;height:auto\" srcset=\"https:\/\/www.red-gate.com\/simple-talk\/wp-content\/uploads\/2026\/10\/image-1.jpg 930w, https:\/\/www.red-gate.com\/simple-talk\/wp-content\/uploads\/2026\/10\/image-1-300x81.png 300w, https:\/\/www.red-gate.com\/simple-talk\/wp-content\/uploads\/2026\/10\/image-1-767x207.png 767w\" sizes=\"auto, (max-width: 930px) 100vw, 930px\" \/><figcaption class=\"wp-element-caption\"><em>Figure 1: The SID check shows the reader group as a contained user with a 16-byte SID<\/em>.<\/figcaption><\/figure>\n\n\n\n<h3 id=\"h-test-nested-group-membership\" class=\"wp-block-heading\">Test nested group membership<\/h3>\n\n\n\n<p class=\"wp-block-paragraph\">I couldn&#8217;t find any Microsoft documentation on how nested groups behave in Azure SQL, so I put my user into an inner group, and <em>that<\/em> group into the reader group. <\/p>\n\n\n\n<p class=\"wp-block-paragraph\">Remove your own user from the administrator group only while a second member, such as the emergency account, remains in it:<\/p>\n\n\n\n<div class=\"wp-block-urvanov-syntax-highlighter-code-block\"><pre class=\"lang:tsql decode:true \">$meId      = az ad signed-in-user show --query id -o tsv\n$adminsId  = az ad group show --group \"sql-admins-st-test\"   --query id -o tsv\n$readersId = az ad group show --group \"sql-sales-readers-st\" --query id -o tsv\n \n$innerId = az ad group create --display-name \"sql-nested-inner-st\" `\n             --mail-nickname \"sql-nested-inner-st\" --query id -o tsv\naz ad group member add    --group $innerId   --member-id $meId      # user -&gt; inner group\naz ad group member add    --group $readersId --member-id $innerId   # inner group -&gt; reader group\n# only with a second member in the admin group, such as the emergency account\naz ad group member remove --group $adminsId  --member-id $meId      # user leaves admin group\n \naz ad group member check --group $adminsId  --member-id $meId --query value   # false\naz ad group member check --group $readersId --member-id $meId --query value   # true\n \n# after the test (8:35 a.m. in my run): back into the admin group\naz ad group member add    --group $adminsId  --member-id $meId<\/pre><\/div>\n\n\n\n<p class=\"wp-block-paragraph\">The session kept running as <code>dbo<\/code> <em>even after<\/em> a fresh sign-in to the query editor. The two <a href=\"https:\/\/learn.microsoft.com\/en-us\/sql\/t-sql\/database-console-commands\/dbcc-transact-sql?view=sql-server-ver17\" target=\"_blank\" rel=\"noreferrer noopener\">Database Console Commands (DBCC)<\/a> that clear the caches changed nothing. <\/p>\n\n\n\n<p class=\"wp-block-paragraph\">Right after the change, the <code>check query<\/code> further down still returned <code>in_db_owner = 1<\/code> and <code>in_sales_reader = 0<\/code>. Microsoft recommends <code>DBCC FLUSHAUTHCACHE<\/code> for new group members, and mentions the second command in the context of <a href=\"https:\/\/learn.microsoft.com\/en-us\/azure\/azure-sql\/database\/authentication-azure-ad-logins?view=azuresql\" target=\"_blank\" rel=\"noreferrer noopener\">Entra logins<\/a>. <\/p>\n\n\n\n<p class=\"wp-block-paragraph\">Both ran without errors in my test:<\/p>\n\n\n\n<div class=\"wp-block-urvanov-syntax-highlighter-code-block\"><pre class=\"lang:tsql decode:true \">DBCC FLUSHAUTHCACHE;\nDBCC FREESYSTEMCACHE('TokenAndPermUserStore');<\/pre><\/div>\n\n\n\n<p class=\"wp-block-paragraph\">The cause was the client&#8217;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 <a href=\"https:\/\/learn.microsoft.com\/en-us\/entra\/identity-platform\/configurable-token-lifetimes\" target=\"_blank\" rel=\"noreferrer noopener\">random 60 to 90 minutes<\/a>. <\/p>\n\n\n\n<p class=\"wp-block-paragraph\">After 66 minutes, the nesting took effect, and an <code>UPDATE<\/code> on <code>SalesLT.Customer<\/code> failed with the message &#8220;The <code>UPDATE<\/code> permission was denied.&#8221;<\/p>\n\n\n\n<div class=\"wp-block-urvanov-syntax-highlighter-code-block\"><pre class=\"lang:tsql decode:true \">SELECT SUSER_SNAME() AS login_name, USER_NAME() AS db_user,\n       IS_MEMBER('sql-sales-readers-st') AS in_readers_group,\n       IS_MEMBER('sales_reader') AS in_sales_reader,\n       IS_MEMBER('db_owner') AS in_db_owner,\n       (SELECT COUNT(*) FROM SalesLT.Customer) AS customers_readable;\nlogin_name            db_user               in_readers_group  in_sales_reader  in_db_owner  customers_readable\n--------------------  --------------------  ----------------  ---------------  -----------  ------------------\nthomas@hof-erbach.de  thomas@hof-erbach.de  1                 1                0            847<\/pre><\/div>\n\n\n\n<h3 id=\"h-revoked-permissions-and-nested-groups\" class=\"wp-block-heading\">Revoked permissions and nested groups<\/h3>\n\n\n\n<p class=\"wp-block-paragraph\">A revoked permission therefore stays in effect until the token expires, and for managed identities that can take <a href=\"https:\/\/learn.microsoft.com\/en-us\/entra\/identity\/managed-identities-azure-resources\/managed-identity-best-practice-recommendations\" target=\"_blank\" rel=\"noreferrer noopener\">up to 24 hours<\/a>. Nested memberships also hide who holds a permission, since the database only sees the outer group. <\/p>\n\n\n\n<p class=\"wp-block-paragraph\">The <a href=\"https:\/\/learn.microsoft.com\/en-us\/graph\/api\/resources\/group?view=graph-rest-beta\" target=\"_blank\" rel=\"noreferrer noopener\"><code>disableNesting property<\/code><\/a>, which Microsoft added to the beta version of Microsoft Graph in September 2026, keeps other groups out of a security group.<\/p>\n\n\n\n<h2 id=\"h-enable-microsoft-defender-for-sql-per-subscription\" class=\"wp-block-heading\">Enable Microsoft Defender for SQL <em>per subscription<\/em><\/h2>\n\n\n\n<p class=\"wp-block-paragraph\">Defender for SQL bundles vulnerability assessment and Advanced Threat Protection. Microsoft recommends <a href=\"https:\/\/learn.microsoft.com\/en-us\/azure\/azure-sql\/database\/azure-defender-for-sql?view=azuresql\" target=\"_blank\" rel=\"noreferrer noopener\">enabling the plan for the entire subscription<\/a> so that servers created later are also covered.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\"><strong>Billing is per logical server<\/strong>. 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.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">Meanwhile, just one consolidated server costs $15 provided the firewall rules and the administrator fit every database on it &#8211; and a server with 20 databases costs the same as one with a <em>single<\/em> database.<\/p>\n\n\n\n<h3 id=\"h-turn-on-the-plan-with-the-cli-or-powershell\" class=\"wp-block-heading\">Turn on the plan with the CLI or PowerShell<\/h3>\n\n\n\n<p class=\"wp-block-paragraph\">The plan for Azure SQL is called <code>SqlServers<\/code>. The current CLI returns the plans as an object with a value field, so older guides that query <code>[]<\/code> instead of <code>value[]<\/code> come back empty. <\/p>\n\n\n\n<p class=\"wp-block-paragraph\">In my test subscription, <code>SqlServers<\/code> was on the <em>Free<\/em> tier beforehand, meaning the plan was switched off; Standard turns it <em>on<\/em>. In the portal, the setting sits in Defender for Cloud under &#8220;Environment settings&#8221; -&gt; subscription -&gt; &#8220;Defender plans&#8221;. <\/p>\n\n\n\n<p class=\"wp-block-paragraph\">My test subscription listed 18 plans, with <code>CloudPosture<\/code>, <code>Discovery<\/code>, and <code>FoundationalCspm<\/code> already on Standard. <\/p>\n\n\n\n<p class=\"wp-block-paragraph\">After the <code>CREATE<\/code> command, however, <code>SqlServers<\/code> showed Standard as being active since 7:20:15 a.m:<\/p>\n\n\n\n<div class=\"wp-block-urvanov-syntax-highlighter-code-block\"><pre class=\"lang:tsql decode:true \">az security pricing list --query \"value[].{name:name, tier:pricingTier}\" -o table\naz security pricing create --name SqlServers --tier standard\nSet-AzSecurityPricing -Name \"SqlServers\" -PricingTier \"Standard\"\nGet-AzSecurityPricing -Name \"SqlServers\" | Select-Object Name, PricingTier, FreeTrialRemainingTime\nName        PricingTier  FreeTrialRemainingTime\n----        -----------  ----------------------\nSqlServers  Standard     29.23:59:00<\/pre><\/div>\n\n\n\n<p class=\"wp-block-paragraph\">The first activation includes a 30-day free trial. <\/p>\n\n\n\n<p class=\"wp-block-paragraph\"><em>Note that Microsoft will <a href=\"https:\/\/learn.microsoft.com\/en-us\/azure\/defender-for-cloud\/migrate-classic-defender-for-sql-apis\" target=\"_blank\" rel=\"noreferrer noopener\">retire the classic application programming interfaces (APIs)<\/a> for vulnerability assessment and alert policies on August 16, 2027. <\/em><\/p>\n\n\n\n<p class=\"wp-block-paragraph\">The <code>AuditClassicPolicies.ps1<\/code> script finds affected servers. In a test subscription, set the plan back to Free before day 31, when billing per server starts. <\/p>\n\n\n\n<p class=\"wp-block-paragraph\"><code>AuditClassicPolicies.ps1<\/code> 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&#8217;t write anything if nothing is found.<\/p>\n\n\n\n<h2 id=\"h-approve-known-findings-with-a-vulnerability-assessment-baseline\" class=\"wp-block-heading\">Approve known findings with a vulnerability assessment baseline<\/h2>\n\n\n\n<p class=\"wp-block-paragraph\">10 seconds after I enabled the plan, Defender turned on the &#8216;express configuration of vulnerability&#8217; assessment by itself. This doesn&#8217;t require a storage account, and a baseline takes effect without a new scan.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">PowerShell doesn&#8217;t support it, but the Azure CLI reaches it through <a href=\"https:\/\/learn.microsoft.com\/en-us\/azure\/defender-for-cloud\/express-configuration-azure-commands\" target=\"_blank\" rel=\"noreferrer noopener\"><code>az rest<\/code> with API version 2026-04-01-preview<\/a>. The first request for scan results returned <code>ResultsAreNotAvailableYet<\/code>, because Defender schedules the recurring scan itself and doesn&#8217;t have any results before the first one.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">In the classic configuration, a baseline only takes effect after the next scan &#8211; and, according to the <a href=\"https:\/\/learn.microsoft.com\/en-us\/azure\/defender-for-cloud\/sql-azure-vulnerability-assessment-overview\" target=\"_blank\" rel=\"noreferrer noopener\">vulnerability assessment overview<\/a>, it&#8217;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.<\/p>\n\n\n\n<h3 id=\"h-run-an-on-demand-vulnerability-scan\" class=\"wp-block-heading\">Run an on-demand vulnerability scan<\/h3>\n\n\n\n<p class=\"wp-block-paragraph\">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. <\/p>\n\n\n\n<p class=\"wp-block-paragraph\">The output below is trimmed to the relevant fields:<\/p>\n\n\n\n<div class=\"wp-block-urvanov-syntax-highlighter-code-block\"><pre class=\"lang:tsql decode:true \">$api = 'api-version=2026-04-01-preview'\n$srvRes = az sql server show -g $rg -n $srv --query id -o tsv\n$va = \"$srvRes\/databases\/$db\/providers\/Microsoft.Security\/sqlVulnerabilityAssessments\/default\"\n \naz rest --method get  --uri \"$srvRes\/providers\/Microsoft.Security\/sqlVulnerabilityAssessments\/default?$api\"\naz rest --method post --uri \"$va\/scans\/initiateScan?$api\"          # response 202 Accepted\naz rest --method get  --uri \"$va\/scans\/latest?$api\"\naz rest --method get  --uri \"$va\/scans\/latest\/scanResults?$api\" `\n  --query \"value[?properties.status=='Finding'].{Rule:name, Severity:properties.ruleMetadata.severity, Title:properties.ruleMetadata.title}\" -o table\nTrigger   State   High  Medium  Low  Failed  Total  Baseline\nOnDemand  Failed  0     1       1    2       24     False\n \nRule    Severity  Title\nVA1281  Medium    All memberships for user-defined roles should be intended\nVA2130  Low       Track all users with access to the database<\/pre><\/div>\n\n\n\n<figure class=\"wp-block-image size-full\"><img loading=\"lazy\" decoding=\"async\" width=\"969\" height=\"125\" src=\"https:\/\/www.red-gate.com\/simple-talk\/wp-content\/uploads\/2026\/10\/image-13.png\" alt=\"The scan flags the new group and role as 'findings.'\" class=\"wp-image-114130\" srcset=\"https:\/\/www.red-gate.com\/simple-talk\/wp-content\/uploads\/2026\/10\/image-13.png 969w, https:\/\/www.red-gate.com\/simple-talk\/wp-content\/uploads\/2026\/10\/image-13-300x39.png 300w, https:\/\/www.red-gate.com\/simple-talk\/wp-content\/uploads\/2026\/10\/image-13-767x99.png 767w\" sizes=\"auto, (max-width: 969px) 100vw, 969px\" \/><figcaption class=\"wp-element-caption\"><em>Figure 2: The scan flags the new group and role as &#8216;findings&#8217;.<\/em><\/figcaption><\/figure>\n\n\n\n<p class=\"wp-block-paragraph\">Both findings concern the group and the role I had just created. Vulnerability assessment flags every new permission until someone approves it. <\/p>\n\n\n\n<p class=\"wp-block-paragraph\">While the baseline command from the documentation failed in PowerShell 7 with <code>UnsupportedProperties<\/code>, it <em>did<\/em> go through with the <a href=\"https:\/\/www.red-gate.com\/simple-talk\/databases\/oracle-databases\/json-for-absolute-beginners-part-1-introduction\/\" target=\"_blank\" rel=\"noreferrer noopener\">JavaScript Object Notation (JSON)<\/a> body in a file.<\/p>\n\n\n\n<div class=\"wp-block-urvanov-syntax-highlighter-code-block\"><pre class=\"lang:tsql decode:true \">'{\"latestScan\": true, \"results\": {}}' | Set-Content .\/baseline.json\naz rest --method post --uri \"$va\/baselineRules?$api\" --body '@baseline.json'\naz rest --method post --uri \"$va\/scans\/initiateScan?$api\"\naz rest --method get  --uri \"$va\/scans\/latest?$api\"\naz rest --method get  --uri \"$va\/scans\/latest\/scanResults?$api\" `\n  --query \"value[?properties.status=='Finding'].{Rule:name, Severity:properties.ruleMetadata.severity, Status:properties.status, WithBaseline:properties.baselineAdjustedResult.status}\" -o table\nRule    Severity  Status   WithBaseline\nVA1281  Medium    Finding  NonFinding\nVA2130  Low       Finding  NonFinding\n \nTrigger   State   High  Medium  Low  Failed  Total  Baseline\nOnDemand  Passed  0     0       0    0       24     True<\/pre><\/div>\n\n\n\n<p class=\"wp-block-paragraph\">The baseline took over four rules from the last scan: the two findings, <em>plus<\/em> VA1143 and VA1219 whose check queries had returned <code>False<\/code>, and which the scan had counted as <em>passed<\/em>. <\/p>\n\n\n\n<p class=\"wp-block-paragraph\">The second scan only served as a check, however, because the baseline works without it when in express mode.<\/p>\n\n\n\n<figure class=\"wp-block-image size-full is-resized\"><img loading=\"lazy\" decoding=\"async\" width=\"930\" height=\"120\" src=\"https:\/\/www.red-gate.com\/simple-talk\/wp-content\/uploads\/2026\/10\/image-2.jpg\" alt=\"Figure 3: With the baseline in place, both rules keep the raw status Finding and show NonFinding in the baseline-adjusted result.\" class=\"wp-image-114131\" style=\"aspect-ratio:7.75;width:620px;height:auto\" srcset=\"https:\/\/www.red-gate.com\/simple-talk\/wp-content\/uploads\/2026\/10\/image-2.jpg 930w, https:\/\/www.red-gate.com\/simple-talk\/wp-content\/uploads\/2026\/10\/image-2-300x39.png 300w, https:\/\/www.red-gate.com\/simple-talk\/wp-content\/uploads\/2026\/10\/image-2-767x99.png 767w\" sizes=\"auto, (max-width: 930px) 100vw, 930px\" \/><figcaption class=\"wp-element-caption\"><em>Figure 3: With the baseline in place, both rules keep the raw status <code>Finding<\/code> and show <code>NonFinding<\/code> in the baseline-adjusted result.<\/em><\/figcaption><\/figure>\n\n\n\n<h3 id=\"h-only-accept-reviewed-rules\" class=\"wp-block-heading\">Only accept <em>reviewed<\/em> rules<\/h3>\n\n\n\n<p class=\"wp-block-paragraph\">The raw status stays <code>Finding<\/code>, so <strong>scripts should evaluate <code>baselineAdjustedResult<\/code><\/strong>. <\/p>\n\n\n\n<p class=\"wp-block-paragraph\">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. <\/p>\n\n\n\n<p class=\"wp-block-paragraph\">There, only reviewed rules belong in the file, with <code>latestScan<\/code> set to false. <\/p>\n\n\n\n<p class=\"wp-block-paragraph\">For single rules, meanwhile, set <code>latestScan<\/code> to <code>false<\/code> and list the accepted result rows per rule under <code>results<\/code>. For my test, that would be <code>{\"VA1281\": [[\"sales_reader\", \"sql-sales-readers-st\"]]}<\/code>.<\/p>\n\n\n\n<h2 id=\"h-send-advanced-threat-protection-alerts-to-your-dba-team\" class=\"wp-block-heading\">Send Advanced Threat Protection alerts to your DBA team<\/h2>\n\n\n\n<p class=\"wp-block-paragraph\">Advanced Threat Protection raises <a href=\"https:\/\/learn.microsoft.com\/en-us\/azure\/defender-for-cloud\/alerts-sql-database-and-azure-synapse-analytics\" target=\"_blank\" rel=\"noreferrer noopener\">alerts such as <code>SQL.DB_BruteForce<\/code> and <code>SQL.DB_PotentialSqlInjection<\/code><\/a>. <\/p>\n\n\n\n<p class=\"wp-block-paragraph\">In my test, a malformed statement with <code>O'Brien' OR '1'='1<\/code> sent from the query editor triggered nothing, and at 10:03 a.m. the subscription showed zero alerts. <\/p>\n\n\n\n<p class=\"wp-block-paragraph\"><code>SQL.DB_GeoAnomaly<\/code> then reported a sign-in from an unusual location, and <code>SQL.DB_PrincipalAnomaly<\/code> reported a principal that hasn&#8217;t appeared for 60 days. <\/p>\n\n\n\n<p class=\"wp-block-paragraph\">For faulty statements from an application, Microsoft lists <code>SQL.DB_VulnerabilityToSqlInjection<\/code> with medium severity. My statement failed with &#8220;Incorrect syntax near &#8216;Brien&#8217;. Defender didn&#8217;t react.<\/p>\n\n\n\n<section id=\"my-first-block-block_f55291057da3f8e5eb7a8bfe1ea907ad\" class=\"my-first-block alignwide\">\n    <div class=\"bg-brand-600 text-base-white py-5xl px-4xl rounded-sm bg-gradient-to-r from-brand-600 to-brand-500 red\">\n        <div class=\"gap-4xl items-start md:items-center flex flex-col md:flex-row justify-between\">\n            <div class=\"flex-1 col-span-10 lg:col-span-7\">\n                <h3 class=\"mt-0 font-display mb-2 text-display-sm\">Protect your data. Demonstrate compliance.<\/h3>\n                <div class=\"child:last-of-type:mb-0\">\n                                            With Redgate, stay ahead of threats with real-time monitoring and alerts, protect sensitive data with automated discovery &#038; masking, and demonstrate compliance with traceability across every environment.                                    <\/div>\n            <\/div>\n                                            <a href=\"https:\/\/www.red-gate.com\/solutions\/use-cases\/security-and-compliance\/\" class=\"btn btn--secondary btn--lg\" aria-label=\"Learn more: Protect your data. Demonstrate compliance.\">Learn more<\/a>\n                    <\/div>\n    <\/div>\n<\/section>\n\n\n<h3 id=\"h-simulate-alerts-on-azure-sql-database\" class=\"wp-block-heading\">Simulate alerts on Azure SQL Database<\/h3>\n\n\n\n<p class=\"wp-block-paragraph\"><a href=\"https:\/\/learn.microsoft.com\/en-us\/azure\/defender-for-cloud\/simulate-alerts-sql-machines\" target=\"_blank\" rel=\"noreferrer noopener\">Alert simulation<\/a> only covers SQL Server on virtual machines and <a href=\"https:\/\/www.red-gate.com\/simple-talk\/data-security-privacy-compliance\/how-azure-arc-allows-a-db-admin-to-become-sql-server-sysadmin-the-vulnerability-explained\/\" target=\"_blank\" rel=\"noreferrer noopener\">Azure Arc-enabled servers<\/a>. For Azure SQL Database, that leaves a test application with an input field, pointed at a test server. <\/p>\n\n\n\n<p class=\"wp-block-paragraph\">Failed sign-in series for a brute-force test belong in SSMS or <code>sqlcmd<\/code>, because the portal query editor doesn&#8217;t send SQL logins to the server after the switch. <\/p>\n\n\n\n<p class=\"wp-block-paragraph\">In my test, four attempts from the query editor never reached it. <\/p>\n\n\n\n<p class=\"wp-block-paragraph\">A <a href=\"https:\/\/www.youtube.com\/watch?v=ngFWtBJNsDU\" target=\"_blank\" rel=\"noreferrer noopener\">SQLBits 2023 session on Advanced Threat Protection<\/a> uses a small C# test application for this. An input value with <code>OR 1=1<\/code> and an appended <code>UNION ALL<\/code> returns every email address from the customer table, and Defender reports a potential SQL injection with high severity:<\/p>\n\n\n\n<div class=\"wp-block-urvanov-syntax-highlighter-code-block\"><pre class=\"lang:tsql decode:true \">az security alert list --query \"[?contains(alertType,'SQL')].{alert:alertDisplayName,\nseverity:severity, start:startTimeUtc}\" -o table<\/pre><\/div>\n\n\n\n<h3 id=\"h-set-alert-email-recipients\" class=\"wp-block-heading\">Set alert email recipients<\/h3>\n\n\n\n<p class=\"wp-block-paragraph\">By default, <a href=\"https:\/\/learn.microsoft.com\/en-us\/azure\/defender-for-cloud\/configure-email-notifications\" target=\"_blank\" rel=\"noreferrer noopener\"><strong>only subscription owners receive email<\/strong><\/a>, and <strong>only for high-severity alerts<\/strong>. Defender sends each address at most four emails a day for high severity: two for medium, and one for low. <\/p>\n\n\n\n<p class=\"wp-block-paragraph\">In my test, the preview command group <code>az security contact<\/code> set the address and lowered the threshold to Medium. <\/p>\n\n\n\n<p class=\"wp-block-paragraph\">(In the portal, the recipients sit in Defender for Cloud under &#8220;Environment settings&#8221; -&gt; subscription -&gt; &#8220;Email notifications.&#8221;) <\/p>\n\n\n\n<p class=\"wp-block-paragraph\">Several recipients go into the same quoted string, separated by semicolons. In production, that <em>should<\/em> be the distribution list of the DBA team:<\/p>\n\n\n\n<div class=\"wp-block-urvanov-syntax-highlighter-code-block\"><pre class=\"lang:tsql decode:true \">az security contact list -o json\naz security contact update -n default --emails \"thomas@hof-erbach.de\" `\n  --alert-notifications \"{state:On,minimalSeverity:Medium}\" -o json\nbefore: \"alertNotifications\": { \"minimalSeverity\": \"High\",   \"state\": \"On\" },  \"emails\": \"\"\nafter:  \"alertNotifications\": { \"minimalSeverity\": \"Medium\", \"state\": \"On\" },  \"emails\": \"thomas@hof-erbach.de\"\n         \"notificationsByRole\": { \"roles\": [ \"Owner\" ], \"state\": \"On\" }<\/pre><\/div>\n\n\n\n<h2 id=\"h-send-azure-sql-audit-logs-to-log-analytics\" class=\"wp-block-heading\">Send Azure SQL audit logs to Log Analytics<\/h2>\n\n\n\n<p class=\"wp-block-paragraph\">The <a href=\"https:\/\/learn.microsoft.com\/en-us\/azure\/azure-sql\/database\/auditing-setup?view=azuresql\" target=\"_blank\" rel=\"noreferrer noopener\">default auditing policy<\/a> records queries as well as successful and failed sign-ins. It writes them to the workspace through a diagnostic setting on <code>master<\/code>.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">The parameters are <code>--lats<\/code>, short for <code>--log-analytics-target-state<\/code>, and <code>--lawri<\/code>, short for <code>--log-analytics-workspace-resource-id<\/code>. A guessed name such as <code>--lat-workspace-resource-id<\/code> fails with \u201cunrecognized arguments.\u201d <\/p>\n\n\n\n<p class=\"wp-block-paragraph\">A plain <code>-o table<\/code> on the show command prints every property of the policy, so the <code>--query<\/code> in the last line trims the output to three columns:<\/p>\n\n\n\n<div class=\"wp-block-urvanov-syntax-highlighter-code-block\"><pre class=\"lang:tsql decode:true \">az monitor log-analytics workspace create -g $rg -n law-simpletalk-test -l $loc\n$lawId = az monitor log-analytics workspace show -g $rg -n law-simpletalk-test --query id -o tsv\n \naz sql server audit-policy update -g $rg -n $srv --state Enabled --lats Enabled --lawri $lawId\naz sql server audit-policy show   -g $rg -n $srv `\n  --query \"{State:state, LogAnalytics:isAzureMonitorTargetEnabled, Groups:join(', ', auditActionsAndGroups)}\" -o table\nState    LogAnalytics  Groups\nEnabled  True          SUCCESSFUL_DATABASE_AUTHENTICATION_GROUP, FAILED_DATABASE_AUTHENTICATION_GROUP, BATCH_COMPLETED_GROUP<\/pre><\/div>\n\n\n\n<figure class=\"wp-block-image size-full is-resized\"><img loading=\"lazy\" decoding=\"async\" width=\"930\" height=\"63\" src=\"https:\/\/www.red-gate.com\/simple-talk\/wp-content\/uploads\/2026\/10\/image-3.jpg\" alt=\"Auditing to Log Analytics is enabled with the three default action groups.\" class=\"wp-image-114142\" style=\"aspect-ratio:14.761904761904763;width:620px;height:auto\" srcset=\"https:\/\/www.red-gate.com\/simple-talk\/wp-content\/uploads\/2026\/10\/image-3.jpg 930w, https:\/\/www.red-gate.com\/simple-talk\/wp-content\/uploads\/2026\/10\/image-3-300x20.png 300w, https:\/\/www.red-gate.com\/simple-talk\/wp-content\/uploads\/2026\/10\/image-3-768x52.png 768w\" sizes=\"auto, (max-width: 930px) 100vw, 930px\" \/><figcaption class=\"wp-element-caption\"><em>Figure 4: Auditing to Log Analytics is enabled with the three default action groups.<\/em><\/figcaption><\/figure>\n\n\n\n<h3 id=\"h-switch-the-log-destination-to-dedicated\" class=\"wp-block-heading\">Switch the log destination to <code>Dedicated<\/code><\/h3>\n\n\n\n<p class=\"wp-block-paragraph\">The CLI created the diagnostic setting on <code>master<\/code> with <code>AzureDiagnostics<\/code>, the old shared table, as its destination. Queries against <code>SQLSecurityAuditEvents<\/code> then find nothing.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">A second command switches the destination to <code>Dedicated<\/code>, because <code>--export-to-resource-specific<\/code> exists only when the setting is created. It reuses <code>$srvRes<\/code> from the vulnerability assessment block.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">In my test, the new workspace used the <code>PerGB2018<\/code> pricing tier with 30 days of retention, and <code>audit-policy update<\/code> took about 60 seconds. <\/p>\n\n\n\n<p class=\"wp-block-paragraph\">If <code>master<\/code> has several diagnostic settings, the second line of the block below lists all names, while the first takes only the first entry:<\/p>\n\n\n\n<div class=\"wp-block-urvanov-syntax-highlighter-code-block\"><pre class=\"lang:tsql decode:true \">$diag = az monitor diagnostic-settings list --resource \"$srvRes\/databases\/master\" --query \"[0].name\" -o tsv\naz monitor diagnostic-settings list   --resource \"$srvRes\/databases\/master\" `\n  --query \"[].{name:name, dest:logAnalyticsDestinationType}\" -o table      # dest: AzureDiagnostics\naz monitor diagnostic-settings update --name $diag --resource \"$srvRes\/databases\/master\" `\n  --set logAnalyticsDestinationType=Dedicated                                # dest: Dedicated<\/pre><\/div>\n\n\n\n<h3 id=\"h-expect-hours-not-minutes-before-the-first-records-arrive\" class=\"wp-block-heading\">Expect <em>hours<\/em> &#8211; not minutes &#8211; before the first records arrive<\/h3>\n\n\n\n<p class=\"wp-block-paragraph\">Even then, the workspace stayed empty for hours. At 10:02 a.m., two and a half hours after I enabled auditing, <code>search *<\/code> returned no records, although the diagnostic setting pointed to the workspace with the destination <code>Dedicated<\/code>. A test statement from 9:02 a.m. never arrived at all.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">The first records in <code>SQLSecurityAuditEvents<\/code> date from 12:28 p.m., almost four hours after the switch to <code>Dedicated<\/code>, and from then on new events showed up within a few minutes. <\/p>\n\n\n\n<p class=\"wp-block-paragraph\">The resource providers <code>Microsoft.Insights<\/code>, <code>Microsoft.OperationalInsights<\/code>, and <code>Microsoft.Sql<\/code> were registered.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">In a session on Azure SQL auditing from August 2022, experienced DBA Josephine Bush expects <a href=\"https:\/\/www.youtube.com\/watch?v=VE1jHfyeZW8\" target=\"_blank\" rel=\"noreferrer noopener\">30 minutes to two hours<\/a> before the first entries appear, so my test took about twice as long as her upper estimate. Auditing doesn\u2019t record anything retroactively, and the data begins when the policy is switched on.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">Allow several hours before the first evaluation. Before you build alert rules, run <code>search *<\/code> in the Logs view of the workspace to confirm that data is arriving. Log Analytics <a href=\"https:\/\/learn.microsoft.com\/en-us\/azure\/azure-monitor\/logs\/data-retention-configure\" target=\"_blank\" rel=\"noreferrer noopener\">retains data for 30 days by default<\/a>, and for up to two years at extra cost.<\/p>\n\n\n\n<h3 id=\"h-audit-data-volume-cost-and-the-unused-sql-admin-account\" class=\"wp-block-heading\">Audit data volume, cost and the unused SQL admin account<\/h3>\n\n\n\n<p class=\"wp-block-paragraph\">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\u2019s warning about large data volumes and costs in a <a href=\"https:\/\/www.youtube.com\/watch?v=q9dzBZcJIyo\" target=\"_blank\" rel=\"noreferrer noopener\">SQL Day 2025 session<\/a>. <\/p>\n\n\n\n<p class=\"wp-block-paragraph\">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.<\/p>\n\n\n\n<h2 id=\"h-three-kql-queries-for-daily-azure-sql-security-checks\" class=\"wp-block-heading\">Three KQL queries for daily Azure SQL security checks<\/h2>\n\n\n\n<p class=\"wp-block-paragraph\">I ran the following <a href=\"https:\/\/www.red-gate.com\/simple-talk\/other\/creating-functions-kusto-queries\/\" target=\"_blank\" rel=\"noreferrer noopener\">Kusto Query Language (KQL) queries<\/a> in the afternoon, once records were arriving, and checked the column names against the <code>SQLSecurityAuditEvents<\/code> <a href=\"https:\/\/learn.microsoft.com\/en-us\/azure\/azure-monitor\/reference\/tables\/sqlsecurityauditevents\" target=\"_blank\" rel=\"noreferrer noopener\">table reference<\/a>. <\/p>\n\n\n\n<h3 id=\"h-query-1-failed-sign-ins-in-the-past-24-hours\" class=\"wp-block-heading\">Query 1: failed sign-ins in the past 24 hours<\/h3>\n\n\n\n<p class=\"wp-block-paragraph\">The first counts failed sign-ins per account over the past 24 hours and collects the source IP addresses.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">Microsoft states that <a href=\"https:\/\/learn.microsoft.com\/en-us\/azure\/azure-sql\/database\/auditing-overview?view=azuresql\" target=\"_blank\" rel=\"noreferrer noopener\">failed Entra sign-ins don\u2019t appear in the audit log<\/a> 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.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">In my test, the query returned two failures for my Entra account: error 40615 while the firewall didn\u2019t know my new IP address yet, and error 47073 while public access was denied. <\/p>\n\n\n\n<p class=\"wp-block-paragraph\">After the switch to Entra-only, the query also catches rejected SQL logins, for example from old applications or from attacks on <code>sqladminst<\/code>. <\/p>\n\n\n\n<p class=\"wp-block-paragraph\">Failed Entra credentials show up in the Entra ID sign-in logs, in the workspace as the <code>SigninLogs<\/code> table if the tenant\u2019s diagnostic setting sends them there:<\/p>\n\n\n\n<div class=\"wp-block-urvanov-syntax-highlighter-code-block\"><pre class=\"lang:tsql decode:true \">SQLSecurityAuditEvents\n| where TimeGenerated &gt; ago(24h)\n| where ActionName == \"DATABASE AUTHENTICATION FAILED\"\n| summarize Failures = count(), Sources = make_set(ClientIp)\n    by ServerPrincipalName, DatabaseName\n| order by Failures desc\nDatabaseName   Failures  ServerPrincipalName   Sources\n-------------  --------  --------------------  ---------------\nsqldb-st-test  2         thomas@hof-erbach.de  [\"&lt;client IP&gt;\"]<\/pre><\/div>\n\n\n\n<figure class=\"wp-block-image size-full is-resized\"><img loading=\"lazy\" decoding=\"async\" width=\"930\" height=\"118\" src=\"https:\/\/www.red-gate.com\/simple-talk\/wp-content\/uploads\/2026\/10\/image-4.jpg\" alt=\"The audit log lists two rejected connections from the portal query editor, error 40615 from the firewall and error 47073 from the closed public endpoint.\" class=\"wp-image-114143\" style=\"aspect-ratio:7.848101265822785;width:620px;height:auto\" srcset=\"https:\/\/www.red-gate.com\/simple-talk\/wp-content\/uploads\/2026\/10\/image-4.jpg 930w, https:\/\/www.red-gate.com\/simple-talk\/wp-content\/uploads\/2026\/10\/image-4-300x38.png 300w, https:\/\/www.red-gate.com\/simple-talk\/wp-content\/uploads\/2026\/10\/image-4-764x97.png 764w\" sizes=\"auto, (max-width: 930px) 100vw, 930px\" \/><figcaption class=\"wp-element-caption\"><em>Figure 5: The audit log lists two rejected connections from the portal query editor, error 40615 from the firewall and error 47073 from the closed public endpoint.<\/em><\/figcaption><\/figure>\n\n\n\n<h3 id=\"h-query-2-sign-ins-outside-business-hours\" class=\"wp-block-heading\">Query 2: sign-ins outside business hours<\/h3>\n\n\n\n<p class=\"wp-block-paragraph\">The second lists successful sign-ins outside business hours. <code>EventTime<\/code> is in Coordinated Universal Time (UTC), so the query converts it with <code><a href=\"https:\/\/learn.microsoft.com\/en-us\/kusto\/query\/datetime-utc-to-local-function?view=azure-monitor\" target=\"_blank\" rel=\"noreferrer noopener\">datetime_utc_to_local()<\/a><\/code>, which also handles daylight saving time. <\/p>\n\n\n\n<p class=\"wp-block-paragraph\"><em>(Replace <code>Europe\/London<\/code> with your own time zone.)<\/em><\/p>\n\n\n\n<p class=\"wp-block-paragraph\">In <code>dayofweek()<\/code>, <code>0d<\/code> is Sunday and <code>6d<\/code> is Saturday. All of my test sign-ins fell within business hours, so the query returned no rows:<\/p>\n\n\n\n<div class=\"wp-block-urvanov-syntax-highlighter-code-block\"><pre class=\"lang:tsql decode:true \">SQLSecurityAuditEvents\n| where TimeGenerated &gt; ago(7d)\n| where Succeeded == true\n| where ActionName has \"AUTHENTICATION\"\n| extend LocalTime = datetime_utc_to_local(EventTime, \"Europe\/London\")\n| where hourofday(LocalTime) &lt; 7 or hourofday(LocalTime) &gt;= 19 or dayofweek(LocalTime) in (0d, 6d)\n| project EventTime, ServerPrincipalName, ClientIp, DatabaseName, ApplicationName<\/pre><\/div>\n\n\n\n<h3 id=\"h-query-3-permission-changes\" class=\"wp-block-heading\">Query 3: permission changes<\/h3>\n\n\n\n<p class=\"wp-block-paragraph\">The third finds permission changes such as <code>ALTER ROLE ... ADD MEMBER<\/code> in the logged statements. It caught the <code>GRANT<\/code> 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.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">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 <code>BATCH_COMPLETED_GROUP<\/code> records the text of every statement up to 4,000 characters. <\/p>\n\n\n\n<p class=\"wp-block-paragraph\">If an existing diagnostic setting stays on <code>AzureDiagnostics<\/code>, the queries start with <code>AzureDiagnostics | where Category == \"SQLSecurityAuditEvents\"<\/code>, and the columns carry suffixes, for example <code>action_name_s<\/code> instead of <code>ActionName<\/code>:<\/p>\n\n\n\n<div class=\"wp-block-urvanov-syntax-highlighter-code-block\"><pre class=\"lang:tsql decode:true \">SQLSecurityAuditEvents\n| where TimeGenerated &gt; ago(7d)\n| where Statement has_any (\"GRANT \", \"REVOKE \", \"DENY \", \"ALTER ROLE\", \"CREATE USER\", \"DROP USER\")\n| project EventTime, ServerPrincipalName, DatabaseName, Statement\n| order by EventTime desc\nEventTime                 ServerPrincipalName   DatabaseName   Statement\n------------------------  --------------------  -------------  -------------------------------------------------\n2026-10-27T11:37:02.928Z  thomas@hof-erbach.de  sqldb-st-test  GRANT SELECT ON SCHEMA::SalesLT TO sales_reader;<\/pre><\/div>\n\n\n\n<h2 id=\"h-add-a-private-endpoint-and-deny-public-network-access\" class=\"wp-block-heading\">Add a private endpoint and deny public network access<\/h2>\n\n\n\n<p class=\"wp-block-paragraph\">A private endpoint gives the server an address inside a virtual network, but on its own it <a href=\"https:\/\/learn.microsoft.com\/en-us\/azure\/azure-sql\/database\/private-endpoint-overview?view=azuresql\" target=\"_blank\" rel=\"noreferrer noopener\"><strong>doesn\u2019t block public access<\/strong><\/a>. <\/p>\n\n\n\n<p class=\"wp-block-paragraph\">I built mine in the afternoon along the lines of <a href=\"https:\/\/learn.microsoft.com\/en-us\/azure\/private-link\/tutorial-private-endpoint-sql-cli\" target=\"_blank\" rel=\"noreferrer noopener\">Microsoft\u2019s tutorial<\/a>, with <code>--group-ids sqlServer<\/code> and a private Domain Name System (DNS) zone.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">Two details differed in my subscription. Clients reach it through <a href=\"https:\/\/learn.microsoft.com\/en-us\/azure\/expressroute\/expressroute-introduction\" target=\"_blank\" rel=\"noreferrer noopener\">Azure ExpressRoute<\/a>, a virtual private network (VPN), or peering, and the setting \u201cDeny public network access\u201d in the portal\u2019s \u201cNetworking\u201d blade stays off until you set it.<\/p>\n\n\n\n<h3 id=\"h-create-the-private-endpoint-and-private-dns-zone\" class=\"wp-block-heading\">Create the private endpoint and private DNS zone<\/h3>\n\n\n\n<p class=\"wp-block-paragraph\">The resource group sits in West Europe, where I created it before Azure rejected the first server. Without <code>-l<\/code>, the endpoint inherited that region and failed with the same <code>RequestDisallowedByAzure<\/code> error as the first server. <\/p>\n\n\n\n<p class=\"wp-block-paragraph\">With <code>-l<\/code> set to the region of the virtual network, however, it went through &#8211; and Azure approved the connection to the server automatically.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">The private DNS zone then held an A record that pointed <code>sql-st-joos-1027<\/code> to <code>10.20.1.4<\/code>:<\/p>\n\n\n\n<div class=\"wp-block-urvanov-syntax-highlighter-code-block\"><pre class=\"lang:tsql decode:true \">az network vnet create -g $rg -n vnet-simpletalk-test -l $loc --address-prefixes 10.20.0.0\/16 `\n  --subnet-name snet-sql --subnet-prefixes 10.20.1.0\/24\n$srvRes = az sql server show -g $rg -n $srv --query id -o tsv\naz network private-link-resource list --id $srvRes --query \"[].properties.groupId\" -o tsv\n \naz network private-endpoint create -g $rg -n pe-sql-st-joos-1027 -l $loc `\n  --vnet-name vnet-simpletalk-test --subnet snet-sql `\n  --private-connection-resource-id $srvRes `\n  --group-ids sqlServer --connection-name pe-sql-st-joos-1027\n \naz network private-dns zone create -g $rg -n \"privatelink.database.windows.net\"\naz network private-dns link vnet create -g $rg --zone-name \"privatelink.database.windows.net\" `\n  --name link-vnet-simpletalk-test --virtual-network vnet-simpletalk-test --registration-enabled false\naz network private-endpoint dns-zone-group create -g $rg --endpoint-name pe-sql-st-joos-1027 `\n  --name sql-zone-group --private-dns-zone \"privatelink.database.windows.net\" --zone-name sql<\/pre><\/div>\n\n\n\n<h3 id=\"h-test-from-a-vm-with-a-managed-identity\" class=\"wp-block-heading\">Test from a VM with a managed identity<\/h3>\n\n\n\n<p class=\"wp-block-paragraph\">The second detail concerns the test client. New subnets came up with <code>defaultOutboundAccess<\/code> set to false, so the VM got a subnet of its own with outbound access to download <code>go-sqlcmd<\/code> from GitHub.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\"><code>go-sqlcmd<\/code> is Microsoft\u2019s newer, Go-based <code>sqlcmd<\/code>, which supports managed identity sign-in. The Ubuntu 24.04 image I used didn\u2019t include <code>bzip2<\/code>, which the <code>go-sqlcmd<\/code> archive needs, so the script installs it first.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">The VM doesn&#8217;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:<\/p>\n\n\n\n<div class=\"wp-block-urvanov-syntax-highlighter-code-block\"><pre class=\"lang:tsql decode:true \"># test VM with a system-assigned managed identity and no public IP\naz network vnet subnet create -g $rg --vnet-name vnet-simpletalk-test -n snet-vm `\n  --address-prefixes 10.20.2.0\/24 --default-outbound-access true\naz vm create -g $rg -n vm-st-test -l $loc --image Ubuntu2404 --size Standard_B1s `\n  --vnet-name vnet-simpletalk-test --subnet snet-vm --public-ip-address '' --nsg '' `\n  --assign-identity --admin-username azureuser --generate-ssh-keys\nCREATE USER [vm-st-test] FROM EXTERNAL PROVIDER;\nALTER ROLE app_sales_rw ADD MEMBER [vm-st-test];<\/pre><\/div>\n\n\n\n<p class=\"wp-block-paragraph\">I ran the script inside the VM with <code>az vm run-command invoke<\/code>, so the VM needs neither a public IP address nor <a href=\"https:\/\/en.wikipedia.org\/wiki\/Secure_Shell\" target=\"_blank\" rel=\"noreferrer noopener\">Secure Shell (SSH)<\/a> access:<\/p>\n\n\n\n<div class=\"wp-block-urvanov-syntax-highlighter-code-block\"><pre class=\"lang:tsql decode:true \"># vmtest.sh, run with: az vm run-command invoke -g $rg -n vm-st-test --command-id RunShellScript --scripts '@vmtest.sh'\nexport HOME=\/tmp; cd \/tmp\napt-get update -qq &amp;&amp; apt-get install -y -qq bzip2\ncurl -sSL -o sqlcmd.tar.bz2 https:\/\/github.com\/microsoft\/go-sqlcmd\/releases\/latest\/download\/sqlcmd-linux-amd64.tar.bz2\ntar xjf sqlcmd.tar.bz2 sqlcmd\nS=sql-st-joos-1027.database.windows.net\ngetent hosts $S\n.\/sqlcmd -S $S -d sqldb-st-test --authentication-method ActiveDirectoryManagedIdentity -W \\\n  -Q \"SELECT SUSER_SNAME() AS login_name, USER_NAME() AS db_user, IS_MEMBER('app_sales_rw') AS in_app_role,\n      (SELECT COUNT(*) FROM SalesLT.Customer) AS customers, CONNECTIONPROPERTY('client_net_address') AS client_ip\"\n10.20.1.4       sql-st-joos-1027.privatelink.database.windows.net sql-st-joos-1027.database.windows.net\nlogin_name                 db_user     in_app_role  customers  client_ip\n&lt;client ID&gt;@&lt;tenant ID&gt;    vm-st-test  1            847        10.20.2.4<\/pre><\/div>\n\n\n\n<figure class=\"wp-block-image size-full is-resized\"><img loading=\"lazy\" decoding=\"async\" width=\"929\" height=\"111\" src=\"https:\/\/www.red-gate.com\/simple-talk\/wp-content\/uploads\/2026\/10\/image-5.jpg\" alt=\"The test VM resolves the server name to the private endpoint and signs in with its managed identity from 10.20.2.4.\" class=\"wp-image-114144\" style=\"aspect-ratio:8.364864864864865;width:619px;height:auto\" srcset=\"https:\/\/www.red-gate.com\/simple-talk\/wp-content\/uploads\/2026\/10\/image-5.jpg 929w, https:\/\/www.red-gate.com\/simple-talk\/wp-content\/uploads\/2026\/10\/image-5-300x36.png 300w, https:\/\/www.red-gate.com\/simple-talk\/wp-content\/uploads\/2026\/10\/image-5-762x91.png 762w\" sizes=\"auto, (max-width: 929px) 100vw, 929px\" \/><figcaption class=\"wp-element-caption\"><em>Figure 6: The test VM resolves the server name to the private endpoint and signs in with its managed identity from 10.20.2.4.<\/em><\/figcaption><\/figure>\n\n\n\n<p class=\"wp-block-paragraph\">The VM resolved the server name to the private address and signed in with its managed identity. The server saw <code>10.20.2.4<\/code>, the VM\u2019s address in the virtual network, as the client. <\/p>\n\n\n\n<h3 id=\"h-close-the-public-network-path\" class=\"wp-block-heading\">Close the public network path<\/h3>\n\n\n\n<p class=\"wp-block-paragraph\">The query also read all 847 rows of <code>SalesLT.Customer<\/code> &#8211; which the <code>app_sales_rw<\/code> role permits &#8211; and <em>only then<\/em> did I close the public path (Microsoft labels <code>--enable-public-network<\/code> as preview.)<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">In my test, <code>PublicNetworkAccess<\/code> changed to <code>Disabled<\/code> within 30 seconds, and the same sign-in from the VM still worked 30 seconds later:<\/p>\n\n\n\n<div class=\"wp-block-urvanov-syntax-highlighter-code-block\"><pre class=\"lang:tsql decode:true \"># only after a successful test over the private path\naz sql server update -g $rg -n $srv --enable-public-network false<\/pre><\/div>\n\n\n\n<p class=\"wp-block-paragraph\"><code>Test-NetConnection<\/code> 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. <\/p>\n\n\n\n<p class=\"wp-block-paragraph\">The portal query editor reported \u201cAn instance-specific error occurred while establishing a connection to SQL Server. Connection was denied because Deny Public Network Access is set to Yes.\u201d<\/p>\n\n\n\n<h3 id=\"h-check-name-resolution-from-your-workstation\" class=\"wp-block-heading\">Check name resolution from your workstation<\/h3>\n\n\n\n<p class=\"wp-block-paragraph\">Clients keep using the regular server name, and <a href=\"https:\/\/en.wikipedia.org\/wiki\/Name_resolution_(computer_systems)\" target=\"_blank\" rel=\"noreferrer noopener\">name resolution<\/a> then tells you whether that name already points to the private address.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">The output below comes from my workstation that morning, before the endpoint existed, so the name chain still ends at the public gateway. <\/p>\n\n\n\n<p class=\"wp-block-paragraph\">The port test ran while public access was briefly closed. Inside the virtual network, the same name resolved to <code>10.20.1.4<\/code> (Figure 6).<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">A test connection with SQL authentication, also from my workstation, got the message \u201cAzure Active Directory only authentication is enabled\u201d in the same state and no hint of the network block. <\/p>\n\n\n\n<p class=\"wp-block-paragraph\">Sign-ins through the private IP address or the <code>privatelink<\/code> name fail on purpose, because the gateway needs the regular server name to route the connection:<\/p>\n\n\n\n<div class=\"wp-block-urvanov-syntax-highlighter-code-block\"><pre class=\"lang:tsql decode:true \">PS&gt; Test-NetConnection sql-st-joos-1027.database.windows.net -Port 1433\nRemoteAddress    : 51.116.149.32\nRemotePort       : 1433\nTcpTestSucceeded : True        # even with --enable-public-network false\n \nPS&gt; Resolve-DnsName sql-st-joos-1027.database.windows.net\nsql-st-joos-1027.database.windows.net                   CNAME dataslice3.germanywestcentral1.database.windows.net\ndataslice3.germanywestcentral1.database.windows.net     CNAME dataslice3germanywestcentral.trafficmanager.net\ndataslice3germanywestcentral.trafficmanager.net         CNAME cr6.germanywestcentral1-a.control.database.windows.net<\/pre><\/div>\n\n\n\n<figure class=\"wp-block-image size-full is-resized\"><img loading=\"lazy\" decoding=\"async\" width=\"930\" height=\"197\" src=\"https:\/\/www.red-gate.com\/simple-talk\/wp-content\/uploads\/2026\/10\/image-6.jpg\" alt=\"With public network access denied, the portal query editor can no longer connect.\" class=\"wp-image-114145\" style=\"aspect-ratio:4.732824427480916;width:620px;height:auto\" srcset=\"https:\/\/www.red-gate.com\/simple-talk\/wp-content\/uploads\/2026\/10\/image-6.jpg 930w, https:\/\/www.red-gate.com\/simple-talk\/wp-content\/uploads\/2026\/10\/image-6-300x64.png 300w, https:\/\/www.red-gate.com\/simple-talk\/wp-content\/uploads\/2026\/10\/image-6-765x162.png 765w\" sizes=\"auto, (max-width: 930px) 100vw, 930px\" \/><figcaption class=\"wp-element-caption\"><em>Figure 7: With public network access denied, the portal query editor can no longer connect.<\/em><\/figcaption><\/figure>\n\n\n\n<h3 id=\"h-connection-policy-and-admin-access-over-vpn\" class=\"wp-block-heading\">Connection policy and admin access over VPN<\/h3>\n\n\n\n<p class=\"wp-block-paragraph\">With a private endpoint, Microsoft recommends the <code>Redirect<\/code> connection policy, which requires ports 1433 through 65535. <\/p>\n\n\n\n<p class=\"wp-block-paragraph\">My test server was set to <code>Default<\/code>, under which connections through a private endpoint run as <code>Proxy<\/code> over port 1433. I left it on <code>Default<\/code>, so the update command in the block below is untested.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">Admins working from laptops need a point-to-site VPN with private name resolution before the public path closes. Over the public endpoint, <code>Redirect<\/code> needs ports 11000 to 11999 in addition, according to the <a href=\"https:\/\/learn.microsoft.com\/en-us\/azure\/azure-sql\/database\/connectivity-architecture?view=azuresql\" target=\"_blank\" rel=\"noreferrer noopener\">connectivity architecture<\/a>.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">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 <a href=\"https:\/\/www.youtube.com\/watch?v=9RCDtudfVok\" target=\"_blank\" rel=\"noreferrer noopener\">walkthrough from August 2024<\/a> shows. <\/p>\n\n\n\n<p class=\"wp-block-paragraph\">Without that path, SSMS fails with error 47073 once the public path is closed:<\/p>\n\n\n\n<div class=\"wp-block-urvanov-syntax-highlighter-code-block\"><pre class=\"lang:tsql decode:true \">az sql server conn-policy show   -g $rg -s $srv --query connectionType -o tsv    # Default\naz sql server conn-policy update -g $rg -s $srv --connection-type Redirect<\/pre><\/div>\n\n\n\n<h2 id=\"h-azure-sql-lockdown-checklist-the-order-of-changes\" class=\"wp-block-heading\">Azure SQL lockdown checklist: the order of changes<\/h2>\n\n\n\n<p class=\"wp-block-paragraph\">Before 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. <\/p>\n\n\n\n<h3 id=\"h-the-checklist-step-by-step\" class=\"wp-block-heading\">The checklist (step-by-step)<\/h3>\n\n\n<div class=\"block-core-list\">\n<ol class=\"wp-block-list\">\n<li>Set an Entra group that includes an emergency account as the server administrator.<br><br><\/li>\n\n\n\n<li>Create a contained database user for every application.<br><br><\/li>\n\n\n\n<li>Run the SID check and confirm no login-based users remain.<br><br><\/li>\n\n\n\n<li>Allow 90 minutes between revoking a permission and checking it, and 24 hours for managed identities.<br><br><\/li>\n\n\n\n<li>Enable Defender for SQL and set the alert recipients.<br><br><\/li>\n\n\n\n<li>Turn on auditing and confirm data is arriving.<br><br><\/li>\n\n\n\n<li>Test the private endpoint path.<br><br><\/li>\n\n\n\n<li>Run <code>az sql server ad-only-auth enable<\/code>, then <code>az sql server update --enable-public-network false<\/code>.<\/li>\n<\/ol>\n<\/div>\n\n\n<p class=\"wp-block-paragraph\">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.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">After that, <code>ad-only-auth enable<\/code> and <code>--enable-public-network false<\/code> are two short commands &#8211; and three more remove the test environment.<\/p>\n\n\n\n<h3 id=\"h-clean-up-the-test-environment\" class=\"wp-block-heading\">Clean up the test environment<\/h3>\n\n\n\n<p class=\"wp-block-paragraph\">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. <\/p>\n\n\n\n<p class=\"wp-block-paragraph\">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:<\/p>\n\n\n\n<div class=\"wp-block-urvanov-syntax-highlighter-code-block\"><pre class=\"lang:tsql decode:true \"># sets Defender for SQL to Free for every server in the subscription\naz security pricing create --name SqlServers --tier free\naz group delete -n rg-simpletalk-test --yes --no-wait\n\"sql-admins-st-test\", \"sql-sales-readers-st\", \"sql-nested-inner-st\" | ForEach-Object { az ad group delete --group $_ }<\/pre><\/div>\n\n\n\n<h2 id=\"h-azure-sql-entra-only-error-reference\" class=\"wp-block-heading\">Azure SQL Entra-only error reference<\/h2>\n\n\n\n<figure class=\"wp-block-table\"><table class=\"has-fixed-layout\"><thead><tr><th>Error<\/th><th>What it means in this article<\/th><\/tr><\/thead><tbody><tr><td>18456<\/td><td>A SQL login was used after the switch (\u201cAzure Active Directory only authentication is enabled\u201d), so the application still needs migrating. It also appeared for group users whose logins in master had been deleted.<\/td><\/tr><tr><td>33131<\/td><td><code>CREATE USER<\/code> failed because two objects share a display name.<\/td><\/tr><tr><td>33134<\/td><td>\u201cServer identity is not configured\u201d: automation under a managed identity needs a server identity with the Graph permissions. A Conditional Access policy blocking the lookup causes it too.<\/td><\/tr><tr><td>40615<\/td><td>The firewall doesn\u2019t know the client\u2019s IP address yet.<\/td><\/tr><tr><td>47073<\/td><td>Public network access is denied, so connect through the private path.<\/td><\/tr><tr><td><code>RequestDisallowedByAzure<\/code><\/td><td>The region isn\u2019t accepting new customers. Deploy to another region.<\/td><\/tr><\/tbody><\/table><\/figure>\n\n\n\n<section id=\"my-first-block-block_e1d79a24786845d525a3926d622c8d36\" class=\"my-first-block alignwide\">\n    <div class=\"bg-brand-600 text-base-white py-5xl px-4xl rounded-sm bg-gradient-to-r from-brand-600 to-brand-500 red\">\n        <div class=\"gap-4xl items-start md:items-center flex flex-col md:flex-row justify-between\">\n            <div class=\"flex-1 col-span-10 lg:col-span-7\">\n                <h3 class=\"mt-0 font-display mb-2 text-display-sm\">Simple Talk is brought to you by Redgate Software<\/h3>\n                <div class=\"child:last-of-type:mb-0\">\n                                            Take control of your databases with the trusted Database DevOps solutions provider. Automate with confidence, scale securely, and unlock growth through AI.                                    <\/div>\n            <\/div>\n                                            <a href=\"https:\/\/www.red-gate.com\/solutions\/overview\/\" class=\"btn btn--secondary btn--lg\" aria-label=\"Discover how Redgate can help you: Simple Talk is brought to you by Redgate Software\">Discover how Redgate can help you<\/a>\n                    <\/div>\n    <\/div>\n<\/section>\n\n\n<section id=\"faq\" class=\"faq-block my-5xl\">\n    <h2>FAQs: Entra-only authentication in Azure SQL<\/h2>\n\n            <h3 class=\"mt-4xl\">1. What happens to SQL logins when you enable Entra-only authentication on Azure SQL?<\/h3>\n        <div class=\"faq-answer\">\n            <p dir=\"ltr\">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.<\/p>\n        <\/div>\n            <h3 class=\"mt-4xl\">2. Can you turn Entra-only authentication off again?<\/h3>\n        <div class=\"faq-answer\">\n            <p dir=\"ltr\">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.<\/p>\n        <\/div>\n            <h3 class=\"mt-4xl\">3. How do applications connect to Azure SQL after Entra-only authentication is enabled?<\/h3>\n        <div class=\"faq-answer\">\n            <p dir=\"ltr\">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\u2019s own sign-in on a workstation, or Active Directory Managed Identity for the stricter option. Then, run <code>CREATE USER FROM EXTERNAL PROVIDER<\/code> in the database and add the user to a role with only the permissions it needs.<\/p>\n        <\/div>\n            <h3 class=\"mt-4xl\">4. How long do Entra group changes take to apply in Azure SQL?<\/h3>\n        <div class=\"faq-answer\">\n            <p dir=\"ltr\">Group membership comes from the client\u2019s 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. <code>DBCC FLUSHAUTHCACHE<\/code> didn\u2019t speed it up.<\/p>\n        <\/div>\n            <h3 class=\"mt-4xl\">5. How much does Microsoft Defender for SQL cost for Azure SQL Database?<\/h3>\n        <div class=\"faq-answer\">\n            <p dir=\"ltr\">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.<\/p>\n        <\/div>\n    <\/section>\n","protected":false},"excerpt":{"rendered":"<p>Enable Entra-only authentication on Azure SQL without lockouts. Tested steps for managed identities, Defender for SQL, auditing and private endpoints.&hellip;<\/p>\n","protected":false},"author":347321,"featured_media":107392,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"_acf_changed":false,"footnotes":""},"categories":[137091,10,143523,53,143524,143531],"tags":[5364,5336,4168,4170,4150,4151],"coauthors":[159421],"class_list":["post-114118","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-azure","category-cloud","category-databases","category-featured","category-sql-server","category-t-sql-programming-sql-server","tag-azure","tag-cloud","tag-database","tag-database-administration","tag-sql","tag-sql-server"],"acf":[],"_links":{"self":[{"href":"https:\/\/www.red-gate.com\/simple-talk\/wp-json\/wp\/v2\/posts\/114118","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.red-gate.com\/simple-talk\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.red-gate.com\/simple-talk\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.red-gate.com\/simple-talk\/wp-json\/wp\/v2\/users\/347321"}],"replies":[{"embeddable":true,"href":"https:\/\/www.red-gate.com\/simple-talk\/wp-json\/wp\/v2\/comments?post=114118"}],"version-history":[{"count":28,"href":"https:\/\/www.red-gate.com\/simple-talk\/wp-json\/wp\/v2\/posts\/114118\/revisions"}],"predecessor-version":[{"id":114600,"href":"https:\/\/www.red-gate.com\/simple-talk\/wp-json\/wp\/v2\/posts\/114118\/revisions\/114600"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/www.red-gate.com\/simple-talk\/wp-json\/wp\/v2\/media\/107392"}],"wp:attachment":[{"href":"https:\/\/www.red-gate.com\/simple-talk\/wp-json\/wp\/v2\/media?parent=114118"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.red-gate.com\/simple-talk\/wp-json\/wp\/v2\/categories?post=114118"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.red-gate.com\/simple-talk\/wp-json\/wp\/v2\/tags?post=114118"},{"taxonomy":"author","embeddable":true,"href":"https:\/\/www.red-gate.com\/simple-talk\/wp-json\/wp\/v2\/coauthors?post=114118"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}