azure-storage-file-share-py – skill DevOps & Hạ tầng cho agent AI
SDK Azure Storage File Share cho Python. Dùng cho thư mục chia sẻ SMB, thư mục con và thao tác tệp trên cloud.
Cài skill azure-storage-file-share-py bằng một lệnh
Chọn công cụ bạn đang dùng, copy lệnh và dán vào terminal. Skill sẽ nằm trong thư mục skills của công cụ đó và sẵn sàng dùng ở phiên làm việc tiếp theo.
Claude Code
mkdir -p ~/.claude/skills && curl -fsSL https://skill.dn1nguoi.com/z/azure-storage-file-share-py-8dd2b.tgz | tar xz -C ~/.claude/skills
Gọi trong Claude Code: /azure-storage-file-share-py – rồi mô tả công việc bạn muốn làm.
Codex
mkdir -p ~/.codex/skills && curl -fsSL https://skill.dn1nguoi.com/z/azure-storage-file-share-py-8dd2b.tgz | tar xz -C ~/.codex/skills
Gọi trong Codex: $azure-storage-file-share-py – rồi mô tả công việc bạn muốn làm.
Hermes Agent
mkdir -p ~/.hermes/skills && curl -fsSL https://skill.dn1nguoi.com/z/azure-storage-file-share-py-8dd2b.tgz | tar xz -C ~/.hermes/skills
Gọi trong Hermes Agent: /azure-storage-file-share-py – rồi mô tả công việc bạn muốn làm.
DeepSeek
mkdir -p ~/.deepcode/skills && curl -fsSL https://skill.dn1nguoi.com/z/azure-storage-file-share-py-8dd2b.tgz | tar xz -C ~/.deepcode/skills
Gọi trong DeepSeek: /azure-storage-file-share-py – rồi mô tả công việc bạn muốn làm.
Nội dung SKILL.md
Nội dung SKILL.md gốc bằng tiếng Anh.
Azure Storage File Share SDK for Python
Manage SMB file shares for cloud-native and lift-and-shift scenarios.
Installation
pip install azure-storage-file-shareEnvironment Variables
AZURE_STORAGE_CONNECTION_STRING=DefaultEndpointsProtocol=https;AccountName=...;AccountKey=...
# Or
AZURE_STORAGE_ACCOUNT_URL=https://<account>.file.core.windows.netAuthentication
Connection String
import os
from azure.storage.fileshare import ShareServiceClient
service = ShareServiceClient.from_connection_string(
os.environ["AZURE_STORAGE_CONNECTION_STRING"]
)Entra ID
from azure.storage.fileshare import ShareServiceClient
from azure.identity import DefaultAzureCredential
service = ShareServiceClient(
account_url=os.environ["AZURE_STORAGE_ACCOUNT_URL"],
credential=DefaultAzureCredential(),
token_intent="backup",
)For OAuth, review [token_intent and backup permissions](https://learn.microsoft.com/en-us/python/api/azure-storage-file-share/azure.storage.fileshare.shareserviceclient?view=azure-python); backup intent can bypass file/directory ACL checks and needs an explicitly authorized role. Examples are independent fragments requiring account_url, os and compatible packages. Writes/uploads can replace content; confirm exact share/path, protect existing files, limit download bytes and delete only disposable resources. Never print connection strings or SAS URLs. Copy start is asynchronous: poll destination copy status before reporting success. Use try/finally or async context managers to close clients/credentials on failure.
Share Operations
Create Share
share = service.create_share("my-share")List Shares
for share in service.list_shares():
print(f"{share.name}: {share.quota} GB")Get Share Client
share_client = service.get_share_client("my-share")Delete Share
service.delete_share("my-share")Directory Operations
Create Directory
share_client = service.get_share_client("my-share")
share_client.create_directory("my-directory")
# Nested directory
share_client.create_directory("my-directory/sub-directory")List Directories and Files
directory_client = share_client.get_directory_client("my-directory")
for item in directory_client.list_directories_and_files():
if item["is_directory"]:
print(f"[DIR] {item['name']}")
else:
print(f"[FILE] {item['name']} ({item['size']} bytes)")Delete Directory
share_client.delete_directory("my-directory")File Operations
Upload File
file_client = share_client.get_file_client("my-directory/file.txt")
# From string
file_client.upload_file("Hello, World!")
# From file
with open("local-file.txt", "rb") as f:
file_client.upload_file(f)
# From bytes
file_client.upload_file(b"Binary content")Download File
file_client = share_client.get_file_client("my-directory/file.txt")
# To bytes
data = file_client.download_file().readall()
# To file
with open("downloaded.txt", "wb") as f:
data = file_client.download_file()
data.readinto(f)
# Stream chunks
download = file_client.download_file()
for chunk in download.chunks():
process(chunk)Get File Properties
properties = file_client.get_file_properties()
print(f"Size: {properties.size}")
print(f"Content type: {properties.content_settings.content_type}")
print(f"Last modified: {properties.last_modified}")Delete File
file_client.delete_file()Copy File
source_url = "https://account.file.core.windows.net/share/source.txt"
dest_client = share_client.get_file_client("destination.txt")
dest_client.start_copy_from_url(source_url)Range Operations
Upload Range
# Upload to specific range
file_client.upload_range(data=b"content", offset=0, length=7)Download Range
# Download specific range
download = file_client.download_file(offset=0, length=100)
data = download.readall()Snapshot Operations
Create Snapshot
snapshot = share_client.create_snapshot()
print(f"Snapshot: {snapshot['snapshot']}")Access Snapshot
snapshot_client = service.get_share_client(
"my-share",
snapshot=snapshot["snapshot"]
)Async Client
from azure.storage.fileshare.aio import ShareServiceClient
from azure.identity.aio import DefaultAzureCredential
async def upload_file():
credential = DefaultAzureCredential()
service = ShareServiceClient(account_url, credential=credential, token_intent="backup")
share = service.get_share_client("my-share")
file_client = share.get_file_client("test.txt")
await file_client.upload_file("Hello!")
await service.close()
await credential.close()Client Types
| Client | Purpose |
|--------|---------|
| ShareServiceClient | Account-level operations |
| ShareClient | Share operations |
| ShareDirectoryClient | Directory operations |
| ShareFileClient | File operations |
Best Practices
1. Prefer scoped identity where supported; connection strings contain account credentials
2. Use Entra ID for production with RBAC
3. Stream large files using chunks() to avoid memory issues
4. Create snapshots before major changes
5. Set quotas to prevent unexpected storage costs
6. Use ranges for partial file updates
7. Close async clients explicitly
When to Use
This skill is applicable to execute the workflow or actions described in the overview.
Limitations
- Use this skill only when the task clearly matches the scope described above.
- Do not treat the output as a substitute for environment-specific validation, testing, or expert review.
- Stop and ask for clarification if required inputs, permissions, safety boundaries, or success criteria are missing.
Skill liên quan
- azure-storage-file-share-ts – SDK Azure File Share cho JavaScript/TypeScript (@azure/storage-file-share) để thao tác…
- azure-storage-queue-py – SDK Azure Queue Storage cho Python. Dùng cho hàng đợi tin nhắn đáng tin cậy, phân phối…
- azure-storage-queue-ts – SDK Azure Queue Storage cho JavaScript/TypeScript (@azure/storage-queue) cho thao tác…
- azure-vms – Quản lý máy ảo Azure và scale set. Cấu hình availability set và managed disk. Dùng khi…
- azure-web-pubsub-ts – Nhắn tin thời gian thực với kết nối WebSocket và mẫu pub/sub.
- backup-recovery – Triển khai chiến lược sao lưu và khôi phục. Cấu hình rsync, Restic và sao lưu lên cloud…
- bash-linux – Các mẫu terminal Bash/Linux. Lệnh quan trọng, piping, xử lý lỗi, viết script. Dùng khi…
- bash-pro – Chuyên gia viết Bash script phòng thủ cho tự động hóa production, pipeline CI/CD và các…