{"id":1363,"library":"azure-mgmt-eventgrid","title":"Azure Event Grid Management Client Library","description":"The Microsoft Azure Event Grid Management Client Library for Python allows developers to programmatically manage Event Grid resources such as topics, domains, and event subscriptions within Azure. It is part of the Azure SDK for Python (Track 2) and follows a regular release cadence, often aligning with updates to the underlying Azure REST APIs. The current stable version is 10.4.0.","status":"active","version":"10.4.0","language":"python","source_language":"en","source_url":"https://github.com/Azure/azure-sdk-for-python","tags":["azure","cloud","event-grid","management","sdk","resource-management"],"install":[{"cmd":"pip install azure-mgmt-eventgrid","lang":"bash","label":"Install stable version"}],"dependencies":[{"reason":"Required for core Azure management client functionalities.","package":"azure-mgmt-core","optional":false},{"reason":"Highly recommended for authentication with Azure services, providing various credential types.","package":"azure-identity","optional":true}],"imports":[{"symbol":"EventGridManagementClient","correct":"from azure.mgmt.eventgrid import EventGridManagementClient"},{"note":"Required for authenticating with Azure services. Install separately with `pip install azure-identity`.","symbol":"DefaultAzureCredential","correct":"from azure.identity import DefaultAzureCredential"}],"quickstart":{"code":"import os\nfrom azure.identity import DefaultAzureCredential\nfrom azure.mgmt.eventgrid import EventGridManagementClient\n\n# Set your Azure Subscription ID as an environment variable or replace directly\n# Example: export AZURE_SUBSCRIPTION_ID=\"<your-subscription-id>\"\nsubscription_id = os.environ.get(\"AZURE_SUBSCRIPTION_ID\", \"\")\n\nif not subscription_id:\n    raise ValueError(\"AZURE_SUBSCRIPTION_ID environment variable not set.\")\n\n# Acquire a credential object using DefaultAzureCredential\n# This will attempt to authenticate via various methods:\n# Environment variables, Managed Identity, Azure CLI, VS Code, etc.\n# For local development, ensure you are logged in via Azure CLI (`az login`)\ncredential = DefaultAzureCredential()\n\n# Create the Event Grid Management Client\nclient = EventGridManagementClient(credential, subscription_id)\n\nprint(f\"Listing Event Grid topics in subscription: {subscription_id}\")\n\ntry:\n    # List all Event Grid topics in the subscription\n    topics = client.topics.list_by_subscription()\n    for topic in topics:\n        print(f\"- Topic Name: {topic.name}, Location: {topic.location}\")\nexcept Exception as e:\n    print(f\"An error occurred: {e}\")\n    print(\"Ensure you have 'Contributor' or 'Owner' role on the subscription.\")\n","lang":"python","description":"This quickstart demonstrates how to authenticate with Azure using `DefaultAzureCredential` and then list all Event Grid topics within a specified Azure subscription using the `EventGridManagementClient`. Ensure you have the `AZURE_SUBSCRIPTION_ID` environment variable set and have appropriate permissions in Azure."},"warnings":[{"fix":"Consult the official migration guide and release notes for the specific library version. Update your code to reflect new model structures or method signatures.","message":"Azure SDK for Python libraries (Track 2) often introduce breaking changes between major versions. These changes typically align with updates to the underlying Azure REST APIs or the SDK guidelines, affecting resource models, method signatures, or parameter names. Always review release notes when upgrading to a new major version.","severity":"breaking","affected_versions":"All major version upgrades (e.g., v9.x.x to v10.x.x)"},{"fix":"Implement polling mechanisms or introduce delays to wait for resources to reach a stable `succeeded` provisioning state before attempting subsequent operations. The Azure SDK may provide `begin_create_or_update` methods that return long-running operation pollers.","message":"Resource provisioning in Azure (like creating an Event Grid topic or domain) can be an asynchronous operation. Chaining dependent operations too quickly after a create/update call might result in 'resource not found' or 'resource not ready' errors due to eventual consistency.","severity":"gotcha","affected_versions":"All versions"},{"fix":"Ensure you are using the correct library for your task: `azure-mgmt-eventgrid` for resource management (create, update, delete topics/domains) and `azure-eventgrid` for data plane operations (send/receive events).","message":"The `azure-mgmt-eventgrid` library manages Event Grid resources. For publishing or consuming events, you need `azure-eventgrid` (the data plane SDK), which is a separate library with different imports and client objects.","severity":"gotcha","affected_versions":"All versions"},{"fix":"For local development, ensure you've run `az login` or configured the necessary environment variables for your chosen credential type. For production, consider Managed Identities for Azure resources.","message":"Authentication with Azure services locally requires setting up `DefaultAzureCredential` correctly. Common issues include not being logged in via `az login` (Azure CLI) or missing required environment variables for service principal authentication (`AZURE_CLIENT_ID`, `AZURE_TENANT_ID`, `AZURE_CLIENT_SECRET`).","severity":"gotcha","affected_versions":"All versions"},{"fix":"Ensure the `azure-identity` package is installed in your Python environment. You can typically install it using pip: `pip install azure-identity`.","message":"To use `DefaultAzureCredential` or any other credential from `azure.identity` for authenticating with Azure services, the `azure-identity` package must be installed. A `ModuleNotFoundError` for `azure.identity` indicates this package is missing from your environment.","severity":"gotcha","affected_versions":"All versions"},{"fix":"Ensure `azure-identity` is listed in your `requirements.txt` or installed via `pip install azure-identity`.","message":"To use `DefaultAzureCredential` or other credential types from the Azure Identity library, the `azure-identity` package must be installed. This error typically means the package was not included in your project's dependencies.","severity":"gotcha","affected_versions":"All versions"}],"env_vars":null,"search_vec":"'10.4.0':66 '2':44 'align':52 'allow':17 'api':60 'azur':1,9,33,39,58,67 'cadenc':50 'client':5,13 'cloud':68 'current':62 'develop':18 'domain':28 'event':2,10,22,30,70 'event-grid':69 'follow':46 'grid':3,11,23,71 'librari':6,14 'manag':4,12,21,72,76 'microsoft':8 'often':51 'part':36 'programmat':20 'python':16,42 'regular':48 'releas':49 'resourc':24,75 'resource-manag':74 'rest':59 'sdk':40,73 'stabl':63 'subscript':31 'topic':27 'track':43 'under':57 'updat':54 'version':64 'within':32","created_at":"2026-04-09T03:44:43.589155+00:00","updated_at":"2026-04-15T22:43:10.861827+00:00","problems":[{"fix":"pip install azure-mgmt-eventgrid","cause":"The `azure-mgmt-eventgrid` package is not installed in the current Python environment.","error":"ModuleNotFoundError: No module named 'azure.mgmt.eventgrid'"},{"fix":"Ensure `AZURE_CLIENT_ID`, `AZURE_TENANT_ID`, and `AZURE_CLIENT_SECRET` (or other credential-specific environment variables) are correctly set, and that the authenticated identity has the necessary Event Grid roles (e.g., 'Event Grid Data Sender' or 'Event Grid Contributor').","cause":"The application cannot authenticate with Azure due to missing or incorrect environment variables for `DefaultAzureCredential`, or insufficient permissions for the assigned identity.","error":"ClientAuthenticationError: DefaultAzureCredential failed to retrieve a token from the included credentials."},{"fix":"Verify the resource name, resource group name, and subscription ID, and ensure the authenticated identity has 'Reader' or appropriate Event Grid permissions on the resource.","cause":"The specified Azure Event Grid resource (e.g., topic, domain, or event subscription) does not exist, the name, resource group, or subscription ID is incorrect, or the authenticated identity lacks permissions to view it.","error":"Code=ResourceNotFound; Message=The Resource 'Microsoft.EventGrid/topics/{topic_name}' under resource group {resource_group_name} was not found."},{"fix":"Access operations through their respective operation groups (e.g., `client.topics.create_or_update(...)` instead of `client.create_or_update_topic(...)`) and consult the library's documentation for the correct API usage for your installed version.","cause":"The code is attempting to access an operation directly on the `EventGridManagementClient` that is part of an operation group (like 'topics', 'event_subscriptions', 'domains') or a method that has been renamed or removed in a different library version.","error":"AttributeError: 'EventGridManagementClient' object has no attribute 'topics'"}],"ecosystem":"pypi","meta_description":null,"install_score":100,"quickstart_score":null,"quickstart_tag":null,"pypi_latest":"10.4.0","cli_name":"","cli_version":null,"type":"library","homepage":null,"github":"https://github.com/Azure/azure-sdk-for-python","docs":null,"changelog":null,"pypi":"https://pypi.org/project/azure-mgmt-eventgrid/","npm":null,"openapi_spec":null,"status_page":null,"smithery":null,"categories":["azure"],"base_url":null,"auth_type":null,"provenance":{"verified_status":"passing","verified_at":"2026-06-28","last_verified":"2026-08-27","next_check":"2026-07-28","install_tag":"verified"}}