01-22-2025 06:21 PM
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)
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
Any insights or guidance would be greatly appreciated. Thanks in advance!
01-23-2025 01:26 PM
I am facing the same issue
01-23-2025 02:56 PM - edited 01-23-2025 02:57 PM
Hi @Asaph, this could be an authentication or missing configuration issue. Please ensure that the AccountClient class instance is created with the required authentication details. Additionally, since this is an account-level operation, check you have account admin privileges to run it successfully.
Example code:
from databricks.sdk import WorkspaceClient, AccountClient
import time
account_client = AccountClient(
host='', # databricks account console host
account_id='', # databricks account id
# authentication options
# client_id/client_secret best practice
client_id='',
client_secret=''
)
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)
Mark as resolved if this solves your issue.
01-23-2025 09:56 PM
This can be a problem with missing configuration or authentication. Please make sure that the necessary authentication information is included when creating the AccountClient class instance. Additionally, make sure you have account admin capabilities to do this operation correctly, as it is account-level.
01-26-2025 01:26 AM
This can be an issue with authentication or configuration being missing. When constructing the AccountClient class instance, please ensure that the required authentication details are present. Additionally, since this action is account-level, make sure you have account admin skills to complete it successfully.
Passionate about hosting events and connecting people? Help us grow a vibrant local community—sign up today to get started!
Sign Up Now