「Azure/CLI」の版間の差分
提供: 初心者エンジニアの簡易メモ
(→コンテナupload(dir)) |
(→コンテナupload(dir)) |
||
| 行52: | 行52: | ||
az storage blob directory upload \ | az storage blob directory upload \ | ||
--account-name <storage-account> \ | --account-name <storage-account> \ | ||
| − | - | + | -c <container> \ |
| − | -s "path/to/directory" \ | + | -s "path/to/directory/*" \ |
| − | -d | + | -d dir1 --recursive |
</pre> | </pre> | ||
| + | |||
| + | 引数指定で、DIRの上げ方は色々ある | ||
| + | <pre> | ||
| + | -s "path/to/file" -d directory | ||
| + | -s "path/to/directory" -d directory --recursive | ||
| + | -s "path/to/*" -d directory --recursive | ||
| + | </pre> | ||
| + | |||
===--container/-cのエラーが出たら=== | ===--container/-cのエラーが出たら=== | ||
2021年8月19日 (木) 20:35時点における版
目次
インストール
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.
61e87b26-c760-xxxx-xxxx-xxxxxxxxxxxxx '既定のディレクトリ'
f18370bf-eaa5-xxxx-xxxx-xxxxxxxxxxxxx '株式会社aaa'
[
{
"cloudName": "AzureCloud",
"homeTenantId": "850d80c1-xxxx-xxxx-xxxx-xxxxxxxxxxxx",
"id": "63f0dcef-7f0f-4e3a-b911-xxxxxxxxxxxxx",
"isDefault": true,
"managedByTenants": [],
"name": "dv_xxx_cloudconfig-virtual-event-service_azureplan",
"state": "Enabled",
"tenantId": "850d80c1-e9bd-4f94-a740-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/
