AzFS
AzFS is to provide convenient Python read/write functions for Azure Storage Account.
AzFS can
- list files in blob (also with wildcard
*), - check if file exists,
- read csv as pd.DataFrame, and json as dict from blob,
- write pd.DataFrame as csv, and dict as json to blob.
install
$ pip install azfs
usage
For Blob Storage.
import azfs
from azure.identity import DefaultAzureCredential
import pandas as pd
# credential is not required if your environment is on AAD(Azure Active Directory)
azc = azfs.AzFileClient()
# credential is required if your environment is not on AAD
credential = "[your storage account credential]"
# or
credential = DefaultAzureCredential()
azc = azfs.AzFileClient(credential=credential)
# connection_string is also supported
connection_string = "DefaultEndpointsProtocol=https;AccountName=xxxx;AccountKey=xxxx;EndpointSuffix=core.windows.net"
azc = azfs.AzFileClient(connection_string=connection_string)
# data paths
csv_path = "https://testazfs.blob.core.windows.net/test_caontainer/test_file.csv"
# read csv as pd.DataFrame
df = azc.read_csv(csv_path, index_col=0)
# or
with azc:
df = pd.read_csv_az(csv_path, header=None)
# write csv
azc.write_csv(path=csv_path, df=df)
# or
with azc:
df.to_csv_az(path=csv_path, index=False)
# you can read multiple files
csv_pattern_path = "https://testazfs.blob.core.windows.net/test_caontainer/*.csv"
df = azc.read().csv(csv_pattern_path)
# to apply additional filter or another process
df = azc.read().apply(function=lambda x: x[x['id'] == 'AAA']).csv(csv_pattern_path)
# in addition, you can use multiprocessing
df = azc.read(use_mp=True).apply(function=lambda x: x[x['id'] == 'AAA']).csv(csv_pattern_path)
For Queue Storage
import azfs
queue_url = "https://{storage_account}.queue.core.windows.net/{queue_name}"
azc = azfs.AzFileClient()
queue_message = azc.get(queue_url)
# message will not be deleted if `delete=False`
# queue_message = azc.get(queue_url, delete=False)
# get message content
queue_content = queue_message.get('content')
For Table Storage
import azfs
cons = {
"account_name": "{storage_account_name}",
"account_key": "{credential}",
"database_name": "{database_name}"
}
table_client = azfs.TableStorageWrapper(**cons)
# put data, according to the keyword you put
table_client.put(id_="1", message="hello_world")
# get data
table_client.get(id_="1")
types of authorization
Supported authentication types are
- Azure Active Directory (AAD) token credential.
- connection_string, like
DefaultEndpointsProtocol=https;AccountName=xxxx;AccountKey=xxxx;EndpointSuffix=core.windows.net
types of storage account kind
The table below shows if AzFS provides read/write functions for the storage.
| account kind | Blob | Data Lake | Queue | File | Table |
|---|---|---|---|---|---|
| StorageV2 | O | O | O | X | O |
| StorageV1 | O | O | O | X | O |
| BlobStorage | O | - | - | - | - |
- O: provides basic functions
- X: not provides
- -: storage type unavailable
dependencies
pandas
azure-identity >= "1.3.1"
azure-storage-blob >= "12.3.0"
azure-storage-file-datalake >= "12.0.0"
azure-storage-queue >= "12.1.1"
azure-cosmosdb-table
references
Metadata
Release files for azfs 0.2.14
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| azfs-0.2.14.tar.gz | 37.1 kB | Without provenance | Details for azfs-0.2.14.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| azfs-0.2.14-py3-none-any.whl | Python 3 | none | any | Details for azfs-0.2.14-py3-none-any.whl |
Total release size: 78.9 kB
Release files / azfs-0.2.14.tar.gz
| Download URL | azfs-0.2.14.tar.gz |
|---|---|
| Size | 37.1 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
115005d72f2bbec05cfb9cb7b895e8ff71feb11070f861f8290199fb66c6b03a
|
|
BLAKE2b-256 checksum How to use checksums |
88f6ef1d5eb6bc4c111d1f3a8178229d6b61f7c40decb6b53a639cf656fce229
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/3.3.0 pkginfo/1.6.1 requests/2.25.1 setuptools/49.2.1 requests-toolbelt/0.9.1 tqdm/4.56.0 CPython/3.9.1
|
Release files / azfs-0.2.14-py3-none-any.whl
| Download URL | azfs-0.2.14-py3-none-any.whl |
|---|---|
| Size | 41.7 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
fdc9e4239e7455396156e056144a2f1540be84d64079c86b7582f897a3d2a8aa
|
|
BLAKE2b-256 checksum How to use checksums |
50671159bf5464b1256a1f9dfd7649fdc9bf8291510a4914cba80b6968071629
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/3.3.0 pkginfo/1.6.1 requests/2.25.1 setuptools/49.2.1 requests-toolbelt/0.9.1 tqdm/4.56.0 CPython/3.9.1
|
Security for azfs 0.2.14
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.