Registry / azure / azure-graphrbac

azure-graphrbac

JSON →
library0.61.2pypypi✓ verified 24d ago

The `azure-graphrbac` client library for Python provided an interface to manage Azure Active Directory (Azure AD) resources, such as users, groups, and service principals, through the Azure AD Graph API. This library is effectively abandoned due to the deprecation and upcoming retirement of the underlying Azure AD Graph API, which was superseded by Microsoft Graph. The last release was in August 2020, and it is no longer actively maintained.

pip install azure-graphrbac
INSTALL
IMPORT
SIG · AZURE-GRAPHRBAC
A
azure-graphrbac
azurepythonv0.61.2
Install
4.3s avg
Import
795ms
Disk
44MB
Pass rate
10/ 10
Env Coverage10 / 10
glibc
3.93.13
musl
3.93.13
Install & Compatibility
Where this runs
tested against v0.61.2 · pip install
no network on importno background threads
Install × environment matrix
Each cell = how many times install + import succeeded across repeated harness runs. Partial = flaky.
glibc = Debian/Ubuntu slim · musl = Alpine Linux
musl
py 3.103.95 runs
installs and imports cleanly · install 0.0s · import 0.822s · 45.5MB
glibc
py 3.103.95 runs
installs and imports cleanly · install 4.3s · import 0.768s · 46MB
44MB installed
● package 44MB
Code
Verified usage

Verified import paths — ran on the pinned version, not inferred.

GraphRbacManagementClient
from azure.graphrbac import GraphRbacManagementClient
from azure.mgmt.graphrbac import GraphRbacManagementClient
The client is in the top-level `azure.graphrbac` namespace, not `azure.mgmt.graphrbac`.
ServicePrincipalCredentials
from msrestazure.azure_active_directory import ServicePrincipalCredentials
This is the typical credential type used with older Azure SDKs like `azure-graphrbac`.

This quickstart demonstrates how to instantiate `GraphRbacManagementClient` using a service principal and list users. Ensure your service principal has appropriate permissions (e.g., 'User.Read.All') in Azure AD. This library relies on the now-deprecated Azure AD Graph API.

import os from msrestazure.azure_active_directory import ServicePrincipalCredentials from azure.graphrbac import GraphRbacManagementClient tenant_id = os.environ.get('AZURE_TENANT_ID', '') client_id = os.environ.get('AZURE_CLIENT_ID', '') client_secret = os.environ.get('AZURE_CLIENT_SECRET', '') if not all([tenant_id, client_id, client_secret]): print("Please set AZURE_TENANT_ID, AZURE_CLIENT_ID, and AZURE_CLIENT_SECRET environment variables.") else: try: # Authenticate using Service Principal Credentials credentials = ServicePrincipalCredentials( client_id=client_id, secret=client_secret, tenant=tenant_id ) # Create the Graph RBAC client graph_client = GraphRbacManagementClient(credentials, tenant_id) # Example: List users (will only work if service principal has sufficient permissions) print("Listing first 5 users...") users = list(graph_client.users.list())[:5] if users: for user in users: print(f" User ID: {user.object_id}, Display Name: {user.display_name}") else: print("No users found or insufficient permissions.") except Exception as e: print(f"An error occurred: {e}")
Debug
Known issues
breakingThe underlying Azure AD Graph API is officially deprecated and will be retired. Applications using `azure-graphrbac` will eventually cease to function as the API endpoints are removed. Microsoft has ceased investment in Azure AD Graph as of June 30, 2022.
fix
Migrate all functionality to use the Microsoft Graph API. The recommended Python SDK for Microsoft Graph is `microsoft-graph-sdk` or using `requests` with `azure-identity` to call the Microsoft Graph REST API directly.
affects: All versions
deprecated`azure-graphrbac` itself is deprecated and no longer receives updates or bug fixes, as its last release was in August 2020. Using this library for new development is strongly discouraged.
fix
Use the Microsoft Graph API for all new development concerning Azure Active Directory resources. Consider `azure-identity` for authentication and `microsoft-graph-sdk` or direct REST API calls for resource management.
affects: All versions
gotchaModern Azure SDK authentication methods (e.g., `DefaultAzureCredential` from `azure-identity`) are generally not directly compatible with the older `azure-graphrbac` client library without additional integration layers. It typically expects `ServicePrincipalCredentials` or `ApplicationTokenCredentials`.
fix
If you must use `azure-graphrbac` for legacy reasons, continue to use `msrestazure.azure_active_directory.ServicePrincipalCredentials` for authentication. For modern applications, migrate to Microsoft Graph and its compatible authentication methods.
affects: All versions
Errors
Common errors & fixes
ModuleNotFoundError: No module named 'azure.graphrbac'
The `azure-graphrbac` library is not installed in the current Python environment, or it's implicitly used by older Azure CLI extensions that have not been updated.
fix
Install the package using pip: `pip install azure-graphrbac`. However, it's strongly recommended to migrate to the Microsoft Graph SDK for Python, as `azure-graphrbac` is deprecated.
AttributeError: 'DefaultAzureCredential' object has no attribute 'signed_session'
The `azure-graphrbac` library, which is an older Track 1 Azure SDK, is incompatible with credential objects from the newer `azure-identity` library (Track 2 SDK).
fix
To resolve this, use older credential types compatible with `azure-graphrbac` (e.g., `ServicePrincipalCredentials` or `UserPassCredentials`) or, preferably, migrate to the Microsoft Graph SDK for Python (`msgraph-sdk-python`) which natively supports `azure-identity` credentials.
azure.graphrbac.models.graph_error_py3.GraphErrorException: Access Token missing or malformed.
The authentication token provided to the `azure-graphrbac` client is invalid, expired, or malformed. This often occurs due to changes in Azure AD authentication flows or incorrect credential setup for the deprecated Azure AD Graph API.
fix
Ensure that correct and up-to-date credentials are used for `azure-graphrbac`, potentially specifying the correct `resource` parameter (e.g., `https://graph.windows.net/`) if using `ServicePrincipalCredentials`. The recommended solution is to migrate to the Microsoft Graph API and its corresponding Python SDK.
GraphErrorException: Operation returned an invalid status code 'Not Found'
This error typically indicates that the underlying Azure AD Graph API endpoint being called by `azure-graphrbac` is either retired, the requested resource does not exist, or the authenticated principal lacks the necessary permissions for the operation. This is increasingly common due to the deprecation of the Azure AD Graph API.
fix
Verify the existence of the Azure AD resource you are trying to access and ensure that the service principal or user has the correct, granular permissions assigned within Azure AD for the Azure AD Graph API. The recommended long-term solution is to migrate your application to use the Microsoft Graph API and its official SDK.
Upgrade
Version history
0.61.2latest on PyPI · released Oct 31, 2024
Audit
Dependencies
msrestazurerequiredProvides Azure Active Directory authentication credentials and Azure-specific exceptions.
azure-commonrequiredShared components for Azure SDKs.
Agent activity
51 hits · last 30 days
node
44
OpenAI (training)
1
Resources
azure-graphrbac — pip install azure-graphrbac · libregistry