Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

This article is a Private article. Only a writer and users who know the URL can access it.
Please change open range to public in publish setting if you want to share this article with other users.

Azure Storage を作って Azure CLI でファイルをアップロードする

0
Posted at

はじめに

Azure 無料アカウントを使って Azure Storage を作成し、ローカル PC から Azure CLI でファイルをアップロードする備忘録です。

改訂履歴

  • 2026/09/05 : 初版公開。

本文

1. Azure Storage の作成

ストレージアカウントの作成画面から、Azure subscription 1 の rg-azure-test に storagetest20260905 というストレージアカウント名で作ります(ストレージアカウント名は Azure 全体で一意である必要があるようです)。

補足
画面にも表示されていますが、Azure Blob Storage の無料サービス特典を受けるには、パフォーマンスは「Starndard」、冗長性は「ローカル冗長ストレージ (LRS)」を選択する必要があるそうです。

完了後「リソースに移動」ボタンをクリックします。

左メニューのコンテナーを選択します。

コンテナーを追加します。

test-container で作成します。

無事作成できました。

2. ロールの割り当ての追加

次に Azure CLI から Azure Storage にファイルをアップロードできるように、自分のアカウントにロールを割り当てます。左側のメニューから「アクセス制御 (IAM)」を選択し、「ロールの割り当ての追加」をクリックします。

ロールの検索欄に「ストレージ BLOB データ共同作成者」と入力し、該当するロールを選択します。

選択したロールが正しいことを確認したら、メンバーとして自分自身を追加します。その後「レビューと割り当て」をクリックしてロールを保存します。

3. Azure CLI でアップロードする

ここからは、ローカル PC から Azure CLI を使ってファイルをアップロードします。以下のコマンドを実行すると、サインイン画面が表示されます。

PowerShell
az login

サインイン後 Select a subscription and tenant (Type a number or Enter for no changes): が表示されたら、Enter キーを押すことで、既定のサブスクリプションでログインできます。

以下のコマンドを実行すると C:\Temp\test.txt を、storagetest20260905 の test-container にアップロードします。

PowerShell
az storage blob upload `
  --account-name storagetest20260905 `
  --container-name test-container `
  --file C:\Temp\test.txt `
  --name test.txt `
  --auth-mode login

以下のような表示になったら、成功です。

ちゃんとアップロードされています。

おわりに

今回は手でポチポチして作りましたが、実際には Terraform や Bicep を使うと思います。

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

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?