diff --git a/src/azure-cli/azure/cli/command_modules/storage/_help.py b/src/azure-cli/azure/cli/command_modules/storage/_help.py index 8473ebe7a41..956c3be32d6 100644 --- a/src/azure-cli/azure/cli/command_modules/storage/_help.py +++ b/src/azure-cli/azure/cli/command_modules/storage/_help.py @@ -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'] = """ @@ -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'] = """ @@ -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'] = """ @@ -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'] = """ @@ -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 @@ -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 """ @@ -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 """ @@ -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 """ @@ -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 """ @@ -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'] = """ @@ -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 --pattern *.py --if-unmodified-since 2018-08-27T20:51Z + az storage blob upload-batch -d mycontainer --account-name mystorageaccount --account-key 00000000 -s --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 + az storage blob upload-batch -d mycontainer -s - 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 --pattern cli-201[89]-??-??.txt + az storage blob upload-batch -d mycontainer -s --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 --pattern cli-201[!89]-??-??.txt + az storage blob upload-batch -d mycontainer -s --pattern cli-201[!89]-??-??.txt """ helps['storage blob url'] = """ @@ -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'] = """ @@ -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 """ @@ -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 """ @@ -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 """ @@ -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'] = """ @@ -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. +""" diff --git a/src/azure-cli/azure/cli/command_modules/storage/_validators.py b/src/azure-cli/azure/cli/command_modules/storage/_validators.py index b2efbca6362..302f5981e37 100644 --- a/src/azure-cli/azure/cli/command_modules/storage/_validators.py +++ b/src/azure-cli/azure/cli/command_modules/storage/_validators.py @@ -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)