[{"data":1,"prerenderedAt":-1},["ShallowReactive",2],{"skill-ffe256dd-2ba0-4038-b686-6ff97ab6443a":3,"$fy7bJe1TOiWxNQEkJcXTBngDa6h_nlygq_CLenoJ1SHQ":43},{"id":4,"title":5,"description":6,"categoryId":7,"moduleId":8,"tags":9,"prompt":10,"icon":11,"source":12,"sourceUrl":13,"authorId":14,"authorName":15,"isPublic":16,"stars":17,"runs":18,"createdAt":19,"updatedAt":19,"module":20,"category":27,"packages":34},"ffe256dd-2ba0-4038-b686-6ff97ab6443a","azure-storage-file-share-py","Azure存储文件共享SDK for Python。用于云中的SMB文件共享、目录和文件操作。","cat_coding_devops","mod_coding","sickn33,coding","---\nname: azure-storage-file-share-py\ndescription: Azure Storage File Share SDK for Python. Use for SMB file shares, directories, and file operations in the cloud.\nrisk: unknown\nsource: community\ndate_added: '2026-02-27'\n---\n\n# Azure Storage File Share SDK for Python\n\nManage SMB file shares for cloud-native and lift-and-shift scenarios.\n\n## Installation\n\n```bash\npip install azure-storage-file-share\n```\n\n## Environment Variables\n\n```bash\nAZURE_STORAGE_CONNECTION_STRING=DefaultEndpointsProtocol=https;AccountName=...;AccountKey=...\n# Or\nAZURE_STORAGE_ACCOUNT_URL=https:\u002F\u002F\u003Caccount>.file.core.windows.net\n```\n\n## Authentication\n\n### Connection String\n\n```python\nfrom azure.storage.fileshare import ShareServiceClient\n\nservice = ShareServiceClient.from_connection_string(\n    os.environ[\"AZURE_STORAGE_CONNECTION_STRING\"]\n)\n```\n\n### Entra ID\n\n```python\nfrom azure.storage.fileshare import ShareServiceClient\nfrom azure.identity import DefaultAzureCredential\n\nservice = ShareServiceClient(\n    account_url=os.environ[\"AZURE_STORAGE_ACCOUNT_URL\"],\n    credential=DefaultAzureCredential()\n)\n```\n\n## Share Operations\n\n### Create Share\n\n```python\nshare = service.create_share(\"my-share\")\n```\n\n### List Shares\n\n```python\nfor share in service.list_shares():\n    print(f\"{share.name}: {share.quota} GB\")\n```\n\n### Get Share Client\n\n```python\nshare_client = service.get_share_client(\"my-share\")\n```\n\n### Delete Share\n\n```python\nservice.delete_share(\"my-share\")\n```\n\n## Directory Operations\n\n### Create Directory\n\n```python\nshare_client = service.get_share_client(\"my-share\")\nshare_client.create_directory(\"my-directory\")\n\n# Nested directory\nshare_client.create_directory(\"my-directory\u002Fsub-directory\")\n```\n\n### List Directories and Files\n\n```python\ndirectory_client = share_client.get_directory_client(\"my-directory\")\n\nfor item in directory_client.list_directories_and_files():\n    if item[\"is_directory\"]:\n        print(f\"[DIR] {item['name']}\")\n    else:\n        print(f\"[FILE] {item['name']} ({item['size']} bytes)\")\n```\n\n### Delete Directory\n\n```python\nshare_client.delete_directory(\"my-directory\")\n```\n\n## File Operations\n\n### Upload File\n\n```python\nfile_client = share_client.get_file_client(\"my-directory\u002Ffile.txt\")\n\n# From string\nfile_client.upload_file(\"Hello, World!\")\n\n# From file\nwith open(\"local-file.txt\", \"rb\") as f:\n    file_client.upload_file(f)\n\n# From bytes\nfile_client.upload_file(b\"Binary content\")\n```\n\n### Download File\n\n```python\nfile_client = share_client.get_file_client(\"my-directory\u002Ffile.txt\")\n\n# To bytes\ndata = file_client.download_file().readall()\n\n# To file\nwith open(\"downloaded.txt\", \"wb\") as f:\n    data = file_client.download_file()\n    data.readinto(f)\n\n# Stream chunks\ndownload = file_client.download_file()\nfor chunk in download.chunks():\n    process(chunk)\n```\n\n### Get File Properties\n\n```python\nproperties = file_client.get_file_properties()\nprint(f\"Size: {properties.size}\")\nprint(f\"Content type: {properties.content_settings.content_type}\")\nprint(f\"Last modified: {properties.last_modified}\")\n```\n\n### Delete File\n\n```python\nfile_client.delete_file()\n```\n\n### Copy File\n\n```python\nsource_url = \"https:\u002F\u002Faccount.file.core.windows.net\u002Fshare\u002Fsource.txt\"\ndest_client = share_client.get_file_client(\"destination.txt\")\ndest_client.start_copy_from_url(source_url)\n```\n\n## Range Operations\n\n### Upload Range\n\n```python\n# Upload to specific range\nfile_client.upload_range(data=b\"content\", offset=0, length=7)\n```\n\n### Download Range\n\n```python\n# Download specific range\ndownload = file_client.download_file(offset=0, length=100)\ndata = download.readall()\n```\n\n## Snapshot Operations\n\n### Create Snapshot\n\n```python\nsnapshot = share_client.create_snapshot()\nprint(f\"Snapshot: {snapshot['snapshot']}\")\n```\n\n### Access Snapshot\n\n```python\nsnapshot_client = service.get_share_client(\n    \"my-share\",\n    snapshot=snapshot[\"snapshot\"]\n)\n```\n\n## Async Client\n\n```python\nfrom azure.storage.fileshare.aio import ShareServiceClient\nfrom azure.identity.aio import DefaultAzureCredential\n\nasync def upload_file():\n    credential = DefaultAzureCredential()\n    service = ShareServiceClient(account_url, credential=credential)\n    \n    share = service.get_share_client(\"my-share\")\n    file_client = share.get_file_client(\"test.txt\")\n    \n    await file_client.upload_file(\"Hello!\")\n    \n    await service.close()\n    await credential.close()\n```\n\n## Client Types\n\n| Client | Purpose |\n|--------|---------|\n| `ShareServiceClient` | Account-level operations |\n| `ShareClient` | Share operations |\n| `ShareDirectoryClient` | Directory operations |\n| `ShareFileClient` | File operations |\n\n## Best Practices\n\n1. **Use connection string** for simplest setup\n2. **Use Entra ID** for production with RBAC\n3. **Stream large files** using chunks() to avoid memory issues\n4. **Create snapshots** before major changes\n5. **Set quotas** to prevent unexpected storage costs\n6. **Use ranges** for partial file updates\n7. **Close async clients** explicitly\n\n## When to Use\nThis skill is applicable to execute the workflow or actions described in the overview.\n\n## Limitations\n- Use this skill only when the task clearly matches the scope described above.\n- Do not treat the output as a substitute for environment-specific validation, testing, or expert review.\n- Stop and ask for clarification if required inputs, permissions, safety boundaries, or success criteria are missing.\n","","imported","https:\u002F\u002Fgithub.com\u002Fsickn33\u002Fantigravity-awesome-skills","user_system_seed","SkillOPIC",true,218,665,"2026-05-16 13:07:54",{"id":8,"name":21,"slug":22,"icon":23,"description":24,"sort":25,"createdAt":26},"编程开发","coding","mdi-code-braces","代码生成、调试、审查，提升开发效率",2,"2026-05-16 12:53:40",{"id":7,"name":28,"slug":29,"icon":30,"description":31,"moduleId":8,"sort":32,"skillCount":33,"createdAt":26},"DevOps","devops","mdi-cog-outline","CI\u002FCD、容器化、部署运维",3,162,[35],{"id":36,"skillId":4,"version":37,"fileName":38,"fileSize":39,"filePath":40,"fileHash":41,"manifest":42,"createdAt":19},"bb48531d-5ca0-4f39-a733-ceca71659b33","1.0.0","azure-storage-file-share-py.zip",1976,"uploads\u002Fskills\u002Fffe256dd-2ba0-4038-b686-6ff97ab6443a\u002Fazure-storage-file-share-py.zip","b71d5260d0a16d55a8f9ab510b6991800bdfd09ceaee4a827e2be26b21aa858d","[{\"path\":\"SKILL.md\",\"isDirectory\":false,\"size\":5374}]",{"code":44,"message":45,"data":46},200,"success",{"items":47,"stats":48,"page":51},[],{"averageRating":49,"totalRatings":49,"ratingCounts":50},0,[49,49,49,49,49],{"limit":52,"offset":49,"hasMore":53,"nextOffset":52,"ratedOnly":16},15,false]