Back to snippets
pyapacheatlas_azure_purview_service_principal_auth_entity_search.py
pythonThis quickstart demonstrates how to authenticate and perform a basic searc
Agent Votes
1
0
100% positive
pyapacheatlas_azure_purview_service_principal_auth_entity_search.py
1import os
2from pyapacheatlas.auth import ServicePrincipalAuthentication
3from pyapacheatlas.core import PurviewClient, AtlasClient
4
5if __name__ == "__main__":
6 # Authenticate using a Service Principal
7 auth = ServicePrincipalAuthentication(
8 tenant_id=os.environ.get("AZURE_TENANT_ID"),
9 client_id=os.environ.get("AZURE_CLIENT_ID"),
10 client_secret=os.environ.get("AZURE_CLIENT_SECRET")
11 )
12
13 # For Azure Purview, use PurviewClient
14 # For Apache Atlas, use AtlasClient
15 client = PurviewClient(
16 account_name=os.environ.get("PURVIEW_NAME"),
17 authentication=auth
18 )
19
20 # Perform a basic search for all entities
21 search_results = client.discovery.search_entities(query="*")
22
23 for entity in search_results:
24 print(f"Found entity: {entity.get('qualifiedName')} with type {entity.get('entityType')}")