Skip to main content

Microsoft Purview CLI with comprehensive automation capabilities

Project description

PURVIEW CLI v1.0.0 - Microsoft Purview Automation & Data Governance

LATEST UPDATE (June 2025):

  • Major: Advanced Data Product Management (see new data-product command group)
  • Enhanced Discovery Query/Search support (see below for usage).

What is PVW CLI?

PVW CLI v1.0.0 is a modern, full-featured command-line interface and Python library for Microsoft Purview. It enables automation and management of all major Purview APIs including:

  • Entity management (create, update, bulk, import/export)
  • Glossary and term management
  • Lineage operations
  • Collection and account management
  • Advanced search and discovery
  • Data product management (new, see below)
  • Classification, label, and status management
  • And more (see command reference)

The CLI is designed for data engineers, stewards, architects, and platform teams to automate, scale, and enhance their Microsoft Purview experience.


Quick Start (pip install)

Get started with PVW CLI in minutes:

  1. Install the CLI

    pip install pvw-cli
    
  2. Set Environment Variables

    set PURVIEW_ACCOUNT_NAME=your-purview-account
    set AZURE_REGION=  # (optional, e.g. 'china', 'usgov')
    
  3. Authenticate

    • Run az login (recommended)
    • Or set Service Principal credentials as environment variables
  4. Run Your First Search

    pvw search query --keywords="customer" --limit=5
    
  5. See All Commands

    pvw --help
    

For more advanced usage, see the sections below or visit the documentation.


Overview

PVW CLI v1.0.0 is a modern command-line interface and Python library for Microsoft Purview, enabling:

  • Advanced data catalog search and discovery
  • Bulk import/export of entities, glossary terms, and lineage
  • Real-time monitoring and analytics
  • Automated governance and compliance
  • Extensible plugin system

Installation

You can install PVW CLI in two ways:

  1. From PyPI (recommended for most users):

    pip install pvw-cli
    
  2. Directly from the GitHub repository (for latest/dev version):

    pip install git+https://github.com/Keayoub/Purview_cli.git
    

Or for development (editable install):

git clone https://github.com/Keayoub/Purview_cli.git
cd Purview_cli
pip install -r requirements.txt
pip install -e .

Requirements

  • Python 3.8+
  • Azure CLI (az login) or Service Principal credentials
  • Microsoft Purview account

Getting Started

  1. Install

    pip install pvw-cli
    
  2. Set Environment Variables

    set PURVIEW_ACCOUNT_NAME=your-purview-account
    set AZURE_REGION=  # (optional, e.g. 'china', 'usgov')
    
  3. Authenticate

    • Azure CLI: az login

    • Or set Service Principal credentials as environment variables

  4. Run a Command

    pvw search query --keywords="customer" --limit=5
    
  5. See All Commands

    pvw --help
    

Authentication

PVW CLI supports multiple authentication methods for connecting to Microsoft Purview, powered by Azure Identity's DefaultAzureCredential. This allows you to use the CLI securely in local development, CI/CD, and production environments.

1. Azure CLI Authentication (Recommended for Interactive Use)

  • Run az login to authenticate interactively with your Azure account.
  • The CLI will automatically use your Azure CLI credentials.

2. Service Principal Authentication (Recommended for Automation/CI/CD)

Set the following environment variables before running any PVW CLI command:

  • AZURE_CLIENT_ID (your Azure AD app registration/client ID)
  • AZURE_TENANT_ID (your Azure AD tenant ID)
  • AZURE_CLIENT_SECRET (your client secret)

Example (Windows):

set AZURE_CLIENT_ID=xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx
set AZURE_TENANT_ID=xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx
set AZURE_CLIENT_SECRET=your-client-secret

Example (Linux/macOS):

export AZURE_CLIENT_ID=xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx
export AZURE_TENANT_ID=xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx
export AZURE_CLIENT_SECRET=your-client-secret

3. Managed Identity (for Azure VMs, App Services, etc.)

If running in Azure with a managed identity, no extra configuration is needed. The CLI will use the managed identity automatically.

4. Visual Studio/VS Code Authentication

If you are signed in to Azure in Visual Studio or VS Code, DefaultAzureCredential can use those credentials as a fallback.


Note:

  • The CLI will try all supported authentication methods in order. The first one that works will be used.
  • For most automation and CI/CD scenarios, service principal authentication is recommended.
  • For local development, Azure CLI authentication is easiest.

For more details, see the Azure Identity documentation.


Search Command (Discovery Query API)

The PVW CLI provides advanced search using the latest Microsoft Purview Discovery Query API:

  • Search for assets, tables, files, and more with flexible filters
  • Use autocomplete and suggestion endpoints
  • Perform faceted, time-based, and entity-type-specific queries

CLI Usage Examples

# Basic search for assets with keyword 'customer'
pvw search query --keywords="customer" --limit=5

# Advanced search with classification filter
pvw search query --keywords="sales" --classification="PII" --objectType="Tables" --limit=10

# Autocomplete suggestions for partial keyword
pvw search autocomplete --keywords="ord" --limit=3

# Get search suggestions (fuzzy matching)
pvw search suggest --keywords="prod" --limit=2

# Faceted search with aggregation
pvw search query --keywords="finance" --facetFields="objectType,classification" --limit=5

# Browse entities by type and path
pvw search browse --entityType="Tables" --path="/root/finance" --limit=2

# Time-based search for assets created after a date
pvw search query --keywords="audit" --createdAfter="2024-01-01" --limit=1

# Entity type specific search
pvw search query --entityTypes="Files,Tables" --limit=2

Python Usage Example

from purviewcli.client._search import Search

search = Search()
args = {"--keywords": "customer", "--limit": 5}
search.searchQuery(args)
print(search.payload)  # Shows the constructed search payload

Test Examples

See tests/test_search_examples.py for ready-to-run pytest examples covering all search scenarios:

  • Basic query
  • Advanced filter
  • Autocomplete
  • Suggest
  • Faceted search
  • Browse
  • Time-based search
  • Entity type search

Data Product Management (Advanced)

PVW CLI now includes a powerful data-product command group for advanced data product lifecycle management. This is in addition to the CLI's support for all core Purview APIs.

See doc/commands/data-product.md for full documentation and examples.

Example Commands

# Create a data product
pvw data-product create --qualified-name="product.test.1" --name="Test Product" --description="A test data product"

# Add classification and label
pvw data-product add-classification --qualified-name="product.test.1" --classification="PII"
pvw data-product add-label --qualified-name="product.test.1" --label="gold"

# Link glossary term
data-product link-glossary --qualified-name="product.test.1" --term="Customer"

# Set status and show lineage
data-product set-status --qualified-name="product.test.1" --status="active"
data-product show-lineage --qualified-name="product.test.1"

Core Features

  • Discovery Query/Search: Flexible, advanced search for all catalog assets
  • Entity Management: Bulk import/export, update, and validation
  • Glossary Management: Import/export terms, assign terms in bulk
    # List all terms in a glossary
    pvw glossary list-terms --glossary-guid "your-glossary-guid"
    
    # Create and manage glossary terms
    pvw glossary create-term --payload-file term.json
    
  • Lineage Operations: Lineage discovery, CSV-based bulk lineage
  • Monitoring & Analytics: Real-time dashboards, metrics, and reporting
  • Plugin System: Extensible with custom plugins

API Coverage and Upcoming Features

PVW CLI aims to provide comprehensive automation for all major Microsoft Purview APIs. However, some features—such as governance domain CRUD operations—are not yet available via the public REST API as of June 2025.

API Version Support

  • Data Map: 2024-03-01-preview (default) or 2023-09-01 (stable)
  • Collections: 2019-11-01-preview
  • Account: 2019-11-01-preview
  • Management: 2021-07-01
  • Scan: 2018-12-01-preview

Note:

  • Domain management (create, update, delete) is not currently supported by the public API. The CLI will add support for these features as soon as Microsoft releases the necessary endpoints.
  • Please monitor the above links and Azure Updates for new API releases.

If you need a feature that is not yet implemented due to API limitations, please open an issue or check for updates in future releases.


Contributing & Support


PVW CLI empowers data engineers, stewards, and architects to automate, scale, and enhance their Microsoft Purview experience with powerful command-line and programmatic capabilities.

Project details


Release history Release notifications | RSS feed

This version

1.0.4

Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

pvw-cli-1.0.4.tar.gz (113.8 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

pvw_cli-1.0.4-py3-none-any.whl (132.7 kB view details)

Uploaded Python 3

File details

Details for the file pvw-cli-1.0.4.tar.gz.

File metadata

  • Download URL: pvw-cli-1.0.4.tar.gz
  • Upload date:
  • Size: 113.8 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.10.18

File hashes

Hashes for pvw-cli-1.0.4.tar.gz
Algorithm Hash digest
SHA256 c91d9c0979676cb4f8fc80f42812eea54351fcac4ff80c2758366edbbaea1486
MD5 7ae999675ec02101331cf38c9722e046
BLAKE2b-256 783ea82c39b60b06bef05f67226988ac712e934156c7a7cc3aaec3f7bb9c9966

See more details on using hashes here.

File details

Details for the file pvw_cli-1.0.4-py3-none-any.whl.

File metadata

  • Download URL: pvw_cli-1.0.4-py3-none-any.whl
  • Upload date:
  • Size: 132.7 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.10.18

File hashes

Hashes for pvw_cli-1.0.4-py3-none-any.whl
Algorithm Hash digest
SHA256 7b91feb54619dfc7a41be9993f0334ad5a4fb10859caf53b698e9d63faedbbbb
MD5 63bfc27dcc428a5ddb7e2fd2f8544af2
BLAKE2b-256 05a4455611a6a3224b59115d137356775773facfc495019c2409d67fd321cc1a

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page