{"id":8146,"date":"2022-11-23T18:34:35","date_gmt":"2022-11-23T23:34:35","guid":{"rendered":"https:\/\/andreas-wolter.com\/?p=8146"},"modified":"2026-10-29T20:21:27","modified_gmt":"2026-10-30T01:21:27","slug":"202211_troubleshooting-external-policies-azure-sql-sql-server","status":"publish","type":"post","link":"https:\/\/andreas-wolter.com\/en\/202211_troubleshooting-external-policies-azure-sql-sql-server\/","title":{"rendered":"Troubleshooting external data and access policies in Azure SQL and SQL Server"},"content":{"rendered":"<p>In this article you will find an overview of all the new metadata that was added to support customers using external data and access Policies from Microsoft Purview. You will find this interesting if you are in a technical role and have access to a SQL database, for example as a DBA or developer or need to create reports on who has access to your systems.<\/p>\n<h2 id=\"community-3683097-toc-hId-509164560\">Background<\/h2>\n<p>If you are one of the early adopters of the new Microsoft Purview based data and access policies (a.k.a. external policies) you are already familiar with what it does and how it works.<br \/>For all others I recommend looking at the following articles:<\/p>\n<p><a href=\"https:\/\/andreas-wolter.com\/en\/202111_purview-access-policies-azure-sql-private-preview\/\" target=\"_blank\">Private Preview: controlling access to Azure SQL at scale with policies in Purview<\/a><\/p>\n<p><a href=\"https:\/\/techcommunity.microsoft.com\/t5\/security-compliance-and-identity\/microsoft-purview-devops-policies-enter-ga-simplify-access\/ba-p\/3674057\" target=\"_blank\" rel=\"noopener\">Microsoft Purview DevOps policies enter GA: Simplify access provisioning while protecting your data<\/a><\/p>\n<p>In this article I provide some background on the architecture of the Purview Integration and what \u201cactions\u201d in the context of policy based access control mean compared to SQL permissions: <a href=\"https:\/\/andreas-wolter.com\/en\/202209_sql-permission-system-internals-least-privilege-external-policies\/\" target=\"_blank\">Revamped SQL Permission system for Principle of Least Privilege and external policies \u2013 internals<\/a><\/p>\n<p>With these fundamentals established let\u2019s take a look under the hood of SQL Server and what it can tell us about active external policies.<\/p>\n<h2 id=\"community-3683097-toc-hId--1298289903\">How to check if External Policies are enabled<\/h2>\n<p>The first and most basic question is: \u201cdoes my SQL Server currently support external policies at all?\u201d or, in other words, \u201cis this functionality activated and could policies that are defined in Microsoft Purview grant access to anyone on this server?\u201d<\/p>\n<p>There are 2 ways to do that, one in T-SQL and one via Powershell.<\/p>\n<p>In T-SQL we have the function SERVERPROPERTY() with a new parameter: \u201c<strong>IsExternalGovernanceEnabled<\/strong>\u201d.<\/p>\n<p>This is how it\u2019s queried:<\/p>\n<p>SELECT SERVERPROPERTY(&#8216;IsExternalGovernanceEnabled&#8217;)<\/p>\n<p>If the result is \u201c1\u201d that means this server is currently listening for external policies. It does not mean there are actual policies in place that address this server, but if there are, they would be effective.<\/p>\n<p>Result \u201c0\u201d, the default simply means this Server is not enabled for this feature and would not download any policies even if policies have been defined for this server.<\/p>\n<p style=\"padding-left: 30px;\"><em>Note on Preview-version<\/em><br \/>In the <strong>Azure SQL Database<\/strong> where this feature currently is in Preview, the parameter is called \u201c<strong>IsExternalPolicybasedAuthorizationEnabled<\/strong>\u201d \u2013 so you need to use SERVERPROPERTY(&#8216;IsExternalPolicybasedAuthorizationEnabled&#8217;)<br \/>Below this article I have listed all object names that are used in the Preview version.<\/p>\n<p style=\"padding-left: 30px;\">\u00a0<\/p>\n<p>In PowerShell you can use the following command:<\/p>\n<p>Invoke-AzRestMethod -Method GET -Path &#8220;$($server.ResourceId)\/<strong>externalPolicyBasedAuthorizations<\/strong>\/MicrosoftPurview?api-version=2021-11-01-preview&#8221;<\/p>\n<p>The parameter $server requires your Azure SQL Database\u2019s logical server name.<\/p>\n<p>It will return true or false, following the same logic as above, meaning that \u201ctrue\u201d means the feature is enabled.<\/p>\n<p>There is one other way to determine if your server has this feature enabled and that is using a new DMV named <em>sys.dm_external_policy_cache<\/em>.<br \/>This DMV will always contain one row if the server has the feature enabled.<br \/>If the DMV returns an empty resultset, in other words <em>zero rows<\/em>, the feature is not enabled:<\/p>\n<p>SELECT *<\/p>\n<p>FROM sys.dm_external_policy_cache<\/p>\n<p>A server with this feature enabled would have a resultset like the following:<\/p>\n<figure class=\"aw-tc-figure\" style=\"text-align: center; margin: 24px 0;\"><img decoding=\"async\" src=\"https:\/\/andreas-wolter.com\/wp-content\/uploads\/2026\/10\/tc-3683097-1.jpg\" alt=\"\" width=\"877\" height=\"288\" loading=\"lazy\" style=\"max-width: 100%; height: auto;\" \/><\/figure>\n<p>That leads us to another topic:<\/p>\n<h2 id=\"community-3683097-toc-hId-1189222930\">Are the policies on my server the most current?<\/h2>\n<p>Policies that are defined <u>and published<\/u> in Purview are downloaded periodically, not continuously. On average it will take about 2-3 minutes for a new policy to appear in SQL.<\/p>\n<p>The DMV <em>sys.dm_external_policy_cache<\/em> that I introduced will let you know the last time in UTC that the SQL engine checked and, if necessary, downloaded all policies that are applicable to this server.<\/p>\n<p>It also tells you the number of policies that have been downloaded and by that currently apply to this server.<\/p>\n<h2 id=\"community-3683097-toc-hId--618231533\">How to ensure policies are fresh during troubleshooting<\/h2>\n<p>Since it can take a few minutes for freshly published policies to be downloaded to the SQL Server, to help speed up troubleshooting and testing, we provide you a system stored procedure that forces the engine to download any new policies when run: <em>sys.sp_external_policy_refresh<\/em> (BOL: <a href=\"https:\/\/learn.microsoft.com\/en-us\/sql\/relational-databases\/system-stored-procedures\/sp-external-policy-refresh-transact-sql?view=sql-server-ver16\" target=\"_blank\" rel=\"noopener noreferrer\">sp_external_policy_refresh (Transact-SQL)<\/a>)<em><br \/><\/em>It updates the Purview cache on the whole instance, for every database.<\/p>\n<p>EXEC sys.sp_external_policy_refresh @type =\u00a0 &#8216;Reload&#8217; &#8212; aka FULL<\/p>\n<p>\u201cReload\u201d forces the engine to flush and \u201cReload\u201d the policy cache entirely.<\/p>\n<p style=\"padding-left: 30px;\"><em>Note<\/em><br \/>If there are any ongoing pull requests, by the background task or by another user, the requested pull waits until the former task is finished and starts a new pull. This ensures that the result of calling this procedure explicitly always results in a fresh pull (the former may have been requested many seconds earlier and thus not contain what the user expects).<\/p>\n<h2 id=\"community-3683097-toc-hId-1869281300\">How to determine who can do what: allowed operations<\/h2>\n<p>Now that you are sure that you have the latest version of all policies applied at your server, you want to understand which AAD Accounts have access via policies and which activities they can perform.<\/p>\n<p style=\"padding-left: 30px;\"><em>Note<\/em><br \/>External policies use so-called Actions to define which operations the policy allows to perform. The difference between Actions and permissions are explained in this post: <a href=\"https:\/\/andreas-wolter.com\/en\/202209_sql-permission-system-internals-least-privilege-external-policies\/\" target=\"_blank\">Revamped SQL Permission system for Principle of Least Privilege and external policies \u2013 internals<\/a><\/p>\n<p>Policies are stored in memory using JSON format. This data is not exposed at this time.<br \/>However, to facilitate determining who has access and can do what, policies are parsed and made available in relational format through a set of DMVs.<\/p>\n<p>All these new DMVs come in pairs of two: one DMV that contains policies that apply to the whole server and one that only shows policies that apply to the current database.<\/p>\n<h3 id=\"community-3683097-toc-hId--1735124522\">sys.dm_server_external_policy_actions and sys.dm_database_external_policy_actions<\/h3>\n<p>List all available Data actions, independently of them being used or not (basically static, returns what could be used)<\/p>\n<p>The result will look like this:<\/p>\n<figure class=\"aw-tc-figure\" style=\"text-align: center; margin: 24px 0;\"><img decoding=\"async\" src=\"https:\/\/andreas-wolter.com\/wp-content\/uploads\/2026\/10\/tc-3683097-2.jpg\" alt=\"list of built-in external actions\" width=\"656\" height=\"612\" loading=\"lazy\" style=\"max-width: 100%; height: auto;\" \/><figcaption style=\"font-size: 14px; color: #5a6470; margin-top: 6px;\">list of built-in external actions<\/figcaption><\/figure>\n<h3 id=\"community-3683097-toc-hId-752388311\">sys.dm_server_external_policy_principals and sys.dm_database_external_policy_principals<\/h3>\n<p>Contain a list of all principals (all types of AAD Accounts) that have at least the Connect-Action assigned to them.<\/p>\n<figure class=\"aw-tc-figure\" style=\"text-align: center; margin: 24px 0;\"><img decoding=\"async\" src=\"https:\/\/andreas-wolter.com\/wp-content\/uploads\/2026\/10\/tc-3683097-3.jpg\" alt=\"\" width=\"792\" height=\"263\" loading=\"lazy\" style=\"max-width: 100%; height: auto;\" \/><\/figure>\n<p><strong>Concerning the SID<\/strong><\/p>\n<p>Currently the external_policy_DMVs only return SIDs not the User names from AAD. And there are 2 formats in which we expose them:<\/p>\n<ol>\n<li>The column <strong><em>sid<\/em><\/strong>: it contains the SID in the format that SQL Server uses and can be used to join with for example <em>sys.dm_exec_sessions<\/em> and other objects that return Windows or AAD Login SIDs.<\/li>\n<li>The column <strong><em>aad_object_id<\/em><\/strong>: this column contains the SID that is used by Azure Active Directory for the <strong><em>Object ID<\/em><\/strong>. The reason is that this is the format that Microsoft Purview policies use internally.<br \/>You can see the Object ID belonging to each account in the Azure portal for example here:<\/li>\n<\/ol>\n<figure class=\"aw-tc-figure\" style=\"text-align: center; margin: 24px 0;\"><img decoding=\"async\" src=\"https:\/\/andreas-wolter.com\/wp-content\/uploads\/2026\/10\/tc-3683097-4.jpg\" alt=\"User account in Azure Active Directory in Azure Portal\" width=\"810\" height=\"525\" loading=\"lazy\" style=\"max-width: 100%; height: auto;\" \/><figcaption style=\"font-size: 14px; color: #5a6470; margin-top: 6px;\">User account in Azure Active Directory in Azure Portal<\/figcaption><\/figure>\n<h3 id=\"community-3683097-toc-hId--1055066152\">sys.dm_server_external_policy_roles and sys.dm_database_external_policy_roles<\/h3>\n<p>All external roles (aka Action Groups in Purview) that are in use for the current scope (server or database)<\/p>\n<h3 id=\"community-3683097-toc-hId-1432446681\">sys.dm_server_external_policy_role_members and sys.dm_database_external_policy_role_members<\/h3>\n<p>Link external_principals with external_roles -&gt; can be used to join those DMVs<\/p>\n<p>This DMV also contains the scope at which the role is applied. Remember that your server may reside in some Resource Group in Azure where the policies are applied, instead of policies being applied on a per-server basis (that would usually be a bad design choice).<\/p>\n<figure class=\"aw-tc-figure\" style=\"text-align: center; margin: 24px 0;\"><img decoding=\"async\" src=\"https:\/\/andreas-wolter.com\/wp-content\/uploads\/2026\/10\/tc-3683097-5.jpg\" alt=\"\" width=\"400\" height=\"111\" loading=\"lazy\" style=\"max-width: 100%; height: auto;\" \/><\/figure>\n<h3 id=\"community-3683097-toc-hId--375007782\">sys.dm_server_external_policy_role_actions and sys.dm_database_external_policy_role_actions<\/h3>\n<p>Link external_actions with external_roles -&gt; can be used to join those DMVs<\/p>\n<p><strong>How to query all at once:<\/strong><\/p>\n<p>To get a useful, informative result, you will want to join those views. To spare you that work, we have created one more set of DMVs that do that for you:<\/p>\n<h3 id=\"community-3683097-toc-hId-1417341572\">sys.dm_server_external_policy_principal_assigned_actions and sys.dm_database_external_policy_principal_assigned_actions<\/h3>\n<p>This set of views joins all 5 views that I explained above and as a result lists the AAD accounts (currently just the SIDs) together with the external roles they are assigned to and the data actions that those roles provide.<\/p>\n<p>The result can look like this:<\/p>\n<figure class=\"aw-tc-figure\" style=\"text-align: center; margin: 24px 0;\"><img decoding=\"async\" src=\"https:\/\/andreas-wolter.com\/wp-content\/uploads\/2026\/10\/tc-3683097-6.jpg\" alt=\"\" width=\"400\" height=\"144\" loading=\"lazy\" style=\"max-width: 100%; height: auto;\" \/><\/figure>\n<p>Now you can see from one query, which AAD Account (the SIDs) has which Actions granted to it and which role this is coming from and on what level of the Resource hierarchy this role is applied to.<\/p>\n<h2 id=\"community-3683097-toc-hId--519195610\">How to detect Users connecting via policy-based permissions<\/h2>\n<p>Often, as a DBA or Auditor, you will want to understand how a certain User that you see in the system was able to connect and what its permissions are.<\/p>\n<p>In this case you are most likely looking at either <em>sys.dm_exec_sessions<\/em> (<a href=\"https:\/\/learn.microsoft.com\/en-us\/sql\/relational-databases\/system-dynamic-management-views\/sys-dm-exec-sessions-transact-sql?view=sql-server-ver16\" target=\"_blank\" rel=\"noopener noreferrer\">sys.dm_exec_sessions (Transact-SQL) <\/a>), often joined with sy<em>s.dm_exec_request<\/em><em>s <\/em>( <a href=\"https:\/\/learn.microsoft.com\/en-us\/sql\/relational-databases\/system-dynamic-management-views\/sys-dm-exec-requests-transact-sql?view=sql-server-ver16\" target=\"_blank\" rel=\"noopener noreferrer\">sys.dm_exec_requests (Transact-SQL) <\/a>), both being DMVs that exist since a long time before external policies came into play.<\/p>\n<p>Since policy-backed accounts are not persisted in SQL Server Catalog views like <em>sys.server_principals<\/em> or <em>sys.database_principals<\/em>, you would now start using <em>sys.dm_database_external_policy_principals<\/em> and <em>sys.dm_server_external_policy_principals<\/em> to make sure to find these accounts. And starting from there you can find out which Actions they have been assigned \u2013 using the DMVs that I explained above.<\/p>\n<p>To join <em>sys.dm_exec_sessions <\/em>with the new <em>external_policy<\/em>-DMVs you can use the column <em>security_id<\/em> (aka SID).<\/p>\n<p>In the following screenshot you can see all currently logged in AAD Accounts that have a Policy assigned to them as indicated by the \u201cRBAC_ASSIGNED_USER\u201d in the type-field.<\/p>\n<figure class=\"aw-tc-figure\" style=\"text-align: center; margin: 24px 0;\"><img decoding=\"async\" src=\"https:\/\/andreas-wolter.com\/wp-content\/uploads\/2026\/10\/tc-3683097-7.jpg\" alt=\"\" width=\"783\" height=\"271\" loading=\"lazy\" style=\"max-width: 100%; height: auto;\" \/><\/figure>\n<p>Of course you will still also enumerate all accounts that may exist as traditional \u201cExternal Login from Azure Active Directory\u201d using <em>sys.server_principals<\/em>.<br \/>It is quite possible that an AAD Account has a Login in SQL in addition to a Policy assigned to it. So don\u2019t be surprised to find entries in both the new <em>external_policy<\/em>&#8211; and the old <em>server_principals <\/em>system views.<\/p>\n<p>Here is how that could look:<\/p>\n<figure class=\"aw-tc-figure\" style=\"text-align: center; margin: 24px 0;\"><img decoding=\"async\" src=\"https:\/\/andreas-wolter.com\/wp-content\/uploads\/2026\/10\/tc-3683097-8.jpg\" alt=\"\" width=\"738\" height=\"469\" loading=\"lazy\" style=\"max-width: 100%; height: auto;\" \/><\/figure>\n<p>As you can see marked in red boxes, the sessions 54 and 55 are listed twice, since I am joining with both DMVs and find an entry for both a Login based on AAD (EXTERNAL_LOGIN) and the same account also is assigned to a Policy, hence \u201cRBAC_ASSIGNED_USER\u201d as the metadata calls it.<\/p>\n<p>This is logical and important, since the traditional Login (and potential Database-Users) can have additional permissions granted directly in SQL.<\/p>\n<h2 id=\"community-3683097-toc-hId-1968317223\">How to check for possible performance-impact on the system or queries<\/h2>\n<p>Lastly, once we understand that hopefully all access makes sense, there are cases where you will want to understand which possible impact the policy cache, the updates and calls to it may have.<\/p>\n<p>There are 3 areas to look at.<\/p>\n<h3 id=\"community-3683097-toc-hId-289945479\">DMVs<\/h3>\n<p>Besides <em>sys.dm_external_policy_cache<\/em> which I explained above, you can monitor the Memory Clerk that the Purview SDK uses through the existing <em>sys.dm_os_memory_clerks<\/em>.<\/p>\n<p>That will show you the amount of memory used by the SDK. You can find the Memory clerk with this query:<\/p>\n<p>SELECT pages_kb\/1024.0 AS [SizeMB], *<\/p>\n<p>FROM sys.dm_os_memory_clerks<\/p>\n<p>WHERE type = &#8216;MEMORYCLERK_EXTERNAL_GOVERNANCE_AUTHORIZATION_ENGINE&#8217;<\/p>\n<p style=\"padding-left: 30px;\"><em>Note on Preview-version<\/em><br \/>In the Preview-version and currently in Azure SQL Database, this Clerk-type is named \u201cMemoryClerk RBAC\u201d for historical reasons. Below this article I have listed all object names that are used in the Preview version.<\/p>\n<h3 id=\"community-3683097-toc-hId--1517508984\">\u00a0<\/h3>\n<h3 id=\"community-3683097-toc-hId-970003849\">Wait-Types<\/h3>\n<p>Analyzing Wait-Stats is an essential part of system-investigation. Waits are a normal part of any system but depending on the operation that the system is waiting for, abnormal high waits can point to underlying issues.<\/p>\n<p>Server-wide waits are queried via <em>sys.dm_os_wait_stats<\/em> and in Azure SQL Database using <em>sys.dm_db_wait_stats<\/em> or on a session-level via <em>sys.dm_exec_session_wait_stats<\/em>. If you are not familiar with this concept, start here: <a href=\"https:\/\/learn.microsoft.com\/en-us\/sql\/relational-databases\/system-dynamic-management-views\/sys-dm-os-wait-stats-transact-sql?view=sql-server-ver16\" target=\"_blank\" rel=\"noopener noreferrer\">sys.dm_os_wait_stats (Transact-SQL) | Microsoft Learn<\/a><\/p>\n<p>The following Wait-types have been introduced in the preview version of Purview integration:<\/p>\n<table style=\"width: 100%; table-layout: fixed; word-break: break-word; overflow-wrap: anywhere;\">\n<tbody>\n<tr>\n<td>\n<p><strong>Wait Type<\/strong><\/p>\n<\/td>\n<td>\n<p><strong>Description<\/strong><\/p>\n<\/td>\n<\/tr>\n<tr>\n<td>\n<p>WAIT_EXTERNAL_GOVERNANCE_PERMCACHE_RESOURCELOCK<\/p>\n<\/td>\n<td>\n<p>Occurs during a read\/write lock on the permission cache, used for the response from the Purview SDK on a permission-lookup.<\/p>\n<\/td>\n<\/tr>\n<tr>\n<td>\n<p>WAIT_EXTERNAL_GOVERNANCE_PERMCACHE_DECISIONLOCK<\/p>\n<\/td>\n<td>\n<p>Occurs during a read\/write lock on the permission cache, used for the response from the Purview SDK during evaluation of an AAD principal for a data action.<\/p>\n<\/td>\n<\/tr>\n<tr>\n<td>\n<p>WAIT_EXTERNAL_GOVERNANCE_POLICY_AAD_GROUP_INFO<\/p>\n<\/td>\n<td>\n<p>Occurs during waiting on internal lock on a map for caching AAD Group IDs for AAD Users.<\/p>\n<\/td>\n<\/tr>\n<tr>\n<td>\n<p>PURVIEW_POLICY_SDK_PREEMPTIVE_SCHEDULING<\/p>\n<\/td>\n<td>\n<p>Occurs during calls to Purview SDK. Scheduling is switched to preemptive mode. It will occur after PWAIT_PREEMPTIVE_OS_AUTHENTICATEDWEBCALL.<\/p>\n<\/td>\n<\/tr>\n<tr>\n<td>\n<p>WAIT_EXTERNAL_GOVERNANCE_POLICY_PROVIDER<\/p>\n<\/td>\n<td>\n<p>Occurs during a read\/write lock on the policy provider cache while accessing the stored policies in memory.<\/p>\n<\/td>\n<\/tr>\n<tr>\n<td>\n<p>EXTERNAL_GOVERNANCE_POLICY_UPDATE<\/p>\n<\/td>\n<td>\n<p>Occurs during updates of the policy cache on a pull task run.<\/p>\n<\/td>\n<\/tr>\n<tr>\n<td>\n<p>WAIT_EXTERNAL_GOVERNANCE_POLICY_SESSION_AUDIT<\/p>\n<\/td>\n<td>\n<p>Lock to synchronize access to an active session\u2019s audit information containing audited external permission evaluation and their outcome together with applicable policy id and version.<\/p>\n<\/td>\n<\/tr>\n<tr>\n<td>\n<p>WAIT_EXTERNAL_GOVERNANCE_POLICY_SESSIONS_AUDIT<\/p>\n<\/td>\n<td>\n<p>Lock to synchronize allocation of, or access to Purview permissions audit information object for a session.<\/p>\n<\/td>\n<\/tr>\n<tr>\n<td>\n<p>EXTERNAL_GOVERNANCE_PULL_TASK<\/p>\n<\/td>\n<td>\n<p>Occurs if there is a background pull task running and a user manually initiates a pull at the same time. This wait type shows up until the background task is done, before the user initiated one can be started.<\/p>\n<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<p>Therefore, a query to retrieve just those could look like:<\/p>\n<p>SELECT * FROM sys.dm_os_wait_stats<\/p>\n<p>WHERE wait_type IN<\/p>\n<p>\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 ( &#8216;WAIT_EXTERNAL_GOVERNANCE_PERMCACHE_RESOURCELOCK&#8217;<\/p>\n<p>\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 , &#8216;EXTERNAL_GOVERNANCE_PULL_TASK&#8217;<\/p>\n<p>\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 , &#8216;EXTERNAL_GOVERNANCE_ATTR_SYNC_BACKGROUND&#8217;<\/p>\n<p>\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 , &#8216;PURVIEW_POLICY_SDK_PREEMPTIVE_SCHEDULING&#8217;<\/p>\n<p>\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 , &#8216;WAIT_EXTERNAL_GOVERNANCE_POLICY_AAD_GROUP_INFO&#8217;<\/p>\n<p>\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 , &#8216;WAIT_EXTERNAL_GOVERNANCE_PERMCACHE_RESOURCELOCK&#8217;<\/p>\n<p>\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 , &#8216;WAIT_EXTERNAL_GOVERNANCE_PERMCACHE_DECISIONLOCK&#8217;<\/p>\n<p>\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 , &#8216;WAIT_EXTERNAL_GOVERNANCE_POLICY_PROVIDER&#8217;<\/p>\n<p>\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 , &#8216;WAIT_EXTERNAL_GOVERNANCE_POLICY_SESSION_AUDIT&#8217;<\/p>\n<p>\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 , &#8216;WAIT_EXTERNAL_GOVERNANCE_POLICY_SESSIONS_AUDIT&#8217;<\/p>\n<p>\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 );<\/p>\n<p>From those, the one that will most likely be on top always, is PURVIEW_POLICY_SDK_PREEMPTIVE_SCHEDULING. Since this happens in a background-process (unless you force the cache update manually), this should normally not be an issue. On my server I have a max wait time of 15 ms over multiple weeks.<\/p>\n<h3 id=\"community-3683097-toc-hId--837450614\">Extended Events<\/h3>\n<p>All the information from DMVs is looking at data at a certain point in time.<\/p>\n<p>So for example you can get the timestamp of the last time that the cache was updated, and the wait-time accumulated until when your query is running.<\/p>\n<p>But sometimes you will want to run a so-called trace, to log specific events over a certain timespan. That\u2019s where <strong><em>Extended Events<\/em><\/strong> aka <strong><em>XEvents<\/em><\/strong> come into play. To assist you in tracing policy related information, we created the following new events that can be captured:<\/p>\n<table style=\"width: 100%; table-layout: fixed; word-break: break-word; overflow-wrap: anywhere;\">\n<tbody>\n<tr>\n<td>\n<p><strong>XEvent and Description<\/strong><\/p>\n<\/td>\n<td>\n<p><strong>Event Fields<\/strong><\/p>\n<\/td>\n<\/tr>\n<tr>\n<td>\n<p>external_governance_policy_pulltask_started\u00a0 *<\/p>\n<p>XEvent for policy pull start<\/p>\n<\/td>\n<td>\n<p>policy_pull_type<\/p>\n<p>&#8211;\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 FULL = Reload, DELTA = Update<\/p>\n<p>service_endpoint_uri<\/p>\n<\/td>\n<\/tr>\n<tr>\n<td>\n<p>external_governance_policy_pulltask_retries *<\/p>\n<p>XEvent for policy pull diagnostics<\/p>\n<\/td>\n<td>\n<p>Message<\/p>\n<p>&#8211;\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 Internal status message<\/p>\n<p>retry_number<\/p>\n<\/td>\n<\/tr>\n<tr>\n<td>\n<p>external_governance_policy_pulltask_finished *<\/p>\n<p>XEvent for policy pull finish<\/p>\n<\/td>\n<td>\n<p>modified_policy_elements_information<br \/>policy_elements_count_after_pull<\/p>\n<p>&#8211;\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 these fields are only useful for internal Microsoft engineers<\/p>\n<\/td>\n<\/tr>\n<tr>\n<td>\n<p>external_governance_call_to_authorization_engine *<\/p>\n<p>a call to external governance SDK is made<\/p>\n<\/td>\n<td>\n<p>database_id<br \/>object_name<br \/>schema_name<\/p>\n<p>&#8211;\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 self-explanatory<\/p>\n<p>data_action<\/p>\n<p>&#8211;\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 internally used ID for Data action<\/p>\n<p>&#8211;\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 i.e. 0 = Connect on Database, 1 = Connect on Server<\/p>\n<p>external_governance_decision<\/p>\n<p>&#8211;\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 0 = Permit, 1 = Deny<\/p>\n<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<p>All these events from external governance tasks are under the Debug-channel. Therefore, if you are searching for these events in the UI, you need to activate that channel to see them \u2013 as shown in the below screenshot:<\/p>\n<figure class=\"aw-tc-figure\" style=\"text-align: center; margin: 24px 0;\"><img decoding=\"async\" src=\"https:\/\/andreas-wolter.com\/wp-content\/uploads\/2026\/10\/tc-3683097-9.jpg\" alt=\"\" width=\"718\" height=\"263\" loading=\"lazy\" style=\"max-width: 100%; height: auto;\" \/><\/figure>\n<p>In addition to new events we also include a new field in the <em>process_login_finished<\/em>\u2013event to help you understand whether a connection was allowed or denied due to policy-based permissions.<\/p>\n<table style=\"width: 100%; table-layout: fixed; word-break: break-word; overflow-wrap: anywhere;\">\n<tbody>\n<tr>\n<td>\n<p><strong>Existing event<\/strong><\/p>\n<\/td>\n<td>\n<p><strong>New Event Field<\/strong><\/p>\n<\/td>\n<\/tr>\n<tr>\n<td>\n<p>process_login_finish<\/p>\n<\/td>\n<td>\n<p>external_governance_policy_authorization<\/p>\n<p>&#8211;\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 this returns one of 3 values, depending on if the session that logged in was authenticated via an external policy Connect-Action: 0 = NotApplicable, 1 = Permit or 2 = Deny<\/p>\n<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<p>To help you get started I am also attaching a file that contains an XEvent session including all of these events to this article.<\/p>\n<p>Here is an example result of tracing <strong>a single policy-update call with XEvents<\/strong>:<\/p>\n<figure class=\"aw-tc-figure\" style=\"text-align: center; margin: 24px 0;\"><img decoding=\"async\" src=\"https:\/\/andreas-wolter.com\/wp-content\/uploads\/2026\/10\/tc-3683097-10.jpg\" alt=\"\" width=\"999\" height=\"455\" loading=\"lazy\" style=\"max-width: 100%; height: auto;\" \/><\/figure>\n<p>Marked in red you can see the Pull type = \u201cFull\u201d which corresponds to \u201cReload\u201d and the Endpoint URI of the Purview Service used by my server.<\/p>\n<p>The green box marks the events that encompass the actual \u201cpulling\u201d of policies from the Purview service. The events are <em>external_governance_policy_pulltask_started<\/em> and <em>external_governance_policy_pulltask_finished<\/em>. The events before are part of the initialization process and those after cover the updates to the database-specific caches.<\/p>\n<p style=\"padding-left: 30px;\"><em>Note<\/em><br \/>In the example I am using the RingBuffer-Target for XEvents which stores the traced events in memory. That is sufficient for a low-impact ad-hoc analysis. For longer running traces you should work with the file-target.<br \/>XEvents are stored in XML format, so to present it in tabular format I am using the nodes-Method for the XML data type.<\/p>\n<p style=\"padding-left: 30px;\"><em>Further reading<\/em><br \/><a href=\"https:\/\/learn.microsoft.com\/en-us\/sql\/relational-databases\/extended-events\/extended-events?view=sql-server-ver16\" target=\"_blank\" rel=\"noopener noreferrer\">XEvents overview &#8211; SQL Server, Azure SQL Database, and Azure SQL Managed Instance | Microsoft Learn<\/a><br \/><a href=\"https:\/\/learn.microsoft.com\/en-us\/sql\/t-sql\/xml\/nodes-method-xml-data-type?view=sql-server-ver16\" target=\"_blank\" rel=\"noopener noreferrer\">nodes() Method (xml Data Type) | Microsoft Learn<\/a>)<\/p>\n<p>Hopefully this is useful.<\/p>\n<p>As this is a new functionality, the security team is very interested in feedback concerning usability and visibility and what we can do to make your life as DBA, Auditor or Developer easier. You can reach out to me using my Firstname dot LastName At Microsoft.com<\/p>\n<p>Happy securing<\/p>\n<p>Andreas<\/p>\n<p>Thank you to the following people for help with this article:<\/p>\n<p>Vlad Rodriguez (Senior Program Manager Purview), Joshua Glassmyer (Program Manager Azure SQL Security), Jakub Szymaszek \u00a0(Principal Program Manager Azure SQL Security), Srdan Bozovic (Senior Program Manager Azure SQL Security), Sailesh Duvvuri (Senior Software Engineer Purview)<\/p>\n<h2 id=\"community-3683097-toc-hId-1520979500\">Appendix: Preview release names<\/h2>\n<p><strong>Memory Clerk<\/strong> in Azure SQL Database Preview release:<\/p>\n<p>SELECT pages_kb\/1024.0 AS [SizeMB], *<\/p>\n<p>FROM sys.dm_os_memory_clerks<\/p>\n<p>WHERE type = &#8216;MEMORYCLERK_RBAC&#8217;<\/p>\n<p><strong>Wait-Type names<\/strong> in Azure SQL Database Preview release:<\/p>\n<table style=\"width: 100%; table-layout: fixed; word-break: break-word; overflow-wrap: anywhere;\">\n<tbody>\n<tr>\n<td>\n<p><strong>Wait Type<\/strong><\/p>\n<\/td>\n<td>\n<p><strong>Description<\/strong><\/p>\n<\/td>\n<\/tr>\n<tr>\n<td>\n<p>WAIT_EXTGOV_PERMCACHE_RESOURCELOCK<\/p>\n<\/td>\n<td>\n<p>Occurs during a read\/write lock on the permission cache, used for the response from the Purview SDK on a permission-lookup.<\/p>\n<\/td>\n<\/tr>\n<tr>\n<td>\n<p>WAIT_EXTGOV_PERMCACHE_DECISIONLOCK<\/p>\n<\/td>\n<td>\n<p>Occurs during a read\/write lock on the permission cache, used for the response from the Purview SDK during evaluation of an AAD principal for a data action.<\/p>\n<\/td>\n<\/tr>\n<tr>\n<td>\n<p>RBAC_AAD_GROUP_INFO<\/p>\n<\/td>\n<td>\n<p>Occurs during waiting on internal lock on a map for caching AAD Group IDs for AAD Users.<\/p>\n<\/td>\n<\/tr>\n<tr>\n<td>\n<p>PURVIEW_POLICY_SDK_PREEMPTIVE_SCHEDULING<\/p>\n<\/td>\n<td>\n<p>Occurs during calls to Purview SDK. Scheduling is switched to preemptive mode. It will occur after PWAIT_PREEMPTIVE_OS_AUTHENTICATEDWEBCALL.<\/p>\n<\/td>\n<\/tr>\n<tr>\n<td>\n<p>WAIT_RBAC_PROVIDER<\/p>\n<\/td>\n<td>\n<p>Occurs during a read\/write lock on the policy provider cache while accessing the stored policies in memory.<\/p>\n<\/td>\n<\/tr>\n<tr>\n<td>\n<p>BABYLON_POLICY_UPDATE<\/p>\n<\/td>\n<td>\n<p>Occurs during updates of the policy cache on a pull task run.<\/p>\n<\/td>\n<\/tr>\n<tr>\n<td>\n<p>WAIT_RBAC_SESSION_AUDIT<\/p>\n<\/td>\n<td>\n<p>Lock to synchronize access to an active session\u2019s audit information containing audited external permission evaluation and their outcome together with applicable policy id and version.<\/p>\n<\/td>\n<\/tr>\n<tr>\n<td>\n<p>WAIT_RBAC_SESSIONS_AUDIT<\/p>\n<\/td>\n<td>\n<p>Lock to synchronize allocation of, or access to Purview permissions audit information object for a session.<\/p>\n<\/td>\n<\/tr>\n<tr>\n<td>\n<p>BABYLON_PULL_TASK<\/p>\n<\/td>\n<td>\n<p>Occurs if there is a background pull task running and a user manually initiates a pull at the same time. This wait type shows up until the background task is done, before the user initiated one can be started.<\/p>\n<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<p>Matching SQL query:<\/p>\n<p>SELECT * FROM sys.dm_os_wait_stats<\/p>\n<p>WHERE wait_type IN<\/p>\n<p>\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 ( &#8216;WAIT_EXTGOV_PERMCACHE_RESOURCELOCK&#8217;<\/p>\n<p>\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 , &#8216;WAIT_EXTGOV_PERMCACHE_DECISIONLOCK&#8217;<\/p>\n<p>\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 , &#8216;RBAC_AAD_GROUP_INFO&#8217;<\/p>\n<p>\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 , &#8216;PURVIEW_POLICY_SDK_PREEMPTIVE_SCHEDULING&#8217;<\/p>\n<p>\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 , &#8216;WAIT_RBAC_SESSION_AUDIT&#8217;<\/p>\n<p>\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 , &#8216;WAIT_RBAC_SESSIONS_AUDIT&#8217;<\/p>\n<p>\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 , &#8216;WAIT_RBAC_PROVIDER&#8217;<\/p>\n<p>\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 , &#8216;BABYLON_POLICY_UPDATE&#8217;<\/p>\n<p>\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 );<\/p>\n<p><strong>XEvent names<\/strong> in Azure SQL Database Preview release:<\/p>\n<table style=\"width: 100%; table-layout: fixed; word-break: break-word; overflow-wrap: anywhere;\">\n<tbody>\n<tr>\n<td>\n<p><strong>Xevent and Description<\/strong><\/p>\n<\/td>\n<\/tr>\n<tr>\n<td>\n<p>external_policy_pulltask_started<\/p>\n<p>XEvent for policy pull start<\/p>\n<\/td>\n<\/tr>\n<tr>\n<td>\n<p>external_policy_pulltask_retries<\/p>\n<p>XEvent for policy pull diagnostics<\/p>\n<\/td>\n<\/tr>\n<tr>\n<td>\n<p>external_policy_pulltask_finished<\/p>\n<p>XEvent for policy pull finish<\/p>\n<\/td>\n<\/tr>\n<tr>\n<td>\n<p>security_external_governance_call<\/p>\n<p>a call to external governance SDK is made<\/p>\n<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n","protected":false},"excerpt":{"rendered":"<p>In this article you will find an overview of all the new metadata that was added to support customers using external data and access Policies from Microsoft Purview. You will find this interesting if you are in a technical role and have access to a SQL database, for example as a DBA or developer or [&hellip;]<\/p>\n","protected":false},"author":4,"featured_media":8126,"comment_status":"open","ping_status":"","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[57],"tags":[450,424],"class_list":["post-8146","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-security-en","tag-azure-en","tag-permissions"],"_links":{"self":[{"href":"https:\/\/andreas-wolter.com\/en\/wp-json\/wp\/v2\/posts\/8146","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/andreas-wolter.com\/en\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/andreas-wolter.com\/en\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/andreas-wolter.com\/en\/wp-json\/wp\/v2\/users\/4"}],"replies":[{"embeddable":true,"href":"https:\/\/andreas-wolter.com\/en\/wp-json\/wp\/v2\/comments?post=8146"}],"version-history":[{"count":2,"href":"https:\/\/andreas-wolter.com\/en\/wp-json\/wp\/v2\/posts\/8146\/revisions"}],"predecessor-version":[{"id":8178,"href":"https:\/\/andreas-wolter.com\/en\/wp-json\/wp\/v2\/posts\/8146\/revisions\/8178"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/andreas-wolter.com\/en\/wp-json\/wp\/v2\/media\/8126"}],"wp:attachment":[{"href":"https:\/\/andreas-wolter.com\/en\/wp-json\/wp\/v2\/media?parent=8146"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/andreas-wolter.com\/en\/wp-json\/wp\/v2\/categories?post=8146"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/andreas-wolter.com\/en\/wp-json\/wp\/v2\/tags?post=8146"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}