0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 1 year has passed since last update.

Azure Storage の Blob コンテナーに外部 URL から直接ファイルをダウンロードしてみた

Posted at

Azure Storage の Blob コンテナーにファイルを格納する場合、大抵どこかしらの環境からファイルをアップロードすると思います。例えば、郵便番号の CSV をローカルにダウンロードしてから Blob コンテナーにアップロードする場合を想定します。これが、ローカルにダンロードせずとも、ダウンロード URL から直接 Blob コンテナーに格納できたら、より早く(速く)より簡単だと思います。そこで Azure CLI でどうやってやるのか試してみました。

検証用の Blob コンテナーを作成

bash
prefix=mnrblob
region=japaneast

az group create \
  --name ${prefix}-rg \
  --location $region

az storage account create \
  --name ${prefix} \
  --resource-group ${prefix}-rg \
  --https-only true \
  --sku Standard_LRS

az storage container create \
  --account-name ${prefix} \
  --name test

ローカルにあるファイルをアップロードする例

bash
LANG=C date > date.txt

az storage blob upload \
  --account-name ${prefix} \
  --container-name test \
  --file date.txt \
  --name date.txt

郵便番号 CSV の URL を確認

blob-copy-from-url-01.png

ダウンロード URL から直接 Blob コンテナーに格納する例

bash
az storage blob copy start \
  --account-name ${prefix} \
  --destination-blob ken_all.zip \
  --destination-container test \
  --source-uri https://www.post.japanpost.jp/zipcode/dl/oogaki/zip/ken_all.zip

Blob コンテナーを確認

blob-copy-from-url-02.png

後片付け

bash
rm date.txt

az group delete \
  --name ${prefix}-rg \
  --yes

参考

0
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?