facebook twitter hatena line email

「Azure/CLI」の版間の差分

提供: 初心者エンジニアの簡易メモ
移動: 案内検索
(コンテナupload(dir))
行12: 行12:
 
You have logged in. Now let us find all the subscriptions to which you have access...
 
You have logged in. Now let us find all the subscriptions to which you have access...
 
The following tenants don't contain accessible subscriptions. Use 'az login --allow-no-subscriptions' to have tenant level access.
 
The following tenants don't contain accessible subscriptions. Use 'az login --allow-no-subscriptions' to have tenant level access.
61e87b26-c760-xxxx-xxxx-xxxxxxxxxxxxx '既定のディレクトリ'
+
xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxxx '既定のディレクトリ'
f18370bf-eaa5-xxxx-xxxx-xxxxxxxxxxxxx '株式会社aaa'
+
xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxxx 'hogeuser'
 
[
 
[
 
   {
 
   {
 
     "cloudName": "AzureCloud",
 
     "cloudName": "AzureCloud",
     "homeTenantId": "850d80c1-xxxx-xxxx-xxxx-xxxxxxxxxxxx",
+
     "homeTenantId": "xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx",
     "id": "63f0dcef-7f0f-4e3a-b911-xxxxxxxxxxxxx",
+
     "id": "xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxxx",
 
     "isDefault": true,
 
     "isDefault": true,
 
     "managedByTenants": [],
 
     "managedByTenants": [],
 
     "name": "dv_xxx_cloudconfig-virtual-event-service_azureplan",
 
     "name": "dv_xxx_cloudconfig-virtual-event-service_azureplan",
 
     "state": "Enabled",
 
     "state": "Enabled",
     "tenantId": "850d80c1-e9bd-4f94-a740-xxxxxxxxxxxx",
+
     "tenantId": "xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx",
 
     "user": {
 
     "user": {
 
       "name": "hogehoge@example.com",
 
       "name": "hogehoge@example.com",

2021年8月20日 (金) 18:57時点における版

インストール

macの場合

brew update && brew install azure-cli

公式:https://docs.microsoft.com/ja-jp/cli/azure/install-azure-cli

login

az login

ブラウザに飛び、ログインが成功すると、以下メッセージが帰ってくる

The default web browser has been opened at https://login.microsoftonline.com/common/oauth2/authorize. Please continue the login in the web browser. If no web browser is available or if the web browser fails to open, use device code flow with `az login --use-device-code`.
You have logged in. Now let us find all the subscriptions to which you have access...
The following tenants don't contain accessible subscriptions. Use 'az login --allow-no-subscriptions' to have tenant level access.
xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxxx '既定のディレクトリ'
xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxxx 'hogeuser'
[
  {
    "cloudName": "AzureCloud",
    "homeTenantId": "xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx",
    "id": "xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxxx",
    "isDefault": true,
    "managedByTenants": [],
    "name": "dv_xxx_cloudconfig-virtual-event-service_azureplan",
    "state": "Enabled",
    "tenantId": "xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx",
    "user": {
      "name": "hogehoge@example.com",
      "type": "user"
    }
  }
]

コンテナupload

az storage blob upload \
    --account-name <storage-account> \
    --container-name <container> \
    --name dir1/text.txt \
    --file /Users/user1/Desktop/test.txt \
    --auth-mode login
  • storage-accountは、左上のストレージアカウント
  • container-nameはコンテナーを選択した際に表示されるコンテナリスト内の名前
  • nameはazure内のpath
  • fileはローカル内のpath


公式:https://docs.microsoft.com/ja-jp/azure/storage/blobs/storage-quickstart-blobs-cli

コンテナupload(dir)

az storage blob directory upload \
    --account-name <storage-account> \
    -c <container> \ 
    -s "path/to/directory/*" \
    -d dir1 --recursive

引数指定で、DIRの上げ方は色々ある

-s "path/to/file" -d directory
-s "path/to/directory" -d directory --recursive
-s "path/to/*" -d directory --recursive

--container/-cのエラーが出たら

the following arguments are required: --container/-c

コンテナ引数は--container-nameではなく --containerか、-cにするとよい。

storage-previewのメッセージが出てきたら

The command requires the extension storage-preview. Do you want to install it now? The command will continue to run after the extension is installed. (Y/n): 

yを押してインストール

storage blob directoryは非推奨

This command is implicitly deprecated because command group 'storage blob directory' is deprecated and will be removed in a future release. Use 'az storage fs directory' instead

az storage fs directoryが良いらしい

コンテナ内リスト取得

$ az storage blob list \
   --account-name <storage-account> \
   --container-name hoge-workspace \
   --auth-mode login \
   | grep name
   "name": "dir1/file1.txt,
   "name": "dir1/file2.txt",
  • storage-accountは、左上のストレージアカウント

参考:https://www.se-from30.com/azure/azurecli-az-storage-blob-01/