Issue with databricks.sdk - AccountClient Service Principals API

Asaph
New Contributor

Hi everyone,

I’ve been trying to work with the databricks.sdk Python library to manage service principals programmatically. However, I’m running into an issue when attempting to create a service principal using the AccountClient class. Below is the code snippet I’m using:

 

from databricks.sdk import WorkspaceClient, AccountClient
import time

account_client = AccountClient()

sp_create = account_client.service_principals.create(active=True, display_name=f'sdk-{time.time_ns()}')

sp = account_client.service_principals.get(id=sp_create.id)

# cleanup
account_client.service_principals.delete(id=sp_create.id)

 

The Problem

When I execute the above code, I encounter the following error:

 

NotFound                                  Traceback (most recent call last)
Cell In[12], line 1
----> 1 sp_create = account_client.service_principals.create(active=True, display_name=f'sdk-{time.time_ns()}')

File ~/.pyenv/versions/3.8.13/lib/python3.8/site-packages/databricks/sdk/service/iam.py:2257, in AccountServicePrincipalsAPI.create(self, active, application_id, display_name, entitlements, external_id, groups, id, roles, schemas)
...
NotFound: Endpoint not found for /2.0/accounts/ACCOUNT_ID/scim/v2/ServicePrincipals

 

Observations

  • The error indicates a NotFound issue, specifically stating that the endpoint /2.0/accounts/{account_id}/scim/v2/ServicePrincipals could not be found.
  • I suspect the AccountClient might not be properly configured or the SDK might not support this operation for my Databricks environment.

Environment Details

  • Python version: 3.8.13
  • Databricks SDK version: databricks.sdk (latest version from PyPI)
  • Databricks environment: AWS Databricks

Questions

  1. Has anyone successfully used the AccountClient class to manage service principals?
  2. Is there any additional configuration or permissions required to use this API?
  3. Could this be a versioning issue with the SDK or API endpoint?

Any insights or guidance would be greatly appreciated. Thanks in advance!