CtrlK
BlogDocsLog inGet started
Tessl Logo

tessl/pypi-azure-mgmt-consumption

Azure Consumption Management Client for accessing consumption resources, budgets, and usage analytics for Azure Enterprise Subscriptions

Pending

Quality

Pending

Does it follow best practices?

Impact

Pending

No eval scenarios have been run

Overview
Eval results
Files

client-management.mddocs/

Client Management

Core client initialization, configuration, and lifecycle management for the Azure Consumption Management Client. This handles authentication, connection management, and client configuration.

Capabilities

Client Initialization

Initialize the ConsumptionManagementClient with Azure credentials and configuration.

class ConsumptionManagementClient:
    def __init__(
        self,
        credential: TokenCredential,
        subscription_id: str,
        base_url: str = "https://management.azure.com",
        **kwargs
    ) -> None:
        """
        Initialize the Consumption Management Client.
        
        Parameters:
        - credential: Azure credential for authentication (TokenCredential)
        - subscription_id: Azure Subscription ID (str)
        - base_url: Service URL, defaults to "https://management.azure.com" (str)
        - **kwargs: Additional configuration parameters
        """

Usage Example:

from azure.identity import DefaultAzureCredential
from azure.mgmt.consumption import ConsumptionManagementClient

# Using DefaultAzureCredential (recommended)
credential = DefaultAzureCredential()
client = ConsumptionManagementClient(
    credential=credential,
    subscription_id="12345678-1234-1234-1234-123456789abc"
)

# Using specific credential types
from azure.identity import ClientSecretCredential

credential = ClientSecretCredential(
    tenant_id="tenant-id",
    client_id="client-id", 
    client_secret="client-secret"
)
client = ConsumptionManagementClient(credential, subscription_id)

Context Management

The client supports context manager protocol for automatic resource cleanup.

def __enter__(self) -> ConsumptionManagementClient:
    """Enter context manager, returns self."""

def __exit__(self, *exc_details) -> None:
    """Exit context manager, closes client resources."""

def close(self) -> None:
    """Explicitly close the client and clean up resources."""

Usage Example:

# Using context manager (recommended)
with ConsumptionManagementClient(credential, subscription_id) as client:
    budgets = client.budgets.list(scope)
    # Client automatically closed when exiting context

# Manual resource management
client = ConsumptionManagementClient(credential, subscription_id)
try:
    budgets = client.budgets.list(scope)
finally:
    client.close()

Low-Level Request Handling

Access to low-level HTTP request functionality for custom operations.

def _send_request(
    self,
    request: HttpRequest,
    **kwargs
) -> HttpResponse:
    """
    Send a custom HTTP request through the client's configured pipeline.
    
    Parameters:
    - request: The HTTP request to send (HttpRequest)
    - **kwargs: Additional request options (stream: bool, etc.)
    
    Returns:
    HttpResponse: The response from the service
    """

Usage Example:

from azure.core.rest import HttpRequest

# Create custom request
request = HttpRequest("GET", "https://management.azure.com/custom-endpoint")
response = client._send_request(request)
print(f"Status: {response.status_code}")

Types

Authentication Types

from azure.core.credentials import TokenCredential

# Base credential interface
class TokenCredential:
    """Base interface for Azure credential providers."""

HTTP Types

from azure.core.rest import HttpRequest, HttpResponse

class HttpRequest:
    """Represents an HTTP request."""
    
class HttpResponse:
    """Represents an HTTP response."""

Client Configuration

class ConsumptionManagementClientConfiguration:
    """Internal configuration class for the client."""

Install with Tessl CLI

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

docs

aggregated-cost.md

budget-management.md

client-management.md

cost-analysis.md

credits-billing.md

index.md

operations.md

reservation-management.md

tags-operations.md

usage-analytics.md

tile.json