Skill

Manage Azure File Shares with Python SDK

Python skill for Azure Storage File Share (SMB) - shares, directories, files, ranges, and snapshots for lift-and-shift.

Works with azure

91
Spark score
out of 100
Updated 24 days ago
Version 13.12.0

Add to Favorites

Why it matters

Automate the management of Azure Storage File Shares using Python. This skill enables programmatic control over file shares, directories, and files for cloud-native and lift-and-shift applications.

Outcomes

What it gets done

01

Create, list, and delete Azure file shares.

02

Manage directories and subdirectories within shares.

03

Upload, download, and manage files, including range operations.

04

Utilize connection strings or Entra ID for authentication.

Install

Add it to your toolbox

Run in your project directory:

curl -fsSL https://spark.entire.vc/get/ag-azure-storage-file-share-py | bash

Overview

Azure Storage File Share SDK for Python

Python skill for Azure Storage File Share, covering SMB share/directory/file management, partial byte-range upload and download, chunked streaming for large files, point-in-time snapshots, and Entra ID or connection-string authentication. Use when an application needs SMB-compatible file share storage on Azure - lift-and-shift migration or shared file directories - rather than flat blob storage.

What it does

This skill manages SMB file shares for cloud-native and lift-and-shift scenarios using azure-storage-file-share (Python), authenticated via connection string (ShareServiceClient.from_connection_string) or Entra ID (DefaultAzureCredential). Its client hierarchy is ShareServiceClient (account-level) → ShareClient (a specific share) → ShareDirectoryClient/ShareFileClient (directory and file operations). Share operations cover creating a share, listing shares with their quota (in GB), fetching a share client by name, and deleting a share. Directory operations cover creating a directory (including a nested path like my-directory/sub-directory in one call), listing a directory's contents (distinguishing files from subdirectories, with file sizes), and deleting a directory. File operations cover uploading from a string, an open file object, or raw bytes; downloading to bytes, streaming into a local file via readinto, or iterating chunks() to process a large download without loading it all into memory; reading file properties (size, content type, last modified); deleting a file; and copying a file directly from a source URL via start_copy_from_url. Range operations allow partial file updates - upload_range writes to a specific byte offset and length, and download_file(offset, length) reads back a specific range, both useful for large files that shouldn't be rewritten wholesale. Snapshot operations create a point-in-time, read-only snapshot of a share and access it later by passing the snapshot identifier back into get_share_client. An async client (azure.storage.fileshare.aio) mirrors the sync API, requiring explicit close() calls on both the service client and credential. Best practices: use a connection string for the simplest setup, prefer Entra ID with RBAC in production, stream large files with chunks() to avoid memory issues, create snapshots before major changes, set share quotas to prevent unexpected storage costs, use range operations for partial file updates, and explicitly close async clients.

When to use - and when NOT to

Use this skill when an application needs SMB-compatible file share storage on Azure - lift-and-shift migration of on-premises file-share workloads, shared configuration/data directories accessible to multiple VMs, or applications needing traditional file semantics (directories, partial-range writes, point-in-time snapshots) rather than flat object storage. It is not for simple key-value blob storage (Azure Blob Storage is the simpler and typically cheaper fit for that) or for big-data hierarchical-namespace analytics workloads (Azure Data Lake Storage Gen2 fits that instead).

Inputs and outputs

Input is share/directory/file names and paths, file content (string, bytes, file object, or a specific byte range), and optional snapshot identifiers. Output is created/listed shares and directory contents, downloaded file content (full, streamed, or ranged), file properties, and point-in-time share snapshots.

Integrations

Built on Azure Storage File Share via azure-storage-file-share, authenticated via connection string or Azure Identity's DefaultAzureCredential.

pip install azure-storage-file-share

Who it's for

Python developers managing SMB-compatible file share storage on Azure - lift-and-shift migrations, shared file directories, or applications needing traditional file semantics like partial-range writes and point-in-time snapshots.

FAQ

Common questions

Discussion

Questions & comments · 0

Sign In Sign in to leave a comment.