Azure CLI통해 Blob 다운로드, 업로드 하는 방법을 알아보자
공식문서에도 관련내용이 있지만, 직접 사용자 login 을 통해 인증받는 방식만 소개하고 있다.
빠른 시작 - Azure CLI를 사용하여 Blob 만들기 - Azure Storage
이 빠른 시작에서는 Azure CLI를 사용하여 Azure Storage에 BLOB을 업로드하고, BLOB을 다운로드하고, 컨테이너의 BLOB을 나열하는 방법을 알아봅니다.
docs.microsoft.com
Storage Account Key값 확인하기
자동화를 위해서는 key를 통한 인증이 필요하다.
azure portal 에서 storage account 의 key를 를 확인할수 있는데, 아래는 해당 key를 확인하는 방법이다
- Azure Portal 접속
- 원하는 Storage Account 클릭
- 왼쪽 탭 Setting / Access keys 클릭
- key1, key2 값 복사 (둘 중 어느것을 사용해도 상관없다)
- Key 값 또는 Connection string 복사 (역시 둘 중 어느것을 사용해도 상관없다)
Key 값 사용해서 다운로드/업로드하기
account-name, container-name, 에 알맞은 값을 입력하고, account-key 에 해당값을 입력하면 된다.
# 다운로드
az storage blob download \
--account-name <storage-account> \
--container-name <container> \
--name <blob-name> \
--file <local-file-name> \
--account-key <account-key>
# 업로드
az storage blob upload \
--account-name <storage-account> \
--container-name <container> \
--name <blob-name> \
--file <local-file-name> \
--account-key <account-key>
Connection string 값 사용해서 다운로드/업로드하기
아래는 Connection string을 사용해서 blob을 다운로드, 업로드 하는 방법이다.
container-name, 에 알맞은 값을 입력하고, connection-string 에 해당값을 입력하면 된다.
Key값을 사용하는것과의 차이점은 account-name 입력이 필요없다는 것이다.
Connection string의 내용을 잘 보면 account-name이 포함되어 있다. 따라서 별도 입력이 불필요하다.
# 다운로드
az storage blob download \
--container-name <container> \
--name <blob-name> \
--file <local-file-name> \
--connection-string <connection-string>
# 업로드
az storage blob upload \
--container-name <container> \
--name <blob-name> \
--file <local-file-name> \
--connection-string <connection-string>
여러개 파일 다운로드
아래는 여러개의 파일을 가져오는 방법이다. 같은 폴더에 있는 파일같이..
명령어가 downlod -> download-batch로 바뀐다.
파라미터가 바뀐듯 하지만, 사실 이름만 다를뿐 내용은 위의 것과 비슷하다.
az storage blob download-batch \
--connection-string <connection-string> \
--destination <destination-folder> \
--source <container-name> \
--pattern <blob file pattern>
* 참고: azure storage blob download 관련 cli
az storage blob
--> az storage blob Manage object storage for unstructured data (blobs). Please specify one of the following authentication parameters for your commands: --auth-mode, --account-key, --connection-string, --sas-token. You also can use corresponding environme
docs.microsoft.com
'IT > Public Cloud' 카테고리의 다른 글
AWS RDS, Aurora 와 MySQL Workbench 연결하기 (0) | 2021.12.09 |
---|---|
AWS CodeDeploy 사용법 (feat. EC2 배포, 실패 log 확인, 요금) (0) | 2021.12.07 |
AWS Organizations, IAM 비교 (0) | 2021.09.08 |
AWS 스토리지 관련 서비스 비교 (DataSync, Storage Gateway, Backup, Transfer Family, DMS) (0) | 2021.09.07 |
AWS Global, Regional, AZ 서비스 레벨 살펴보기 (0) | 2021.07.13 |