개요
Azure Blob Storage는 Microsoft Azure의 오브젝트 스토리지 서비스. AWS S3에 대응하는 Azure의 비정형 데이터 저장소.
- 공식 문서: https://learn.microsoft.com/azure/storage/blobs/
- S3 호환: Azure 자체 API + S3 호환 API (2023년 GA)
- FUSE 마운트: blobfuse (blobfuse2)
Blob 유형
| 유형 | 용도 |
|---|---|
| Block Blob | 일반 파일, 미디어, 백업 (가장 많이 사용) |
| Append Blob | 로그 파일 (추가만 가능) |
| Page Blob | VM 디스크 (VHD), 랜덤 읽기/쓰기 |
액세스 계층
| 계층 | 특징 | 비용 |
|---|---|---|
| Hot | 자주 접근하는 데이터 | 저장 비용 높음, 액세스 비용 낮음 |
| Cool | 가끔 접근 (30일+ 보관) | 저장 비용 중간 |
| Cold | 드물게 접근 (90일+ 보관) | 저장 비용 낮음 |
| Archive | 거의 접근 안 함 (180일+ 보관) | 저장 비용 최저, 읽기 시간 수 시간 |
blobfuse2 (FUSE 마운트)
Azure Blob Storage를 로컬 파일시스템처럼 마운트하는 도구.
# baseConfig.yaml 예시
allow-other: true
logging:
level: log_warning
components:
- libfuse
- file_cache
- attr_cache
- azstorage
azstorage:
type: block
account-name: mystorageaccount
account-key: <account-key>
endpoint: https://mystorageaccount.blob.core.windows.net
container: mycontainer# 마운트
blobfuse2 mount /mnt/blob --config-file=config.yaml
# 마운트 해제
blobfuse2 unmount /mnt/blobPython SDK
from azure.storage.blob import BlobServiceClient
conn_str = "DefaultEndpointsProtocol=https;AccountName=...;AccountKey=...;"
client = BlobServiceClient.from_connection_string(conn_str)
# 업로드
blob_client = client.get_blob_client(container="mycontainer", blob="file.txt")
with open("local.txt", "rb") as f:
blob_client.upload_blob(f, overwrite=True)
# 다운로드
with open("download.txt", "wb") as f:
f.write(blob_client.download_blob().readall())