CtrlK
BlogDocsLog inGet started
Tessl Logo

tessl/pypi-azure-mgmt-storage

Microsoft Azure Storage 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

utilities.mddocs/

Utility Operations

Operations for discovering available SKUs, checking usage limits, managing deleted accounts, and retrieving service metadata. These utilities provide essential information for storage account planning and management.

Capabilities

SKU Information

Discover available storage account SKUs and their capabilities across Azure regions.

class SkusOperations:
    def list(self) -> ItemPaged[SkuInformation]:
        """
        Lists the available SKUs supported by Microsoft.Storage.
        
        Returns:
        Paginated list of SkuInformation objects with available SKUs
        """

Usage example:

# List all available SKUs
skus = list(client.skus.list())

for sku in skus:
    print(f"SKU: {sku.name}, Tier: {sku.tier}")
    print(f"  Kind: {sku.kind}")
    print(f"  Locations: {sku.locations}")
    print(f"  Capabilities: {[cap.name + '=' + cap.value for cap in sku.capabilities]}")
    print(f"  Restrictions: {len(sku.restrictions)} restriction(s)")
    print()

# Filter for specific SKU types
premium_skus = [sku for sku in skus if "Premium" in sku.name]
standard_skus = [sku for sku in skus if "Standard" in sku.name]

print(f"Premium SKUs: {len(premium_skus)}")
print(f"Standard SKUs: {len(standard_skus)}")

Usage and Limits

Check current usage and limits for storage resources in specific Azure regions.

class UsagesOperations:
    def list_by_location(self, location: str) -> ItemPaged[Usage]:
        """
        Lists storage usage metrics for the specified location.
        
        Parameters:
        - location: Azure region name (e.g., "East US", "West Europe")
        
        Returns:
        Paginated list of Usage objects showing current usage and limits
        """

Usage example:

# Check usage in specific regions
regions = ["East US", "West Europe", "Southeast Asia"]

for region in regions:
    print(f"\nUsage in {region}:")
    usages = list(client.usages.list_by_location(region))
    
    for usage in usages:
        print(f"  {usage.name.value}: {usage.current_value}/{usage.limit} {usage.unit}")
        if usage.current_value > (usage.limit * 0.8):
            print(f"    WARNING: Usage at {(usage.current_value/usage.limit)*100:.1f}% of limit")

# Find regions with available capacity
available_regions = []
for region in ["East US", "West US", "Central US", "North Europe", "West Europe"]:
    usages = list(client.usages.list_by_location(region))
    storage_account_usage = next((u for u in usages if "StorageAccounts" in u.name.value), None)
    
    if storage_account_usage and storage_account_usage.current_value < storage_account_usage.limit:
        available_capacity = storage_account_usage.limit - storage_account_usage.current_value
        available_regions.append({
            "region": region,
            "available": available_capacity,
            "total": storage_account_usage.limit
        })

print(f"\nRegions with available storage account capacity:")
for region_info in sorted(available_regions, key=lambda x: x["available"], reverse=True):
    print(f"  {region_info['region']}: {region_info['available']} available")

Deleted Account Recovery

Manage and recover soft-deleted storage accounts.

class DeletedAccountsOperations:
    def list(self) -> ItemPaged[DeletedAccount]:
        """
        Lists deleted accounts under the subscription.
        
        Returns:
        Paginated list of DeletedAccount objects that can be restored
        """
    
    def get(self, deleted_account_name: str, location: str) -> DeletedAccount:
        """
        Gets properties of the specified deleted account.
        
        Parameters:
        - deleted_account_name: Name of the deleted storage account
        - location: Location of the deleted account
        
        Returns:
        DeletedAccount with restoration details
        """

Usage example:

# List all deleted accounts that can be restored
deleted_accounts = list(client.deleted_accounts.list())

print(f"Found {len(deleted_accounts)} deleted storage accounts:")
for deleted_account in deleted_accounts:
    print(f"  Account: {deleted_account.name}")
    print(f"  Original Location: {deleted_account.location}")
    print(f"  Deletion Time: {deleted_account.deletion_time}")
    print(f"  Remaining Retention Days: {deleted_account.remaining_retention_days}")
    print(f"  Restorable: {'Yes' if deleted_account.remaining_retention_days > 0 else 'No'}")
    print()

# Get details for a specific deleted account
if deleted_accounts:
    first_deleted = deleted_accounts[0]
    account_details = client.deleted_accounts.get(
        deleted_account_name=first_deleted.name,
        location=first_deleted.location
    )
    
    print(f"Details for {account_details.name}:")
    print(f"  Storage Account Type: {account_details.storage_account_type}")
    print(f"  Creation Time: {account_details.creation_time}")
    print(f"  Can Restore: {account_details.remaining_retention_days > 0}")

Service Operations Metadata

Retrieve metadata about available Azure Storage management operations.

class Operations:
    def list(self) -> ItemPaged[Operation]:
        """
        Lists all available Azure Storage management operations.
        
        Returns:
        Paginated list of Operation objects describing available API operations
        """

Usage example:

# List all available operations
operations = list(client.operations.list())

print(f"Available operations: {len(operations)}")

# Group operations by resource type
operation_groups = {}
for op in operations:
    # Extract resource type from operation name
    parts = op.name.split('/')
    if len(parts) >= 2:
        provider = parts[0]  # Microsoft.Storage
        resource_type = parts[1]  # storageAccounts, blobServices, etc.
        
        if resource_type not in operation_groups:
            operation_groups[resource_type] = []
        operation_groups[resource_type].append(op)

# Display operations by resource type
for resource_type, ops in sorted(operation_groups.items()):
    print(f"\n{resource_type} operations ({len(ops)}):")
    for op in ops[:5]:  # Show first 5 operations
        print(f"  {op.name}")
        print(f"    Display: {op.display.operation}")
        print(f"    Description: {op.display.description}")
    
    if len(ops) > 5:
        print(f"  ... and {len(ops) - 5} more operations")

# Find specific operations
storage_account_ops = [op for op in operations if "storageAccounts" in op.name]
blob_ops = [op for op in operations if "blobServices" or "blobContainers" in op.name]

print(f"\nStorage Account operations: {len(storage_account_ops)}")
print(f"Blob-related operations: {len(blob_ops)}")

# Check for read vs write operations
read_ops = [op for op in operations if any(verb in op.name.lower() for verb in ['read', 'get', 'list'])]
write_ops = [op for op in operations if any(verb in op.name.lower() for verb in ['write', 'create', 'update', 'delete'])]

print(f"Read operations: {len(read_ops)}")
print(f"Write operations: {len(write_ops)}")

Checking Service Availability

Combine utilities to check service availability and capacity planning.

def check_service_availability(regions_to_check, required_sku="Standard_LRS"):
    """
    Check service availability across multiple regions.
    
    Parameters:
    - regions_to_check: List of Azure region names
    - required_sku: SKU name to check availability for
    
    Returns:
    Dictionary with availability information per region
    """
    availability = {}
    
    # Check if SKU is available
    available_skus = list(client.skus.list())
    target_sku = next((sku for sku in available_skus if sku.name == required_sku), None)
    
    if not target_sku:
        print(f"SKU {required_sku} not found")
        return availability
    
    for region in regions_to_check:
        region_info = {
            "sku_available": region in target_sku.locations,
            "usage_info": None,
            "restrictions": []
        }
        
        # Check usage limits
        try:
            usages = list(client.usages.list_by_location(region))
            storage_usage = next((u for u in usages if "StorageAccounts" in u.name.value), None)
            if storage_usage:
                region_info["usage_info"] = {
                    "current": storage_usage.current_value,
                    "limit": storage_usage.limit,
                    "available": storage_usage.limit - storage_usage.current_value,
                    "utilization_pct": (storage_usage.current_value / storage_usage.limit) * 100
                }
        except Exception as e:
            region_info["usage_error"] = str(e)
        
        # Check SKU restrictions for this region
        for restriction in target_sku.restrictions:
            if region in restriction.values:
                region_info["restrictions"].append({
                    "type": restriction.type,
                    "reason": restriction.reason_code
                })
        
        availability[region] = region_info
    
    return availability

# Example usage
regions = ["East US", "West US 2", "North Europe", "Southeast Asia"]
availability = check_service_availability(regions, "Standard_GRS")

for region, info in availability.items():
    print(f"\n{region}:")
    print(f"  SKU Available: {info['sku_available']}")
    if info.get('usage_info'):
        usage = info['usage_info']
        print(f"  Capacity: {usage['available']}/{usage['limit']} available ({usage['utilization_pct']:.1f}% used)")
    if info['restrictions']:
        print(f"  Restrictions: {len(info['restrictions'])}")
        for restriction in info['restrictions']:
            print(f"    {restriction['type']}: {restriction['reason']}")

API Operations Discovery

List all available REST API operations for the Azure Storage service.

class Operations:
    def list(self) -> ItemPaged[Operation]:
        """
        Lists all of the available Storage REST API operations.
        
        Returns:
        ItemPaged[Operation]: Paginated list of available operations with metadata
        """

Usage example:

# List all available storage operations
operations = list(client.operations.list())

print(f"Available operations: {len(operations)}")
for operation in operations[:5]:  # Show first 5
    print(f"- {operation.name}: {operation.display.description}")
    print(f"  Resource: {operation.display.resource}")
    print(f"  Provider: {operation.display.provider}")

Types

class SkuInformation:
    """Information about a storage SKU."""
    name: SkuName
    tier: SkuTier
    resource_type: str
    kind: Kind
    locations: List[str]
    capabilities: List[SKUCapability]
    restrictions: List[Restriction]

class SKUCapability:
    """Capability of a storage SKU."""
    name: str
    value: str

class Restriction:
    """Restriction on SKU usage."""
    type_: str
    values: List[str]
    reason_code: ReasonCode

class Usage:
    """Storage usage information."""
    unit: UsageUnit
    current_value: int
    limit: int
    name: UsageName

class UsageName:
    """Name of usage metric."""
    value: str
    localized_value: str

class DeletedAccount:
    """Deleted storage account information."""
    id: str
    name: str
    type_: str
    location: str
    properties: DeletedAccountProperties

class DeletedAccountProperties:
    """Properties of deleted account."""
    storage_account_type: str
    creation_time: str
    deletion_time: str
    remaining_retention_days: int

class Operation:
    """Available API operation."""
    name: str
    display: OperationDisplay
    origin: str
    properties: Dict[str, Any]

class OperationDisplay:
    """Display information for operation."""
    provider: str
    resource: str
    operation: str
    description: str

class UsageUnit(str, Enum):
    """Unit for usage metrics."""
    COUNT = "Count"
    BYTES = "Bytes"
    SECONDS = "Seconds"
    PERCENT = "Percent"
    COUNTS_PER_SECOND = "CountsPerSecond"
    BYTES_PER_SECOND = "BytesPerSecond"

class ReasonCode(str, Enum):
    """Reason codes for restrictions."""
    QUOTA_ID = "QuotaId"
    NOT_AVAILABLE_FOR_SUBSCRIPTION = "NotAvailableForSubscription"

Install with Tessl CLI

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

docs

blob-storage.md

file-storage.md

index.md

policy-management.md

queue-storage.md

security-access.md

storage-accounts.md

storage-tasks.md

table-storage.md

utilities.md

tile.json