{"id":6501,"library":"agent-framework-purview","title":"Microsoft Purview Integration for Microsoft Agent Framework","description":"The `agent-framework-purview` library provides integration with Microsoft Purview's Graph dataSecurityAndGovernance APIs for the Microsoft Agent Framework. It enables agents to interact with Purview, performing tasks like searching for data assets, managing policies, and ingesting metadata. Currently in beta version `1.0.0b260409`, the library is actively developed with a focus on integrating data governance capabilities into AI agent workflows.","status":"active","version":"1.0.0b260409","language":"en","source_language":"en","source_url":"https://github.com/microsoft/agent-framework-purview-python","tags":["Microsoft","Azure","Purview","Agent Framework","Data Governance","AI Agent","Graph API"],"install":[{"cmd":"pip install agent-framework-purview","lang":"bash","label":"Install stable (beta) version"}],"dependencies":[{"reason":"Core dependency for the underlying agent framework functionality.","package":"agent-framework","optional":false},{"reason":"Required for Azure authentication, often via DefaultAzureCredential.","package":"azure-identity","optional":false},{"reason":"Provides core functionality for interacting with Microsoft Graph APIs.","package":"msgraph-core","optional":false},{"reason":"Provides Purview Data Map client functionality.","package":"azure-purview-datamap","optional":false},{"reason":"Used for data validation and settings management.","package":"pydantic","optional":false},{"reason":"Optional for loading environment variables from .env files during local development.","package":"python-dotenv","optional":true}],"imports":[{"symbol":"PurviewAgent","correct":"from agent_framework_purview.purview_agent import PurviewAgent"},{"symbol":"AgentProcessor","correct":"from agent_framework.core.processor import AgentProcessor"},{"symbol":"DefaultAzureCredential","correct":"from azure.identity.aio import DefaultAzureCredential"}],"quickstart":{"code":"import os\nimport asyncio\nfrom agent_framework_purview.purview_agent import PurviewAgent\nfrom agent_framework.core.processor import AgentProcessor\nfrom azure.identity.aio import DefaultAzureCredential\n\nasync def main():\n    # Ensure AZURE_TENANT_ID, AZURE_CLIENT_ID, AZURE_CLIENT_SECRET, etc., are set\n    # for DefaultAzureCredential to authenticate. For local development, \n    # 'az login' or environment variables are common. For production, \n    # Managed Identity is recommended.\n    credential = DefaultAzureCredential()\n\n    # The Purview Agent requires the Azure Purview account name.\n    # Replace 'your_purview_account_name' or set AZURE_PURVIEW_ACCOUNT_NAME env var.\n    purview_account_name = os.environ.get(\n        \"AZURE_PURVIEW_ACCOUNT_NAME\", \"your_purview_account_name\"\n    )\n    if purview_account_name == \"your_purview_account_name\":\n        print(\"WARNING: Please set AZURE_PURVIEW_ACCOUNT_NAME environment variable or update the code.\")\n        return\n\n    purview_agent_config = {\n        \"azure_purview_account_name\": purview_account_name,\n        \"purview_scope\": [\"https://purview.azure.net/.default\"], # Standard scope\n    }\n\n    try:\n        purview_agent: PurviewAgent = await AgentProcessor.create_agent(\n            PurviewAgent,\n            credential=credential,\n            config=purview_agent_config\n        )\n\n        print(f\"Agent created for Purview account: {purview_account_name}\")\n\n        # Example invocation: find assets matching a query string\n        print(\"Invoking agent to find assets...\")\n        response = await purview_agent.invoke(\n            \"find assets\",\n            query_string=\"Sales Data\"\n        )\n\n        print(\"\\n--- Purview Agent Response ---\")\n        print(f\"Content: {response.content}\")\n        if response.citations:\n            print(f\"Citations: {response.citations}\")\n        else:\n            print(\"No citations found.\")\n\n    except Exception as e:\n        print(f\"An error occurred: {e}\")\n    finally:\n        await credential.close()\n\nif __name__ == \"__main__\":\n    asyncio.run(main())","lang":"python","description":"This quickstart demonstrates how to initialize the `PurviewAgent` and use it to interact with Azure Purview. It sets up `DefaultAzureCredential` for authentication and configures the agent with the Purview account name. It then invokes the agent to 'find assets' based on a query string. Ensure your Azure environment variables for authentication (e.g., `AZURE_CLIENT_ID`, `AZURE_TENANT_ID`, `AZURE_CLIENT_SECRET`) and `AZURE_PURVIEW_ACCOUNT_NAME` are set."},"warnings":[{"fix":"Monitor GitHub repository and PyPI for updates. Test thoroughly when upgrading between beta versions and before moving to production.","message":"This library is in beta (`1.x.x` versions starting with `b`). API surfaces, configuration options, and internal implementations are subject to change without strict adherence to semantic versioning until a stable `1.0.0` release.","severity":"breaking","affected_versions":"All beta versions (1.0.0b*)"},{"fix":"Ensure environment variables like `AZURE_TENANT_ID`, `AZURE_CLIENT_ID`, `AZURE_CLIENT_SECRET` are correctly configured, or use `az login` (for CLI credential), or configure Managed Identity for Azure-hosted services. Refer to `azure-identity` documentation.","message":"Proper Azure authentication setup is crucial. `DefaultAzureCredential` relies on environment variables, Azure CLI login, Managed Identity, etc. Incorrect setup will lead to authentication errors.","severity":"gotcha","affected_versions":"All versions"},{"fix":"Ensure `agent-framework` is installed alongside `agent-framework-purview`. Understand the `AgentProcessor` patterns for creating and invoking agents.","message":"This library is an extension of the `agent-framework` core library. It is not standalone and requires `agent-framework` to be installed and used for agent creation and processing.","severity":"gotcha","affected_versions":"All versions"},{"fix":"Wrap your agent code in an `async` function and run it using `asyncio.run(your_async_function())`.","message":"Most interactions with the Purview agent, including its initialization (`AgentProcessor.create_agent`) and invocation (`purview_agent.invoke`), are asynchronous. Users must use `async/await` and run their code within an `asyncio` event loop.","severity":"gotcha","affected_versions":"All versions"},{"fix":"Provide the `azure_purview_account_name` in the `config` dictionary when calling `AgentProcessor.create_agent`, or ensure it's loaded from environment variables if the agent's internal configuration supports it.","message":"The `PurviewAgentConfig` requires the `azure_purview_account_name` parameter to specify which Purview account to connect to. Failing to provide this will result in configuration errors or inability to connect.","severity":"gotcha","affected_versions":"All versions"}],"env_vars":null,"last_verified":"2026-04-15T00:00:00.000Z","next_check":"2026-07-14T00:00:00.000Z","problems":[{"fix":"Install the module using pip: 'pip install agent-framework-purview'.","cause":"The 'agent_framework_purview' module is not installed or the installation is incomplete.","error":"ModuleNotFoundError: No module named 'agent_framework_purview'"},{"fix":"Ensure you have the latest version of 'agent-framework-purview' installed: 'pip install --upgrade agent-framework-purview'.","cause":"The 'PurviewPolicyMiddleware' class is not available in the 'agent_framework.microsoft' module, possibly due to an outdated version.","error":"ImportError: cannot import name 'PurviewPolicyMiddleware' from 'agent_framework.microsoft'"},{"fix":"Verify that your Azure subscription has the necessary Purview licensing and billing configurations.","cause":"The Microsoft Purview service requires appropriate licensing or billing setup, which is missing.","error":"PurviewServiceError: 402 Payment Required - tenant lacks proper Purview licensing or consumptive billing setup"},{"fix":"Implement exponential backoff and retry logic to handle rate limiting, and ensure your application adheres to Purview's usage guidelines.","cause":"The application has exceeded the allowed number of requests to the Purview service within a given timeframe.","error":"PurviewServiceError: 429 Too Many Requests - rate limit exceeded"},{"fix":"Ensure that your application is correctly configured with valid Azure credentials and that the necessary permissions are granted.","cause":"Authentication to the Purview service failed due to invalid or missing credentials.","error":"PurviewServiceError: 401 Unauthorized - token acquisition/validation issues"}]}