Skip to main content

azure-storage-helper

Azure의 storage 서비스를 사용하기 위한 Python SDK를 좀 더 쉽게 사용할 수 있도록 도와줍니다.
현재 지원하고 있는 SDK는 다음 2개 라이브러리이며, Blob container만 지원하고 있습니다.

  • Blob Storage (azure-storage-blob)
  • Datalake Storage Gen2 (azure-storage-file-datalake)

목차

Getting started

Installation

azure-storage-helper는 pip 명령어를 통해 PyPI으로부터 설치할 수 있습니다.

pip install azure-storage-helper

Package overview

본 패키지에서는 4개의 Client를 제공합니다.

StorageClient > ContainerClient > DirectoryClient(gen2만 해당) > BlobClient

helper에서는 BlobClient를 이용하여 파일 업로드/다운로드 등 자주 수행하는 작업을 함수로 제공합니다.

User Guide

본 가이드는 gen2를 기준으로 작성되었습니다.
gen1은 DirectoryClient가 없으며, 일부 기능에 제한이 있을 수 있습니다.

StorageClient

Azure Storage Account에 대한 클라이언트입니다.
다음 두 개의 인자를 이용해 생성할 수 있습니다.

  • account_name : Storage Account의 이름
  • account_key : Storage Account에 접근하기 위한 key

Example

from azure.gen2 import StorageClient

account_name = "account_name"
account_key = "account_key"

storage = StorageClient(account_name=account_name, account_key=account_key)

Property

  • client
    • Original SDK의 client(azure.storage.filedatalake.DataLakeServiceClient)를 반환합니다. 본 패키지에서 제공하지 않는 기능이 필요한 경우 사용할 수 있습니다.
    • gen1에서는 azure.storage.blob.BlobServiceClient

Method

  • containers(name_starts_with: str = None) -> list[ContainerClient]
    • 현재 스토리지 계정에 존재하는 컨테이너 리스트를 반환합니다.
  • get_container(name: str) -> ContainerClient
    • 특정 이름의 컨테이너를 반환합니다.
  • get_directory(path: str) -> DirectoryClient
    • 특정 경로의 디렉토리를 반환합니다.
    • 경로는 <container>/<directory-path>로 나타냅니다.
    • gen1에서는 제공하지 않습니다.
  • get_blob(path: str) -> BlobClient
    • 특정 경로의 블랍을 반환합니다.
    • 경로는 <container>/<directory-path>/<blob-name>으로 나타냅니다.

ContainerClient

Container에 대한 클라이언트입니다.
다음 두 개의 인자를 이용해 생성할 수 있습니다.

  • name : 컨테이너 이름
  • storage : StorageClient

Example

from azure.gen2 import ContainerClient

container = ContainerClient("raw", storage)

if not container.exists():
    container.create()

Property

  • name
    • 컨테이너 이름
  • client
    • Original SDK의 client(azure.storage.filedatalake.FileSystemClient)를 반환합니다. 본 패키지에서 제공하지 않는 기능이 필요한 경우 사용할 수 있습니다.
    • gen1에서는 azure.storage.blob.ContainerClient

Method

  • exists() -> bool
    • 컨테이너의 존재 유무를 반환합니다.
  • create(exist_ok=False, **kwargs) -> None
    • 컨테이너를 생성합니다.
    • exist_ok가 True이면 컨테이너가 이미 존재할 시 에러가 발생하지 않습니다.
  • delete(**kwargs) -> None
    • 컨테이너를 삭제합니다.
  • glob(path: str = None, name_starts_with: str = None, recursive: bool = True) -> list[BlobClient]
    • 현재 컨테이너에 존재하는 조건에 부합하는 모든 blob을 반환합니다.
    • path는 현재 컨테이너로부터 검색하려는 디렉토리의 상대 경로입니다.
    • name_starts_with는 blob 이름의 접두사입니다.
    • recursive는 재귀적으로 하위 디렉토리에 대한 검색 여부를 나타냅니다.
    • gen1에서는 recursive 옵션 기능을 제공하지 않습니다.
  • get_directory(path: str) -> DirectoryClient
    • 현재 컨테이너로부터 특정 경로에 있는 DirectoryClient를 반환합니다.
    • 경로는 컨테이너 이름을 제외한 현재 컨테이너로부터 디렉토리의 상대 경로입니다.
    • gen1에서는 제공하지 않습니다.
  • get_blob(path: str) -> BlobClient
    • 현재 컨테이너로부터 특정 경로의 BlobClient를 반환합니다.
    • 경로는 컨테이너 이름을 제외한 현재 컨테이너로부터 blob의 상대 경로입니다.

DirectoryClient

Directory에 대한 클라이언트입니다.
다음 두 개의 인자를 이용해 생성할 수 있습니다.
※ gen1에서는 제공하지 않습니다.

  • path : 컨테이너를 포함하는 디렉토리의 절대 경로
  • storage : StorageClient

Example

from azure.gen2 import DirectoryClient

directory = DirectoryClient("raw/folder/subfolder", storage)

if not directory.exists():
    directory.create()

Property

  • name
    • 디렉토리 이름
  • path
    • 컨테이너를 포함하는 디렉토리의 절대 경로
  • client
    • Original SDK의 client(azure.storage.filedatalake.DataLakeDirectoryClient)를 반환합니다. 본 패키지에서 제공하지 않는 기능이 필요한 경우 사용할 수 있습니다.
  • container
    • 현재 디렉토리의 상위 컨테이너에 대한 ContainerClient
  • parent
    • 현재 디렉토리의 상위 클라이언트
    • DirectoryClient 또는 ContainerClient

Method

  • exists() -> bool
    • 디렉토리의 존재 유무를 반환합니다.
  • create(exist_ok=False, **kwargs) -> None
    • 디렉토리를 생성합니다.
    • exist_ok가 True이면 디렉토리가 이미 존재할 시 에러가 발생하지 않습니다.
  • delete(**kwargs) -> None
    • 디렉토리를 삭제합니다.
  • glob(name_starts_with: str = None, recursive: bool = True) -> list[BlobClient]
    • 현재 디렉토리에 존재하는 조건에 부합하는 모든 blob을 반환합니다.
    • name_starts_with는 blob 이름의 접두사입니다.
    • recursive는 재귀적으로 하위 디렉토리에 대한 검색 여부를 나타냅니다.
  • get_directory(path: str) -> DirectoryClient
    • 현재 디렉토리로부터 특정 경로에 있는 DirectoryClient를 반환합니다.
    • 경로는 현재 디렉토리로부터 해당 디렉토리의 상대 경로입니다.
  • get_blob(path: str) -> BlobClient
    • 현재 디렉토리로부터 특정 경로의 BlobClient를 반환합니다.
    • 경로는 현재 디렉토리로부터 blob의 상대 경로입니다.

BlobClient

Blob에 대한 클라이언트입니다.
다음 두 개의 인자를 이용해 생성할 수 있습니다.

  • path : 컨테이너를 포함하는 디렉토리의 절대 경로
  • storage : StorageClient

Example

from azure.gen2 import BlobClient

blob = BlobClient("raw/folder/blob.txt", storage)

if not blob.exists():
    blob.create()

Property

  • name
    • Blob 이름
  • path
    • 컨테이너를 포함하는 Blob의 절대 경로
  • client
    • Original SDK의 client(azure.storage.filedatalake.DataLakeFileClient)를 반환합니다. 본 패키지에서 제공하지 않는 기능이 필요한 경우 사용할 수 있습니다.
    • gen1에서는 azure.storage.blob.BLobClient
  • container
    • 현재 Blob의 상위 컨테이너에 대한 ContainerClient
  • parent
    • 현재 Blob의 상위 클라이언트
    • DirectoryClient 또는 ContainerClient
    • gen1에서는 제공하지 않습니다.

Method

  • exists() -> bool
    • Blob의 존재 유무를 반환합니다.
  • create(exist_ok=False, **kwargs) -> None
    • Blob를 생성합니다.
    • exist_ok가 True이면 Blob이 이미 존재할 시 에러가 발생하지 않습니다.
    • gen1에서는 제공하지 않습니다.
  • delete(**kwargs) -> None
    • Blob을 삭제합니다.
  • upload(bytes: BytesIO, overwrite: bool = True) -> None
    • 현재 blob에 바이트 스트림의 내용을 작성합니다.
  • download() -> BytesIO
    • 현재 blob의 내용을 바이트 스트림으로 받아옵니다.

helper

  • load_yaml(blob: BlobClient) -> dict
  • load_csv(blob: BlobClient, **kwargs) -> DataFrame
  • load_jobib(blob: BlobClient) -> Any
  • upload_to_csv(blob: BlobClient, data: DataFrame, encode: str = "utf-8", **kwargs)
  • upload_to_parquet(blob: BlobClient, data: DataFrame, **kwargs)
  • upload_file(blob: BlobClient, local_path: str, overwrite: bool = True)
  • download_file(blob: BlobClient, local_path: str, file_name: str = None) -> str

Metadata

Release files for azure-storage-helper 0.3.3

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for azure-storage-helper 0.3.3
File Size Uploaded Provenance
azure_storage_helper-0.3.3.tar.gz 82.0 kB Without provenance Details

Built distribution (wheel)

Table of built distributions (wheels) for azure-storage-helper 0.3.3
File Interpreter ABI Platform
azure_storage_helper-0.3.3-py3-none-any.whl Python 3 none any Details

Total release size: 94.2 kB

Release files / azure_storage_helper-0.3.3.tar.gz

Download URL azure_storage_helper-0.3.3.tar.gz
Size 82.0 kB
Tags Source
SHA-256 checksum
How to use checksums
8a94a1ce615ba1edea1eff0fb1e8dc4ccb4cf8d153b46d3f646c583babd8fb8d
BLAKE2b-256 checksum
How to use checksums
5e61fef5aedf25a9514d29f9d784b7a80a6fedeb9d83cbf3222b3d6cd74985d1
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via uv/0.5.18

Release files / azure_storage_helper-0.3.3-py3-none-any.whl

Download URL azure_storage_helper-0.3.3-py3-none-any.whl
Size 12.2 kB
Tags Python 3
SHA-256 checksum
How to use checksums
b2c557eb26cec6d71bdc17b5222d91bef465b787d95d4d133a5d232419ab2fed
BLAKE2b-256 checksum
How to use checksums
95751c18f7559c5d1df7cfecd4c1b1165ab89e4329b571545e65ba86c3ed8367
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via uv/0.5.18

Security for azure-storage-helper 0.3.3

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.

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page