Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
75 changes: 49 additions & 26 deletions src/azure-cli/azure/cli/command_modules/storage/_help.py
Original file line number Diff line number Diff line change
Expand Up @@ -254,6 +254,10 @@
helps['storage blob'] = """
type: group
short-summary: Manage object storage for unstructured data (blobs).
long-summary: >
Please specify one of the following authentication parameters for your commands: --auth-mode, --account-key,
--connection-string, --sas-token. You also can use corresponding environment variables to store your authentication
credentials, e.g. AZURE_STORAGE_KEY, AZURE_STORAGE_CONNECTION_STRING and AZURE_STORAGE_SAS_TOKEN.
"""

helps['storage blob copy'] = """
Expand Down Expand Up @@ -320,7 +324,9 @@
Both can be removed at the same time.
examples:
- name: Delete a blob.
text: az storage blob delete -c MyContainer -n MyBlob
text: az storage blob delete -c mycontainer -n MyBlob
- name: Delete a blob using login credentials.
text: az storage blob delete -c mycontainer -n MyBlob --account-name mystorageaccount --auth-mode login
"""

helps['storage blob delete-batch'] = """
Expand Down Expand Up @@ -350,16 +356,16 @@
- name: Delete all blobs ending with ".py" in a container that have not been modified for 10 days.
text: |
date=`date -d "10 days ago" '+%Y-%m-%dT%H:%MZ'`
az storage blob delete-batch -s mycontainer --account-name mystorageaccount --pattern *.py --if-unmodified-since $date
az storage blob delete-batch -s mycontainer --account-name mystorageaccount --pattern *.py --if-unmodified-since $date --auth-mode login
- name: Delete all the blobs in a directory named "dir" in a container named "mycontainer".
text: |
az storage blob delete-batch -s mycontainer --account-name mystorageaccount --pattern dir/*
az storage blob delete-batch -s mycontainer --pattern dir/*
- name: Delete the blobs with the format 'cli-2018-xx-xx.txt' or 'cli-2019-xx-xx.txt' in a container.
text: |
az storage blob delete-batch -s mycontainer --account-name mystorageaccount --pattern cli-201[89]-??-??.txt
az storage blob delete-batch -s mycontainer --pattern cli-201[89]-??-??.txt
- name: Delete all blobs with the format 'cli-201x-xx-xx.txt' except cli-2018-xx-xx.txt' and 'cli-2019-xx-xx.txt' in a container.
text: |
az storage blob delete-batch -s mycontainer --account-name mystorageaccount --pattern cli-201[!89]-??-??.txt
az storage blob delete-batch -s mycontainer --pattern cli-201[!89]-??-??.txt
"""

helps['storage blob download-batch'] = """
Expand All @@ -383,16 +389,16 @@
examples:
- name: Download all blobs that end with .py
text: |
az storage blob download-batch -d . --pattern *.py -s mycontainer --account-name mystorageaccount
az storage blob download-batch -d . --pattern *.py -s mycontainer --account-name mystorageaccount --account-key 00000000
- name: Download all blobs in a directory named "dir" from container named "mycontainer".
text: |
az storage blob download-batch -d . -s mycontainer --account-name mystorageaccount --pattern dir/*
az storage blob download-batch -d . -s mycontainer --pattern dir/*
- name: Download all blobs with the format 'cli-2018-xx-xx.txt' or 'cli-2019-xx-xx.txt' in container to current path.
text: |
az storage blob download-batch -d . -s mycontainer --account-name mystorageaccount --pattern cli-201[89]-??-??.txt
az storage blob download-batch -d . -s mycontainer --pattern cli-201[89]-??-??.txt
- name: Download all blobs with the format 'cli-201x-xx-xx.txt' except cli-2018-xx-xx.txt' and 'cli-2019-xx-xx.txt' in container to current path.
text: |
az storage blob download-batch -d . -s mycontainer --account-name mystorageaccount --pattern cli-201[!89]-??-??.txt
az storage blob download-batch -d . -s mycontainer --pattern cli-201[!89]-??-??.txt
"""

helps['storage blob exists'] = """
Expand All @@ -414,7 +420,7 @@
- name: Generate a sas token for a blob with read-only permissions.
text: |
end=`date -u -d "30 minutes" '+%Y-%m-%dT%H:%MZ'`
az storage blob generate-sas --account-name MyStorageAccount -c MyContainer -n MyBlob --permissions r --expiry $end --https-only
az storage blob generate-sas -c myycontainer -n MyBlob --permissions r --expiry $end --https-only
- name: Generates a shared access signature for the blob. (autogenerated)
text: az storage blob generate-sas --account-key 00000000 --account-name MyStorageAccount --container-name MyContainer --expiry 2018-01-01T00:00:00Z --name MyBlob --permissions r
crafted: true
Expand Down Expand Up @@ -473,7 +479,7 @@
short-summary: Show the storage blob delete-policy.
examples:
- name: Show the storage blob delete-policy. (autogenerated)
text: az storage blob service-properties delete-policy show --account-name MyAccount
text: az storage blob service-properties delete-policy show --account-name mystorageccount --account-key 00000000
crafted: true
"""

Expand All @@ -482,7 +488,7 @@
short-summary: Update the storage blob delete-policy.
examples:
- name: Update the storage blob delete-policy. (autogenerated)
text: az storage blob service-properties delete-policy update --account-name MyAccount --days-retained 7 --enable true
text: az storage blob service-properties delete-policy update --account-name mystorageccount --account-key 00000000 --days-retained 7 --enable true
crafted: true
"""

Expand All @@ -491,7 +497,7 @@
short-summary: Update storage blob service properties.
examples:
- name: Update storage blob service properties. (autogenerated)
text: az storage blob service-properties update --404-document error.html --account-name MyAccount --index-document index.html --static-website true
text: az storage blob service-properties update --404-document error.html --account-name mystorageccount --account-key 00000000 --index-document index.html --static-website true
crafted: true
"""

Expand Down Expand Up @@ -521,7 +527,7 @@
- name: Show all properties of a blob.
text: az storage blob show -c MyContainer -n MyBlob
- name: Get the details of a blob (autogenerated)
text: az storage blob show --account-name MyAccount --container-name MyContainer --name MyBlob
text: az storage blob show --account-name mystorageccount --account-key 00000000 --container-name MyContainer --name MyBlob
crafted: true
"""

Expand All @@ -531,9 +537,9 @@
long-summary: Sync command depends on Azcopy, which will be upgraded to v10.3 soon to support 32-bit Operating System and utilize new features.
examples:
- name: Sync a single blob to a container.
text: az storage blob sync -c MyContainer --account-name MyStorageAccount -s "path/to/file" -d NewBlob
text: az storage blob sync -c mycontainer -s "path/to/file" -d NewBlob
- name: Sync a directory to a container.
text: az storage blob sync -c MyContainer --account-name MyStorageAccount -s "path/to/directory"
text: az storage blob sync -c mycontainer --account-name mystorageccount --account-key 00000000 -s "path/to/directory"
"""

helps['storage blob upload'] = """
Expand Down Expand Up @@ -590,16 +596,16 @@
examples:
- name: Upload all files that end with .py unless blob exists and has been modified since given date.
text: |
az storage blob upload-batch -d mycontainer --account-name mystorageaccount -s <path-to-directory> --pattern *.py --if-unmodified-since 2018-08-27T20:51Z
az storage blob upload-batch -d mycontainer --account-name mystorageaccount --account-key 00000000 -s <path-to-directory> --pattern *.py --if-unmodified-since 2018-08-27T20:51Z
- name: Upload all files from local path directory to a container named "mycontainer".
text: |
az storage blob upload-batch -d mycontainer --account-name mystorageaccount -s <path-to-directory>
az storage blob upload-batch -d mycontainer -s <path-to-directory>
- name: Upload all files with the format 'cli-2018-xx-xx.txt' or 'cli-2019-xx-xx.txt' in local path directory.
text: |
az storage blob upload-batch -d mycontainer --account-name mystorageaccount -s <path-to-directory> --pattern cli-201[89]-??-??.txt
az storage blob upload-batch -d mycontainer -s <path-to-directory> --pattern cli-201[89]-??-??.txt
- name: Upload all files with the format 'cli-201x-xx-xx.txt' except cli-2018-xx-xx.txt' and 'cli-2019-xx-xx.txt' in a container.
text: |
az storage blob upload-batch -d mycontainer --account-name mystorageaccount -s <path-to-directory> --pattern cli-201[!89]-??-??.txt
az storage blob upload-batch -d mycontainer -s <path-to-directory> --pattern cli-201[!89]-??-??.txt
"""

helps['storage blob url'] = """
Expand All @@ -610,13 +616,17 @@
text: az storage blob url --connection-string $connectionString --container-name container1 --name blob1
crafted: true
- name: Create the url to access a blob (autogenerated)
text: az storage blob url --account-name storageacct --container-name container1 --name blob1
text: az storage blob url --account-name storageacct --account-key 00000000 --container-name container1 --name blob1
crafted: true
"""

helps['storage container'] = """
type: group
short-summary: Manage blob storage containers.
long-summary: >
Please specify one of the following authentication parameters for your commands: --auth-mode, --account-key,
--connection-string, --sas-token. You also can use corresponding environment variables to store your authentication
credentials, e.g. AZURE_STORAGE_KEY, AZURE_STORAGE_CONNECTION_STRING and AZURE_STORAGE_SAS_TOKEN.
"""

helps['storage container create'] = """
Expand Down Expand Up @@ -651,7 +661,7 @@
short-summary: Check for the existence of a storage container.
examples:
- name: Check for the existence of a storage container. (autogenerated)
text: az storage container exists --account-name MyAccount --name MyContainer
text: az storage container exists --account-name mystorageccount --account-key 00000000 --name mycontainer
crafted: true
"""

Expand All @@ -662,10 +672,10 @@
- name: Generate a sas token for blob container and use it to upload a blob.
text: |
end=`date -u -d "30 minutes" '+%Y-%m-%dT%H:%MZ'`
sas=`az storage container generate-sas -n MyContainer --account-name MyStorageAccount --https-only --permissions dlrw --expiry $end -o tsv`
az storage blob upload -n MyBlob -c MyContainer --account-name MyStorageAccount -f file.txt --sas-token $sas
sas=`az storage container generate-sas -n mycontainer --https-only --permissions dlrw --expiry $end -o tsv`
az storage blob upload -n MyBlob -c mycontainer -f file.txt --sas-token $sas
- name: Generates a shared access signature for the container (autogenerated)
text: az storage container generate-sas --account-key 00000000 --account-name MyStorageAccount --expiry 2020-01-01 --name MyContainer --permissions dlrw
text: az storage container generate-sas --account-key 00000000 --account-name mystorageaccount --expiry 2020-01-01 --name mycontainer --permissions dlrw
crafted: true
"""

Expand All @@ -689,7 +699,7 @@
short-summary: Get the legal hold properties of a container.
examples:
- name: Get the legal hold properties of a container. (autogenerated)
text: az storage container legal-hold show --account-name MyAccount --container-name MyContainer
text: az storage container legal-hold show --account-name mystorageccount --container-name MyContainer
crafted: true
"""

Expand Down Expand Up @@ -1126,6 +1136,10 @@
helps['storage message'] = """
type: group
short-summary: Manage queue storage messages.
long-summary: >
Please specify one of the following authentication parameters for your commands: --auth-mode, --account-key,
--connection-string, --sas-token. You also can use corresponding environment variables to store your authentication
credentials, e.g. AZURE_STORAGE_KEY, AZURE_STORAGE_CONNECTION_STRING and AZURE_STORAGE_SAS_TOKEN.
"""

helps['storage metrics'] = """
Expand Down Expand Up @@ -1369,3 +1383,12 @@
type: group
short-summary: Manage shared access policies of a storage table.
"""

helps['storage queue'] = """
type: group
short-summary: Manage shared access policies of a storage table.
long-summary: >
Please specify one of the following authentication parameters for your commands: --auth-mode, --account-key,
--connection-string, --sas-token. You also can use corresponding environment variables to store your authentication
credentials, e.g. AZURE_STORAGE_KEY, AZURE_STORAGE_CONNECTION_STRING and AZURE_STORAGE_SAS_TOKEN.
"""
Original file line number Diff line number Diff line change
Expand Up @@ -147,6 +147,9 @@ def get_config_value(section, key, default):

# if account name is specified but no key, attempt to query
if n.account_name and not n.account_key and not n.sas_token:
logger.warning('No connection string, account key or sas token found, we will query account keys for your '
'storage account. Please try to use --auth-mode login or provide one of the following parameters'
': connection string, account key or sas token for your storage account.')
n.account_key = _query_account_key(cmd.cli_ctx, n.account_name)


Expand Down