Microsoft Azure Azure File Share Storage Client Library for Python version 12.24.0. This library provides fully managed file shares in the cloud, accessible via the industry-standard Server Message Block (SMB) protocol. It is part of the extensive Azure SDK for Python, which typically adheres to a continuous release cadence, delivering frequent updates and bug fixes across its various client libraries.
pip install azure-storage-file-shareVerified import paths — ran on the pinned version, not inferred.
This quickstart demonstrates how to initialize a `ShareServiceClient` using a storage account connection string and then list all existing file shares in the account. Ensure the `STORAGE_CONNECTION_STRING` environment variable is set with your Azure Storage account connection string.
Migrate code to use the new v12 client libraries and their specific import paths and API patterns. Refer to the official migration guides for detailed steps.
For operations that do not support OAuth, use an account key or a connection string for authentication. This is explicitly stated in the documentation for certain scenarios like share snapshots. Consider using Azure Key Vault to securely store account keys.
Install `aiohttp` (e.g., `pip install azure-storage-file-share[aio]`) to enable asynchronous operations. Ensure async clients and credentials are properly closed when no longer needed using `await client.close()` or `async with` statements.
Always ensure the parent share and any intermediate directories exist before attempting to create or access files within them. You can use methods like `create_share()` or `create_directory()` on the respective client objects to ensure existence.
Ensure you install the correct, service-specific package for file shares: `pip install azure-storage-file-share`. Then, import clients directly from `azure.storage.fileshare`, for example: `from azure.storage.fileshare import ShareServiceClient`.
Verify the share name, directory path, and file name are correct and exist in your Azure Storage account. Ensure the credentials (account key, SAS token, or Azure AD principal) have the necessary permissions (e.g., read, write, create) for the resource. When uploading a file, first ensure the parent directory exists, and for some operations, you may need to explicitly create the file (e.g., using `create_file()`) before uploading its content.
Double-check your storage account name and access key. If using a SAS token, regenerate it to ensure it's valid, has the correct permissions, and a non-expired expiry time. Synchronize your system's clock with UTC. If using Azure AD or Managed Identity, verify that the assigned RBAC roles (e.g., 'Storage File Data SMB Share Contributor' or 'Storage File Data Reader') are correctly scoped to the storage account or file share.
When creating the `ShareServiceClient` or `ShareClient` with `TokenCredential` (e.g., `DefaultAzureCredential`), you need to pass `token_intent='backup'` as a keyword argument to the client constructor. Example: `ShareServiceClient(account_url=account_url, credential=azure_credential, token_intent='backup')`. Ensure your Azure AD principal has the necessary RBAC permissions for the intended operations.