CtrlK
BlogDocsLog inGet started
Tessl Logo

tessl/pypi-azure-mgmt-search

Microsoft Azure Search Management Client Library for Python

Pending

Quality

Pending

Does it follow best practices?

Impact

Pending

No eval scenarios have been run

Overview
Eval results
Files

usage-monitoring.mddocs/

Usage and Monitoring

Operations for querying usage statistics, quota information, and available Azure operations for monitoring and capacity planning. These capabilities help track resource consumption and plan for scaling search services.

Capabilities

Usage and Quota Information

Query usage statistics and quota limits for search services to monitor consumption and plan capacity requirements.

def list_by_subscription(
    location: str,
    *,
    client_request_id: Optional[str] = None,
    **kwargs
) -> ItemPaged[QuotaUsageResult]:
    """
    Get quota usage information for search services in a specific location.
    
    Parameters:
        location (str): Azure region to query usage for
        client_request_id (str, optional): Client-generated request ID
        
    Returns:
        ItemPaged[QuotaUsageResult]: Usage and quota information for various search service resources
        
    Raises:
        HttpResponseError: Invalid location or access denied
    """

Azure Operations Discovery

List all available Azure operations for the Search Management service to understand available APIs and capabilities.

def list(**kwargs) -> ItemPaged[Operation]:
    """
    List all available operations for the Azure Search Management service.
    
    Returns:
        ItemPaged[Operation]: All available operations with metadata
        
    Raises:
        HttpResponseError: Service error or access denied
    """

Usage Example:

# Get usage information for a specific region
usage_info = client.usages.list_by_subscription(location="East US")

print("Search Service Usage in East US:")
for usage in usage_info:
    print(f"Resource: {usage.name.localized_value}")
    print(f"  Current Usage: {usage.current_value} {usage.unit}")
    print(f"  Limit: {usage.limit} {usage.unit}")
    
    # Calculate usage percentage
    if usage.limit > 0:
        percentage = (usage.current_value / usage.limit) * 100
        print(f"  Usage: {percentage:.1f}%")
        
        # Alert if usage is high
        if percentage > 80:
            print(f"  WARNING: High usage detected!")
    
    print()

# List all available operations
operations = client.operations.list()
print("Available Azure Search Management Operations:")
for operation in operations:
    print(f"Operation: {operation.name}")
    print(f"  Display Name: {operation.display.operation}")
    print(f"  Provider: {operation.display.provider}")
    print(f"  Resource: {operation.display.resource}")
    print(f"  Description: {operation.display.description}")
    print(f"  Origin: {operation.origin}")
    print()

Data Models

QuotaUsageResult

Information about current usage and limits for search service resources.

class QuotaUsageResult:
    """
    Usage and quota information for a search service resource.
    
    Attributes:
        id (str): Usage resource ID
        unit (str): Unit of measurement (e.g., "Count", "Bytes")
        current_value (int): Current usage value
        limit (int): Maximum allowed usage (quota limit)
        name (QuotaUsageResultName): Resource name information
    """

class QuotaUsageResultName:
    """
    Name information for a quota usage result.
    
    Attributes:
        value (str): Resource name identifier
        localized_value (str): Human-readable localized name
    """

Operation

Information about available Azure operations for the Search Management service.

class Operation:
    """
    Azure operation metadata for Search Management service.
    
    Attributes:
        name (str): Operation name (e.g., "Microsoft.Search/searchServices/read")
        display (OperationDisplay): Display information for the operation
        origin (Origin): Origin of the operation
        is_data_action (bool): Whether this is a data plane action
        action_type (ActionType): Type of action
    """

class OperationDisplay:
    """
    Display information for an Azure operation.
    
    Attributes:
        provider (str): Resource provider name
        resource (str): Resource type
        operation (str): Operation name
        description (str): Operation description
    """

Supporting Enums

class Origin(str, Enum):
    """Operation origin values."""
    USER = "user"
    SYSTEM = "system"
    USER_SYSTEM = "user,system"

class ActionType(str, Enum):
    """Action type values."""
    INTERNAL = "internal"

Monitoring Scenarios

Quota Monitoring and Alerting

def monitor_search_quotas(regions: List[str], alert_threshold: float = 80.0):
    """
    Monitor search service quotas across multiple regions and alert on high usage.
    
    Args:
        regions: List of Azure regions to monitor
        alert_threshold: Usage percentage threshold for alerts (default 80%)
    """
    
    alerts = []
    
    for region in regions:
        print(f"\nChecking quotas in {region}:")
        
        try:
            usage_info = client.usages.list_by_subscription(location=region)
            
            for usage in usage_info:
                resource_name = usage.name.localized_value
                current = usage.current_value
                limit = usage.limit
                
                if limit > 0:
                    percentage = (current / limit) * 100
                    print(f"  {resource_name}: {current}/{limit} ({percentage:.1f}%)")
                    
                    # Check if usage exceeds threshold
                    if percentage >= alert_threshold:
                        alert = {
                            "region": region,
                            "resource": resource_name,
                            "usage": current,
                            "limit": limit,
                            "percentage": percentage
                        }
                        alerts.append(alert)
                        print(f"    🚨 ALERT: Usage above {alert_threshold}%!")
                else:
                    print(f"  {resource_name}: {current} (no limit)")
                    
        except Exception as e:
            print(f"  Error getting usage for {region}: {e}")
    
    return alerts

# Monitor quotas in key regions
regions_to_monitor = ["East US", "West US 2", "North Europe", "Southeast Asia"]
alerts = monitor_search_quotas(regions_to_monitor, alert_threshold=75.0)

# Process alerts
if alerts:
    print(f"\n🚨 Found {len(alerts)} quota alerts:")
    for alert in alerts:
        print(f"  {alert['region']}: {alert['resource']} at {alert['percentage']:.1f}%")
else:
    print("\n✅ All quotas within acceptable limits")

Capacity Planning

def analyze_capacity_trends(regions: List[str]):
    """
    Analyze current capacity usage for capacity planning.
    """
    
    capacity_data = {}
    
    for region in regions:
        print(f"\nCapacity Analysis for {region}:")
        
        usage_info = client.usages.list_by_subscription(location=region)
        region_data = {}
        
        for usage in usage_info:
            resource_name = usage.name.localized_value
            current = usage.current_value
            limit = usage.limit
            
            region_data[resource_name] = {
                "current": current,
                "limit": limit,
                "available": limit - current if limit > 0 else "unlimited"
            }
            
            if limit > 0:
                percentage = (current / limit) * 100
                remaining = limit - current
                
                print(f"  {resource_name}:")
                print(f"    Used: {current}/{limit} ({percentage:.1f}%)")
                print(f"    Available: {remaining}")
                
                # Capacity recommendations
                if percentage > 90:
                    print(f"    📈 CRITICAL: Consider requesting quota increase")
                elif percentage > 70:
                    print(f"    ⚠️  WARNING: Monitor closely, may need more capacity soon")
                elif percentage < 20:
                    print(f"    💰 INFO: Significant unused capacity available")
        
        capacity_data[region] = region_data
    
    return capacity_data

# Analyze capacity across regions  
capacity_analysis = analyze_capacity_trends(["East US", "West US 2"])

Service Operation Discovery

def discover_available_operations():
    """
    Discover and categorize all available Azure Search Management operations.
    """
    
    operations = client.operations.list()
    
    # Categorize operations
    categories = {}
    
    for operation in operations:
        # Extract category from operation name
        parts = operation.name.split('/')
        if len(parts) >= 3:
            category = parts[2] if parts[2] != 'searchServices' else parts[3] if len(parts) > 3 else 'general'
        else:
            category = 'general'
        
        if category not in categories:
            categories[category] = []
        
        categories[category].append({
            'name': operation.name,
            'display_name': operation.display.operation,
            'description': operation.display.description,
            'resource': operation.display.resource,
            'origin': operation.origin
        })
    
    # Display categorized operations
    print("Available Azure Search Management Operations:\n")
    
    for category, ops in categories.items():
        print(f"📂 {category.upper()}:")
        for op in ops:
            print(f"  • {op['display_name']}")
            print(f"    {op['description']}")
            print(f"    API: {op['name']}")
        print()
    
    return categories

# Discover all available operations
available_operations = discover_available_operations()

Usage Reporting

def generate_usage_report(regions: List[str], output_file: str = None):
    """
    Generate a comprehensive usage report for search services.
    """
    
    report_data = {
        "timestamp": datetime.now().isoformat(),
        "regions": {},
        "summary": {}
    }
    
    total_usage = {}
    total_limits = {}
    
    for region in regions:
        print(f"Generating report for {region}...")
        
        usage_info = client.usages.list_by_subscription(location=region)
        region_usage = {}
        
        for usage in usage_info:
            resource_name = usage.name.value
            localized_name = usage.name.localized_value
            
            region_usage[resource_name] = {
                "name": localized_name,
                "current": usage.current_value,
                "limit": usage.limit,
                "unit": usage.unit,
                "percentage": (usage.current_value / usage.limit * 100) if usage.limit > 0 else 0
            }
            
            # Accumulate totals
            if resource_name not in total_usage:
                total_usage[resource_name] = 0
                total_limits[resource_name] = 0
            
            total_usage[resource_name] += usage.current_value
            total_limits[resource_name] += usage.limit
        
        report_data["regions"][region] = region_usage
    
    # Generate summary
    for resource_name in total_usage:
        report_data["summary"][resource_name] = {
            "total_usage": total_usage[resource_name],
            "total_limit": total_limits[resource_name],
            "percentage": (total_usage[resource_name] / total_limits[resource_name] * 100) if total_limits[resource_name] > 0 else 0
        }
    
    # Output report
    if output_file:
        import json
        with open(output_file, 'w') as f:
            json.dump(report_data, f, indent=2)
        print(f"Report saved to {output_file}")
    
    return report_data

# Generate usage report
from datetime import datetime
report = generate_usage_report(
    regions=["East US", "West US 2", "North Europe"],
    output_file="search_usage_report.json"
)

Install with Tessl CLI

npx tessl i tessl/pypi-azure-mgmt-search

docs

index.md

key-management.md

network-security.md

private-networking.md

service-management.md

usage-monitoring.md

tile.json