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

storage-accounts.mddocs/

Storage Account Management

Complete lifecycle management of Azure Storage accounts including creation, deletion, configuration updates, key management, and failover operations. Storage accounts are the fundamental resource containing all Azure Storage data services.

Capabilities

Name Availability Checking

Validates storage account names before creation to ensure they are available and meet naming requirements.

def check_name_availability(
    self,
    account_name: StorageAccountCheckNameAvailabilityParameters
) -> CheckNameAvailabilityResult:
    """
    Checks that the storage account name is valid and is not already in use.
    
    Parameters:
    - account_name: Name validation parameters containing the proposed name
    
    Returns:
    CheckNameAvailabilityResult with availability status and reason if unavailable
    
    Raises:
    HttpResponseError: For service errors
    """

Usage example:

from azure.mgmt.storage.models import StorageAccountCheckNameAvailabilityParameters

check_params = StorageAccountCheckNameAvailabilityParameters(
    name="mystorageaccount123",
    type_="Microsoft.Storage/storageAccounts"
)

result = client.storage_accounts.check_name_availability(check_params)
if result.name_available:
    print("Name is available")
else:
    print(f"Name unavailable: {result.reason} - {result.message}")

Storage Account Creation

Creates new storage accounts with comprehensive configuration options.

def begin_create(
    self,
    resource_group_name: str,
    account_name: str,
    parameters: StorageAccountCreateParameters
) -> LROPoller[StorageAccount]:
    """
    Creates a new storage account with the specified parameters.
    
    Parameters:
    - resource_group_name: Name of the resource group
    - account_name: Name of the storage account (3-24 chars, lowercase letters and numbers)
    - parameters: Storage account creation parameters
    
    Returns:
    LROPoller for tracking the long-running operation, result is StorageAccount
    
    Raises:
    HttpResponseError: For service errors including name conflicts
    """

Usage example:

from azure.mgmt.storage.models import (
    StorageAccountCreateParameters, Sku, Kind, 
    Identity, IdentityType, AccessTier
)

# Create with basic configuration
basic_params = StorageAccountCreateParameters(
    sku=Sku(name="Standard_LRS"),
    kind=Kind.STORAGE_V2,
    location="East US",
    access_tier=AccessTier.HOT
)

poller = client.storage_accounts.begin_create(
    resource_group_name="my-resource-group",
    account_name="mystorageaccount123",
    parameters=basic_params
)

account = poller.result()  # Wait for completion
print(f"Created account: {account.name}")

# Create with advanced configuration
advanced_params = StorageAccountCreateParameters(
    sku=Sku(name="Standard_GRS"),
    kind=Kind.STORAGE_V2,
    location="West US 2",
    access_tier=AccessTier.HOT,
    identity=Identity(type=IdentityType.SYSTEM_ASSIGNED),
    tags={"Environment": "Production", "Owner": "DataTeam"},
    properties=StorageAccountPropertiesCreateParameters(
        allow_blob_public_access=False,
        minimum_tls_version="TLS1_2",
        enable_https_traffic_only=True
    )
)

Storage Account Retrieval and Listing

Get individual storage accounts or list all accounts in subscription or resource group.

def get_properties(
    self,
    resource_group_name: str,
    account_name: str,
    expand: Optional[StorageAccountExpand] = None
) -> StorageAccount:
    """
    Returns the properties for the specified storage account.
    
    Parameters:
    - resource_group_name: Name of the resource group
    - account_name: Name of the storage account
    - expand: May be used to expand nested properties
    
    Returns:
    StorageAccount with full properties
    
    Raises:
    ResourceNotFoundError: If account doesn't exist
    HttpResponseError: For other service errors
    """

def list(self) -> ItemPaged[StorageAccount]:
    """
    Lists all storage accounts in the subscription.
    
    Returns:
    Paginated list of StorageAccount objects
    """

def list_by_resource_group(
    self,
    resource_group_name: str
) -> ItemPaged[StorageAccount]:
    """
    Lists storage accounts in the specified resource group.
    
    Parameters:
    - resource_group_name: Name of the resource group
    
    Returns:
    Paginated list of StorageAccount objects
    """

Usage example:

# Get specific account
account = client.storage_accounts.get_properties(
    resource_group_name="my-resource-group",
    account_name="mystorageaccount123"
)
print(f"Account kind: {account.kind}, SKU: {account.sku.name}")

# List all accounts in subscription
all_accounts = list(client.storage_accounts.list())
print(f"Total accounts: {len(all_accounts)}")

# List accounts in resource group
rg_accounts = list(client.storage_accounts.list_by_resource_group("my-resource-group"))
for account in rg_accounts:
    print(f"Account: {account.name}, Location: {account.location}")

Storage Account Updates

Update existing storage account properties and configuration.

def update(
    self,
    resource_group_name: str,
    account_name: str,
    parameters: StorageAccountUpdateParameters
) -> StorageAccount:
    """
    Updates the specified storage account with the provided parameters.
    
    Parameters:
    - resource_group_name: Name of the resource group
    - account_name: Name of the storage account
    - parameters: Storage account update parameters
    
    Returns:
    Updated StorageAccount
    
    Raises:
    ResourceNotFoundError: If account doesn't exist
    HttpResponseError: For service errors
    """

Usage example:

from azure.mgmt.storage.models import StorageAccountUpdateParameters

update_params = StorageAccountUpdateParameters(
    access_tier=AccessTier.COOL,
    tags={"Environment": "Development"},
    properties=StorageAccountPropertiesUpdateParameters(
        allow_blob_public_access=True,
        minimum_tls_version="TLS1_2"
    )
)

updated_account = client.storage_accounts.update(
    resource_group_name="my-resource-group",
    account_name="mystorageaccount123",
    parameters=update_params
)

Key Management

Manage access keys for storage account authentication.

def list_keys(
    self,
    resource_group_name: str,
    account_name: str,
    expand: Literal["kerb"] = "kerb"
) -> StorageAccountListKeysResult:
    """
    Lists the access keys for the specified storage account.
    
    Parameters:
    - resource_group_name: Name of the resource group
    - account_name: Name of the storage account
    - expand: May be used to expand nested properties
    
    Returns:
    StorageAccountListKeysResult containing access keys
    """

def regenerate_key(
    self,
    resource_group_name: str,
    account_name: str,
    regenerate_key: StorageAccountRegenerateKeyParameters
) -> StorageAccountListKeysResult:
    """
    Regenerates the access keys for the specified storage account.
    
    Parameters:
    - resource_group_name: Name of the resource group
    - account_name: Name of the storage account
    - regenerate_key: Parameters specifying which key to regenerate
    
    Returns:
    StorageAccountListKeysResult with new keys
    """

Usage example:

from azure.mgmt.storage.models import StorageAccountRegenerateKeyParameters

# List current keys
keys_result = client.storage_accounts.list_keys(
    resource_group_name="my-resource-group",
    account_name="mystorageaccount123"
)

for key in keys_result.keys:
    print(f"Key name: {key.key_name}, Permissions: {key.permissions}")

# Regenerate a key
regenerate_params = StorageAccountRegenerateKeyParameters(key_name="key1")
new_keys = client.storage_accounts.regenerate_key(
    resource_group_name="my-resource-group",
    account_name="mystorageaccount123",
    regenerate_key=regenerate_params
)

SAS Token Generation

Generate account-level and service-level Shared Access Signatures.

def list_account_sas(
    self,
    resource_group_name: str,
    account_name: str,
    parameters: AccountSasParameters
) -> ListAccountSasResponse:
    """
    Lists SAS credentials for storage account.
    
    Parameters:
    - resource_group_name: Name of the resource group
    - account_name: Name of the storage account
    - parameters: SAS generation parameters
    
    Returns:
    ListAccountSasResponse containing the SAS token
    """

def list_service_sas(
    self,
    resource_group_name: str,
    account_name: str,
    parameters: ServiceSasParameters
) -> ListServiceSasResponse:
    """
    Lists service SAS credentials for specific resource.
    
    Parameters:
    - resource_group_name: Name of the resource group
    - account_name: Name of the storage account  
    - parameters: Service SAS parameters
    
    Returns:
    ListServiceSasResponse containing the SAS token
    """

Account Deletion

Delete storage accounts with data removal.

def delete(
    self,
    resource_group_name: str,
    account_name: str
) -> None:
    """
    Deletes a storage account. All data in the account is permanently deleted.
    
    Parameters:
    - resource_group_name: Name of the resource group
    - account_name: Name of the storage account
    
    Raises:
    ResourceNotFoundError: If account doesn't exist
    HttpResponseError: For service errors
    """

Usage example:

# Delete storage account (irreversible)
client.storage_accounts.delete(
    resource_group_name="my-resource-group",
    account_name="mystorageaccount123"
)
print("Storage account deleted successfully")

Failover Operations

Initiate failover for geo-redundant storage accounts.

def begin_failover(
    self,
    resource_group_name: str,
    account_name: str,
    failover_type: Literal["Planned"] = "Planned"
) -> LROPoller[None]:
    """
    Initiates failover for a storage account in case of availability issues.
    
    Parameters:
    - resource_group_name: Name of the resource group
    - account_name: Name of the storage account
    - failover_type: Type of failover operation
    
    Returns:
    LROPoller for tracking the long-running failover operation
    """

Hierarchical Namespace Migration

Migrate storage accounts to enable hierarchical namespace (Azure Data Lake Storage Gen2).

def begin_hierarchical_namespace_migration(
    self,
    resource_group_name: str,
    account_name: str,
    request_type: str
) -> LROPoller[None]:
    """
    Live migration of storage account to enable hierarchical namespace.
    
    Parameters:
    - resource_group_name: Name of the resource group
    - account_name: Name of the storage account
    - request_type: Type of migration request
    
    Returns:
    LROPoller for tracking the long-running migration operation
    """
    
def begin_abort_hierarchical_namespace_migration(
    self,
    resource_group_name: str,
    account_name: str
) -> LROPoller[None]:
    """
    Abort live migration of storage account to enable hierarchical namespace.
    
    Parameters:
    - resource_group_name: Name of the resource group
    - account_name: Name of the storage account
    
    Returns:
    LROPoller for tracking the abort operation
    """

Point-in-Time Recovery

Restore blob ranges to a previous point in time.

def begin_restore_blob_ranges(
    self,
    resource_group_name: str,
    account_name: str,
    parameters: BlobRestoreParameters
) -> LROPoller[BlobRestoreStatus]:
    """
    Restore blob ranges for the specified storage account.
    
    Parameters:
    - resource_group_name: Name of the resource group
    - account_name: Name of the storage account
    - parameters: Parameters for blob restore operation
    
    Returns:
    LROPoller for tracking the restore operation status
    """

Customer-Initiated Migration

Manage customer-initiated migration operations.

def begin_customer_initiated_migration(
    self,
    resource_group_name: str,
    account_name: str,
    parameters: StorageAccountMigration
) -> LROPoller[StorageAccount]:
    """
    Account Migration request can be triggered for a storage account.
    
    Parameters:
    - resource_group_name: Name of the resource group
    - account_name: Name of the storage account
    - parameters: Migration parameters
    
    Returns:
    LROPoller for tracking the migration operation
    """
    
def get_customer_initiated_migration(
    self,
    resource_group_name: str,
    account_name: str
) -> StorageAccountMigration:
    """
    Gets the status of the ongoing migration for the specified storage account.
    
    Parameters:
    - resource_group_name: Name of the resource group
    - account_name: Name of the storage account
    
    Returns:
    StorageAccountMigration: Current migration status
    """

User Delegation Key Management

Manage user delegation keys for Azure AD-based authentication.

def revoke_user_delegation_keys(
    self,
    resource_group_name: str,
    account_name: str
) -> None:
    """
    Revoke user delegation keys for the specified storage account.
    
    Parameters:
    - resource_group_name: Name of the resource group
    - account_name: Name of the storage account
    """

Types

class StorageAccountCheckNameAvailabilityParameters:
    """Parameters for checking storage account name availability."""
    name: str
    type_: str  # Always "Microsoft.Storage/storageAccounts"

class CheckNameAvailabilityResult:
    """Result of name availability check."""
    name_available: bool
    reason: str  # "AccountNameInvalid" or "AlreadyExists"
    message: str

class StorageAccountCreateParameters:
    """Parameters for creating a storage account."""
    sku: Sku
    kind: Kind
    location: str
    extended_location: Optional[ExtendedLocation]
    tags: Optional[Dict[str, str]]
    identity: Optional[Identity]
    properties: Optional[StorageAccountPropertiesCreateParameters]

class StorageAccountUpdateParameters:
    """Parameters for updating a storage account."""
    sku: Optional[Sku]
    tags: Optional[Dict[str, str]]
    identity: Optional[Identity]
    properties: Optional[StorageAccountPropertiesUpdateParameters]
    access_tier: Optional[AccessTier]

class StorageAccount:
    """Storage account resource representation."""
    id: str
    name: str
    type_: str
    location: str
    tags: Optional[Dict[str, str]]
    sku: Sku
    kind: Kind
    identity: Optional[Identity]
    properties: StorageAccountProperties

class StorageAccountKey:
    """Storage account access key."""
    key_name: str
    value: str
    permissions: KeyPermission
    creation_time: datetime

class StorageAccountListKeysResult:
    """Result containing storage account keys."""
    keys: List[StorageAccountKey]

class AccountSasParameters:
    """Parameters for generating account SAS token."""
    services: Services
    resource_types: SignedResourceTypes
    permissions: Permissions
    ip_address_or_range: Optional[str]
    protocols: Optional[HttpProtocol]
    shared_access_start_time: Optional[datetime]
    shared_access_expiry_time: datetime
    key_to_sign: Optional[str]

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