728x90
반응형
2024.07.12 - [Development/Cloud] - [Azure] Storage 생성 및 권한 연결
Azure Blob Stroage 에 접근하기 위한 두번째로는 엑세스 키로 접근하는 방법이 있다. 이 방법은 먼저 설명한 방법보다는 간단하다. 스토리지 계정에 들어가보면 보안 + 네트워킹 메뉴에 액세스 키 라는 메뉴가 있다.
화면에 보이는 연결 문자열의 값을 가지고 BlobServiceClient 를 생성할 수 있다.
connection_string = ""
blob_service_client = BlobServiceClient.from_connection_string(connection_string)
container_client = blob_service_client.get_container_client(container="test-2024-07-12")
with open(file=os.path.join('./', 'test.txt'), mode="rb") as data:
blob_client = container_client.upload_blob(name="sample-blob20240724.txt", data=data, overwrite=True)
print(blob_client)
blob_list = container_client.list_blobs()
for blob in blob_list:
print(f"Name: {blob.name}")
BlobServiceClient 의 from_connection_string 에 위 연결 문자열 값을 넣어주고 파일을 업로드 하고 조회를 할수 있다. 기존 방법에서는 Azure 에서 만들고 설정하는 절차가 많았는데 액세스 키를 사용을 하면 간단하게 접근 할 수 있다.
728x90
반응형
'Development > Python' 카테고리의 다른 글
[SSL: CERTIFICATE_VERIFY_FAILED] certificate verify failed: unable to get local issuer certificate (0) | 2024.08.27 |
---|---|
Python 웹 스크래핑 하기 (0) | 2024.08.20 |
python 으로 Azure blob storage 연결 (0) | 2024.07.12 |
poetry 설정 및 패키지 추가 (0) | 2024.07.11 |
파이썬 requests 의 multipart/form-data 활용 (0) | 2024.06.27 |