<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>topic Re: How to make an Entra group available for GRANT commands inside a workspace? in Administration &amp; Architecture</title>
    <link>https://community.databricks.com/t5/administration-architecture/how-to-make-an-entra-group-available-for-grant-commands-inside-a/m-p/155084#M5172</link>
    <description>&lt;P&gt;Genie Code did a decent job fixing this up for me. Thanks again, Ashwin!&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;from databricks.sdk import WorkspaceClient
from databricks.sdk.service.catalog import PermissionsChange, Privilege
import re

catalog_name="dataeng_us"

# Job parameters:
dbutils.widgets.text("entra_group_id", "xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx", "Entra Group ID")
dbutils.widgets.text("schema_name", "xxx", "Schema Name")
entra_group_id = dbutils.widgets.get("entra_group_id")
schema_name = dbutils.widgets.get("schema_name")

# Validate entra group ID looks like a UUID (case insensitive)
if not re.match(r"^[0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{12}$", entra_group_id):
    raise ValueError(f"Invalid entra_group_id '{entra_group_id}'. Must be a valid UUID.")


# Unity Catalog schema names must match: ^[a-zA-Z][a-zA-Z0-9_]{2,254}$
if not re.match(r"^[a-zA-Z][a-zA-Z0-9_]{2,254}$", schema_name):
    raise ValueError(f"Invalid schema name '{schema_name}'. Must start with a letter and contain only letters, numbers, and underscores (3-255 chars).")

print("Starting WorkspaceClient")

w = WorkspaceClient()  # job runs as SP via OAuth

print("Resolving group from Entra")

# 1. Activate group from Entra
# https://databricks-sdk-py.readthedocs.io/en/stable/workspace/iamv2/workspace_iam_v2.html
resolve_group_response = w.workspace_iam_v2.resolve_group_proxy(external_id=entra_group_id)
print(resolve_group_response)
print(resolve_group_response.group)
print(f"Resolved group {resolve_group_response.group.group_name}")

# 2. Create schema (if needed)
full_schema_name = f"{catalog_name}.{schema_name}"
try:
    w.schemas.get(full_name=full_schema_name)
    print(f"Schema '{schema_name}' already exists in catalog '{catalog_name}'.")
except Exception:
    w.schemas.create(
        name=schema_name,
        catalog_name=catalog_name,
    )
    print(f"Schema '{schema_name}' created in catalog '{catalog_name}'.")

# 3. Grant to the group using Unity Catalog API
# TODO: more permissions will be needed.
w.grants.update(
    securable_type="schema",
    full_name=full_schema_name,
    changes=[
        PermissionsChange(
            add=[Privilege.USE_SCHEMA],
            principal=resolve_group_response.group.group_name,
        )
    ],
)&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Tue, 21 Apr 2026 13:06:21 GMT</pubDate>
    <dc:creator>mzs</dc:creator>
    <dc:date>2026-04-21T13:06:21Z</dc:date>
    <item>
      <title>How to make an Entra group available for GRANT commands inside a workspace?</title>
      <link>https://community.databricks.com/t5/administration-architecture/how-to-make-an-entra-group-available-for-grant-commands-inside-a/m-p/154995#M5165</link>
      <description>&lt;P&gt;We're using Azure Databricks and automatic identity management. Users and groups sync over automatically.&lt;/P&gt;&lt;P&gt;If I want to grant permissions to an Entra group to a schema, I can't just run something like this in a workspace notebook:&lt;/P&gt;&lt;P&gt;GRANT USE SCHEMA ON SCHEMA xxx.yyy TO `Example Entra Group`;&lt;/P&gt;&lt;P&gt;It can't find the group. If I go to workspace settings -&amp;gt; security -&amp;gt; groups -&amp;gt; add group, and start typing the name of the group, it populates in a dropdown. If I click on the group it found, the browser makes a GraphQL call to "GetOrCreateIdpGroup". Once that's happened, I can cancel out of the "add group" dialog, and my GRANT query above starts working.&lt;/P&gt;&lt;P&gt;How can I do this programmatically using the API? Ideally at the workspace level.&lt;/P&gt;&lt;P&gt;I'd like to automate the assignment of groups to schemas using a job and service principal. I don't particularly care if the groups are in Entra or Databricks, but I'm trying to avoid using Databricks account-level APIs as they don't have fine-grained permissions: whatever process or job is creating a group in the Databricks account would need full admin privileges at the account level. I figured I could create the groups in Entra instead, because apps in Entra can be given access just to create groups. The group seems like it syncs over, but I can't use it in a GRANT command in a workspace until I go through the "add group" workspace UI above.&lt;/P&gt;</description>
      <pubDate>Mon, 20 Apr 2026 20:51:44 GMT</pubDate>
      <guid>https://community.databricks.com/t5/administration-architecture/how-to-make-an-entra-group-available-for-grant-commands-inside-a/m-p/154995#M5165</guid>
      <dc:creator>mzs</dc:creator>
      <dc:date>2026-04-20T20:51:44Z</dc:date>
    </item>
    <item>
      <title>Re: How to make an Entra group available for GRANT commands inside a workspace?</title>
      <link>https://community.databricks.com/t5/administration-architecture/how-to-make-an-entra-group-available-for-grant-commands-inside-a/m-p/154997#M5166</link>
      <description>&lt;P&gt;Hi&amp;nbsp;&lt;a href="https://community.databricks.com/t5/user/viewprofilepage/user-id/153687"&gt;@mzs&lt;/a&gt;,&lt;/P&gt;
&lt;P&gt;To make sure we suggest the right option, can you share a bit more about your setup?&lt;/P&gt;
&lt;UL&gt;
&lt;LI&gt;Cloud &amp;amp; workspace type: Are you on Azure Databricks, and is the workspace identity-federated (Unity Catalog enabled)?&lt;/LI&gt;
&lt;LI&gt;Identity sync: Are you using Automatic Identity Management (AIM) with Entra, SCIM, or both?&lt;/LI&gt;
&lt;LI&gt;How are you managing groups today? Terraform, REST API, or just SQL GRANT from notebooks?&lt;/LI&gt;
&lt;LI&gt;What principal is running the automation? (service principal vs. user; workspace-admin vs. limited role)&lt;/LI&gt;
&lt;/UL&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Mon, 20 Apr 2026 21:27:07 GMT</pubDate>
      <guid>https://community.databricks.com/t5/administration-architecture/how-to-make-an-entra-group-available-for-grant-commands-inside-a/m-p/154997#M5166</guid>
      <dc:creator>Ashwin_DSA</dc:creator>
      <dc:date>2026-04-20T21:27:07Z</dc:date>
    </item>
    <item>
      <title>Re: How to make an Entra group available for GRANT commands inside a workspace?</title>
      <link>https://community.databricks.com/t5/administration-architecture/how-to-make-an-entra-group-available-for-grant-commands-inside-a/m-p/154998#M5167</link>
      <description>&lt;P&gt;Hi Ashwin, yes, it's Azure Databricks, Unity Catalog is enabled, and automatic identity management is enabled. We are not using SCIM.&lt;/P&gt;&lt;P&gt;I'm looking for ways to automate group creation using a fairly limited-privilege service principal. Either using the REST API from outside Databricks, or maybe a job running as a service principal inside Databricks that I could then trigger from outside. If I do it inside Databricks, I figure I could use GRANT and/or the REST API with WorkspaceClient() and the default credentials available to the job.&lt;/P&gt;&lt;P&gt;This would be using a service principal, probably one that we'd create at either the account or workspace level in Databricks. I would give it the minimum privileges possible to do what it needs to do: create a schema and assign a group to the schema.&lt;/P&gt;&lt;P&gt;But I was testing GRANT manually in the SQL Editor as an Entra user with workspace admin privileges.&lt;/P&gt;</description>
      <pubDate>Mon, 20 Apr 2026 21:37:46 GMT</pubDate>
      <guid>https://community.databricks.com/t5/administration-architecture/how-to-make-an-entra-group-available-for-grant-commands-inside-a/m-p/154998#M5167</guid>
      <dc:creator>mzs</dc:creator>
      <dc:date>2026-04-20T21:37:46Z</dc:date>
    </item>
    <item>
      <title>Re: How to make an Entra group available for GRANT commands inside a workspace?</title>
      <link>https://community.databricks.com/t5/administration-architecture/how-to-make-an-entra-group-available-for-grant-commands-inside-a/m-p/155069#M5169</link>
      <description>&lt;P&gt;Hi&amp;nbsp;&lt;a href="https://community.databricks.com/t5/user/viewprofilepage/user-id/153687"&gt;@mzs&lt;/a&gt;,&lt;/P&gt;
&lt;P&gt;Given that you’re on Azure Databricks + UC + AIM (no SCIM), here are some recommendations.&lt;/P&gt;
&lt;P&gt;Firstly, I think that you should create/manage the group in Entra only.&amp;nbsp;You should avoid creating the groups in Databricks directly. AIM treats Entra as the source of truth.&lt;/P&gt;
&lt;P&gt;You can then programmatically activate the Entra group in Databricks (the UI’s GetOrCreateIdpGroup) using IAM v2.&lt;/P&gt;
&lt;P&gt;Workspace-level endpoint (works from a job or from outside):&lt;/P&gt;
&lt;DIV data-ui-element="code-block-container"&gt;
&lt;PRE&gt;POST https://&amp;lt;workspace-host&amp;gt;/api/2.0/identity/groups/resolveByExternalId
Authorization: Bearer &amp;lt;workspace_admin_SP_OAuth_token&amp;gt;
Content-Type: application/json

{ "external_id": "&amp;lt;entra_group_object_id&amp;gt;" }&lt;/PRE&gt;
&lt;DIV&gt;
&lt;DIV&gt;This ensures the Entra group exists as a Databricks principal (created if needed) and is referenceable by display name in the GRANT/UC APIs in that workspace.&lt;/DIV&gt;
&lt;DIV&gt;&amp;nbsp;&lt;/DIV&gt;
&lt;DIV&gt;You can create a schema and assign permissions with the same SP using REST&amp;nbsp;&lt;/DIV&gt;
&lt;DIV&gt;&amp;nbsp;&lt;/DIV&gt;
&lt;/DIV&gt;
&lt;/DIV&gt;
&lt;DIV data-ui-element="code-block-container"&gt;
&lt;PRE&gt;# Create schema
POST https://&amp;lt;workspace-host&amp;gt;/api/2.1/unity-catalog/schemas
Authorization: Bearer &amp;lt;token&amp;gt;
Content-Type: application/json

{
  "name": "my_schema",
  "catalog_name": "main",
  "comment": "…"
}&lt;/PRE&gt;
&lt;DIV&gt;
&lt;DIV&gt;and then either use SQL&lt;/DIV&gt;
&lt;/DIV&gt;
&lt;/DIV&gt;
&lt;DIV data-ui-element="code-block-container"&gt;
&lt;PRE&gt;GRANT USE SCHEMA ON SCHEMA main.my_schema TO `Example Entra Group`;&lt;/PRE&gt;
&lt;DIV&gt;
&lt;DIV&gt;or UC grants API (/api/2.1/unity-catalog/permissions/…).&lt;/DIV&gt;
&lt;DIV&gt;&amp;nbsp;&lt;/DIV&gt;
&lt;DIV&gt;You can do this inside a Databricks job (recommended) by configuring a workspace-admin service principal for the workspace (minimal Databricks side privilege you need today to call IAM v2 + create schemas):&lt;/DIV&gt;
&lt;/DIV&gt;
&lt;/DIV&gt;
&lt;DIV data-ui-element="code-block-container"&gt;
&lt;PRE&gt;from databricks.sdk import WorkspaceClient

w = WorkspaceClient()  # job runs as SP via OAuth

entra_group_id = "&amp;lt;entra_group_object_id&amp;gt;"
group_display_name = "Example Entra Group"

# 1. Activate group from Entra
w.iamv2.workspace_iam_v2.resolve_group_proxy(external_id=entra_group_id)

# 2. Create schema (if needed)
w.unity_catalog.create_schema(
    name="my_schema",
    catalog_name="main",
)

# 3. Grant to the group by display name
w.sql.statements.execute(
    warehouse_id="&amp;lt;sql_warehouse_id&amp;gt;",
    statement=f"GRANT USE SCHEMA ON SCHEMA main.my_schema TO `{group_display_name}`",
    wait=True,
)&lt;/PRE&gt;
&lt;DIV&gt;
&lt;DIV&gt;From outside Databricks you just trigger this job with the schema + group parameters.&lt;/DIV&gt;
&lt;DIV&gt;&amp;nbsp;&lt;/DIV&gt;
&lt;DIV&gt;In terms of privileges for the Databricks SP... For workspace,&amp;nbsp;make it workspace admin (that’s currently the practical minimum to call identity/groups/resolveByExternalId, and create UC schemas). Fo unity catalog,&amp;nbsp;grant this SP USE CATALOG and CREATE SCHEMA (and OWN/GRANT on the schema if you want it to manage further grants).&lt;/DIV&gt;
&lt;/DIV&gt;
&lt;/DIV&gt;
&lt;P&gt;That gives you no account-admin SCIM or group-creation, groups fully owned in Entra and a&amp;nbsp;single, limited-scope SP that can activate Entra groups via resolveByExternalId, create schemas, and run GRANTs, either as a Databricks job or from an external script using the same REST calls.&lt;/P&gt;
&lt;P&gt;Try this out and let me know how it goes. If you encounter any issues, let me know.&amp;nbsp;&lt;/P&gt;
&lt;P class="p1"&gt;&lt;FONT size="2" color="#FF6600"&gt;&lt;STRONG&gt;&lt;I&gt;If this answer resolves your question, could you mark it as “Accept as Solution”? That helps other users quickly find the correct fix.&lt;/I&gt;&lt;/STRONG&gt;&lt;/FONT&gt;&lt;I&gt;&lt;/I&gt;&lt;/P&gt;</description>
      <pubDate>Tue, 21 Apr 2026 09:57:06 GMT</pubDate>
      <guid>https://community.databricks.com/t5/administration-architecture/how-to-make-an-entra-group-available-for-grant-commands-inside-a/m-p/155069#M5169</guid>
      <dc:creator>Ashwin_DSA</dc:creator>
      <dc:date>2026-04-21T09:57:06Z</dc:date>
    </item>
    <item>
      <title>Re: How to make an Entra group available for GRANT commands inside a workspace?</title>
      <link>https://community.databricks.com/t5/administration-architecture/how-to-make-an-entra-group-available-for-grant-commands-inside-a/m-p/155083#M5171</link>
      <description>&lt;P&gt;Hi Ashwin,&lt;/P&gt;&lt;P&gt;Thanks for your reply. WorkspaceClient doesn't seem to have an iamv2 or workspace_iam_v2 attribute - I get an AttributeError.&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;w = WorkspaceClient()  # job runs as SP via OAuth

resolve_group_response = w.iamv2.workspace_iam_v2.resolve_group_proxy(external_id=entra_group_id)

AttributeError: 'WorkspaceClient' object has no attribute 'iamv2'&lt;/LI-CODE&gt;&lt;P&gt;I'm using Serverless - environment v5:&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="mzs_0-1776774836112.png" style="width: 400px;"&gt;&lt;img src="https://community.databricks.com/t5/image/serverpage/image-id/26251i930DBFF1226D9613/image-size/medium?v=v2&amp;amp;px=400" role="button" title="mzs_0-1776774836112.png" alt="mzs_0-1776774836112.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;Thanks!&lt;/P&gt;</description>
      <pubDate>Tue, 21 Apr 2026 12:34:32 GMT</pubDate>
      <guid>https://community.databricks.com/t5/administration-architecture/how-to-make-an-entra-group-available-for-grant-commands-inside-a/m-p/155083#M5171</guid>
      <dc:creator>mzs</dc:creator>
      <dc:date>2026-04-21T12:34:32Z</dc:date>
    </item>
    <item>
      <title>Re: How to make an Entra group available for GRANT commands inside a workspace?</title>
      <link>https://community.databricks.com/t5/administration-architecture/how-to-make-an-entra-group-available-for-grant-commands-inside-a/m-p/155084#M5172</link>
      <description>&lt;P&gt;Genie Code did a decent job fixing this up for me. Thanks again, Ashwin!&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;from databricks.sdk import WorkspaceClient
from databricks.sdk.service.catalog import PermissionsChange, Privilege
import re

catalog_name="dataeng_us"

# Job parameters:
dbutils.widgets.text("entra_group_id", "xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx", "Entra Group ID")
dbutils.widgets.text("schema_name", "xxx", "Schema Name")
entra_group_id = dbutils.widgets.get("entra_group_id")
schema_name = dbutils.widgets.get("schema_name")

# Validate entra group ID looks like a UUID (case insensitive)
if not re.match(r"^[0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{12}$", entra_group_id):
    raise ValueError(f"Invalid entra_group_id '{entra_group_id}'. Must be a valid UUID.")


# Unity Catalog schema names must match: ^[a-zA-Z][a-zA-Z0-9_]{2,254}$
if not re.match(r"^[a-zA-Z][a-zA-Z0-9_]{2,254}$", schema_name):
    raise ValueError(f"Invalid schema name '{schema_name}'. Must start with a letter and contain only letters, numbers, and underscores (3-255 chars).")

print("Starting WorkspaceClient")

w = WorkspaceClient()  # job runs as SP via OAuth

print("Resolving group from Entra")

# 1. Activate group from Entra
# https://databricks-sdk-py.readthedocs.io/en/stable/workspace/iamv2/workspace_iam_v2.html
resolve_group_response = w.workspace_iam_v2.resolve_group_proxy(external_id=entra_group_id)
print(resolve_group_response)
print(resolve_group_response.group)
print(f"Resolved group {resolve_group_response.group.group_name}")

# 2. Create schema (if needed)
full_schema_name = f"{catalog_name}.{schema_name}"
try:
    w.schemas.get(full_name=full_schema_name)
    print(f"Schema '{schema_name}' already exists in catalog '{catalog_name}'.")
except Exception:
    w.schemas.create(
        name=schema_name,
        catalog_name=catalog_name,
    )
    print(f"Schema '{schema_name}' created in catalog '{catalog_name}'.")

# 3. Grant to the group using Unity Catalog API
# TODO: more permissions will be needed.
w.grants.update(
    securable_type="schema",
    full_name=full_schema_name,
    changes=[
        PermissionsChange(
            add=[Privilege.USE_SCHEMA],
            principal=resolve_group_response.group.group_name,
        )
    ],
)&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 21 Apr 2026 13:06:21 GMT</pubDate>
      <guid>https://community.databricks.com/t5/administration-architecture/how-to-make-an-entra-group-available-for-grant-commands-inside-a/m-p/155084#M5172</guid>
      <dc:creator>mzs</dc:creator>
      <dc:date>2026-04-21T13:06:21Z</dc:date>
    </item>
    <item>
      <title>Re: How to make an Entra group available for GRANT commands inside a workspace?</title>
      <link>https://community.databricks.com/t5/administration-architecture/how-to-make-an-entra-group-available-for-grant-commands-inside-a/m-p/155098#M5174</link>
      <description>&lt;P&gt;That's great. I was planning to respond later today, but I'm glad it's resolved now.&lt;/P&gt;</description>
      <pubDate>Tue, 21 Apr 2026 14:17:44 GMT</pubDate>
      <guid>https://community.databricks.com/t5/administration-architecture/how-to-make-an-entra-group-available-for-grant-commands-inside-a/m-p/155098#M5174</guid>
      <dc:creator>Ashwin_DSA</dc:creator>
      <dc:date>2026-04-21T14:17:44Z</dc:date>
    </item>
  </channel>
</rss>

