Repository: Azure/azure-cli-extensions

Issue:
unexpected keyword argument 'account_key'
## Describe the bug

I've used this command in the past to get a list of VHD images in my storage: 

**Command Name**
`az storage blob list
Extension Name: storage-blob-preview. Version: 0.5.0.`

**Errors:**
```
The command failed with an unexpected error. Here is the traceback:
request() got an unexpected keyword argument 'account_key'
Traceback (most recent call last):
  File "/opt/az/lib/python3.6/site-packages/knack/cli.py", line 231, in invoke
    cmd_result = self.invocation.execute(args)
  File "/opt/az/lib/python3.6/site-packages/azure/cli/core/commands/__init__.py", line 657, in execute
    raise ex
  File "/opt/az/lib/python3.6/site-packages/azure/cli/core/commands/__init__.py", line 720, in _run_jobs_serially
    results.append(self._run_job(expanded_arg, cmd_copy))
  File "/opt/az/lib/python3.6/site-packages/azure/cli/core/commands/__init__.py", line 712, in _run_job
    return cmd_copy.exception_handler(ex)
  File "/home/henti/.azure/cliextensions/storage-blob-preview/azext_storage_blob_preview/__init__.py", line 266, in new_handler
    raise ex
  File "/opt/az/lib/python3.6/site-packages/azure/cli/core/commands/__init__.py", line 691, in _run_job
    result = cmd_copy(params)
  File "/opt/az/lib/python3.6/site-packages/azure/cli/core/commands/__init__.py", line 328, in __call__
    return self.handler(*args, **kwargs)
  File "/opt/az/lib/python3.6/site-packages/azure/cli/core/commands/command_operation.py", line 121, in handler
    return op(**command_args)
  File "/home/henti/.azure/cliextensions/storage-blob-preview/azext_storage_blob_preview/operations/blob.py", line 511, in list_blobs
    result = list_generator(pages=pages, num_results=num_results)
  File "/home/henti/.azure/cliextensions/storage-blob-preview/azext_storage_blob_preview/track2_util.py", line 83, in list_generator
    page = list(next(pages))
  File "/opt/az/lib/python3.6/site-packages/azure/core/paging.py", line 76, in __next__
    self._response = self._get_next(self.continuation_token)
  File "/home/henti/.azure/cliextensions/storage-blob-preview/azext_storage_blob_preview/vendored_sdks/azure_storage_blob/v2020_02_10/_list_blobs_helper.py", line 76, in _get_next_cb
    use_location=self.location_mode)
  File "/home/henti/.azure/cliextensions/storage-blob-preview/azext_storage_blob_preview/vendored_sdks/azure_storage_blob/v2020_02_10/_generated/operations/_container_operations.py", line 1211, in list_blob_flat_segment
    pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs)
  File "/opt/az/lib/python3.6/site-packages/azure/core/pipeline/_base.py", line 211, in run
    return first_node.send(pipeline_request)  # type: ignore
  File "/opt/az/lib/python3.6/site-packages/azure/core/pipeline/_base.py", line 71, in send
    response = self.next.send(request)
  File "/opt/az/lib/python3.6/site-packages/azure/core/pipeline/_base.py", line 71, in send
    response = self.next.send(request)
  File "/opt/az/lib/python3.6/site-packages/azure/core/pipeline/_base.py", line 71, in send
    response = self.next.send(request)
  [Previous line repeated 2 more times]
  File "/opt/az/lib/python3.6/site-packages/azure/core/pipeline/policies/_redirect.py", line 158, in send
    response = self.next.send(request)
  File "/opt/az/lib/python3.6/site-packages/azure/core/pipeline/_base.py", line 71, in send
    response = self.next.send(request)
  File "/home/henti/.azure/cliextensions/storage-blob-preview/azext_storage_blob_preview/vendored_sdks/azure_storage_blob/v2020_02_10/_shared/policies.py", line 489, in send
    response = self.next.send(request)
  File "/opt/az/lib/python3.6/site-packages/azure/core/pipeline/_base.py", line 71, in send
    response = self.next.send(request)
  File "/opt/az/lib/python3.6/site-packages/azure/core/pipeline/_base.py", line 71, in send
    response = self.next.send(request)
  File "/opt/az/lib/python3.6/site-packages/azure/core/pipeline/_base.py", line 71, in send
    response = self.next.send(request)
  [Previous line repeated 1 more time]
  File "/home/henti/.azure/cliextensions/storage-blob-preview/azext_storage_blob_preview/vendored_sdks/azure_storage_blob/v2020_02_10/_shared/policies.py", line 290, in send
    response = self.next.send(request)
  File "/opt/az/lib/python3.6/site-packages/azure/core/pipeline/_base.py", line 71, in send
    response = self.next.send(request)
  File "/opt/az/lib/python3.6/site-packages/azure/core/pipeline/_base.py", line 71, in send
    response = self.next.send(request)
  File "/opt/az/lib/python3.6/site-packages/azure/core/pipeline/_base.py", line 103, in send
    self._sender.send(request.http_request, **request.context.options),
  File "/home/henti/.azure/cliextensions/storage-blob-preview/azext_storage_blob_preview/vendored_sdks/azure_storage_blob/v2020_02_10/_shared/base_client.py", line 319, in send
    return self._transport.send(request, **kwargs)
  File "/opt/az/lib/python3.6/site-packages/azure/core/pipeline/transport/_requests_basic.py", line 246, in send
    **kwargs)
TypeError: request() got an unexpected keyword argument 'account_key'

```

## To Reproduce:
Steps to reproduce the behavior. Note that argument values have been redacted, as they may contain sensitive information.

```
export AZURE_STORAGE_CONNECTION_STRING=$(az storage account show-connection-string -n $storageAccountName -g $ResourceGroupName --query connectionString -o tsv)
az storage blob list -c $container
```
## Expected Behavior

list file sin storage

## Environment Summary
```
Linux-5.4.0-72-generic-x86_64-with-debian-buster-sid
Python 3.6.10
Installer: DEB

azure-cli 2.24.2

Extensions:
storage-blob-preview 0.5.0
image-copy-extension 0.2.8

```
## Additional Context

<!--Please don't remove this:-->
<!--auto-generated-->




Discussion:
storage
Using the official documentation here : https://docs.microsoft.com/en-us/azure/virtual-machines/linux/find-unattached-disks with this snippet

```
# Set deleteUnattachedVHDs=1 if you want to delete unattached VHDs
# Set deleteUnattachedVHDs=0 if you want to see the details of the unattached VHDs
deleteUnattachedVHDs=0
storageAccountIds=$(az storage account list --query [].[id] -o tsv)
for id in ${storageAccountIds[@]}
do
    connectionString=$(az storage account show-connection-string --ids $id --query connectionString -o tsv)
    containers=$(az storage container list --connection-string $connectionString --query [].[name] -o tsv)

    for container in ${containers[@]}
    do 
        
        blobs=$(az storage blob list -c $container --connection-string $connectionString --query "[?properties.blobType=='PageBlob' && ends_with(name,'.vhd')].[name]" -o tsv)
        
        for blob in ${blobs[@]}
        do
            leaseStatus=$(az storage blob show -n $blob -c $container --connection-string $connectionString --query "properties.lease.status" -o tsv)
            
            if [ "$leaseStatus" == "unlocked" ]
            then 

                if (( $deleteUnattachedVHDs == 1 ))
                then 

                    echo "Deleting VHD: "$blob" in container: "$container" in storage account: "$id

                    az storage blob delete --delete-snapshots include  -n $blob -c $container --connection-string $connectionString

                    echo "Deleted VHD: "$blob" in container: "$container" in storage account: "$id
                else
                    echo "StorageAccountId: "$id" container: "$container" VHD: "$blob
                fi

            fi
        done
    done
done
```
Getting the same errors. This is official Microsoft documentation.  

Resolving patch:
diff --git a/src/storage-blob-preview/azext_storage_blob_preview/_client_factory.py b/src/storage-blob-preview/azext_storage_blob_preview/_client_factory.py
--- a/src/storage-blob-preview/azext_storage_blob_preview/_client_factory.py
+++ b/src/storage-blob-preview/azext_storage_blob_preview/_client_factory.py
@@ -3,9 +3,8 @@
 # Licensed under the MIT License. See License.txt in the project root for license information.
 # --------------------------------------------------------------------------------------------
 
-from azure.cli.core.commands.client_factory import get_mgmt_service_client
+from azure.cli.core.commands.client_factory import get_mgmt_service_client, prepare_client_kwargs_track2
 from azure.cli.core.profiles import ResourceType, get_sdk
-from azure.cli.core.commands.client_factory import _prepare_client_kwargs_track2
 from .profiles import CUSTOM_DATA_STORAGE_BLOB, CUSTOM_MGMT_STORAGE
 
 MISSING_CREDENTIALS_ERROR_MESSAGE = """
@@ -54,28 +53,37 @@ def get_credential(kwargs):
     return credential
 
 
+def _config_location_mode(kwargs, client_kwargs):
+    location_mode = kwargs.pop('location_mode', None)
+    if location_mode:
+        client_kwargs['_location_mode'] = location_mode
+    return client_kwargs
+
+
 def cf_blob_service(cli_ctx, kwargs):
-    from knack.util import CLIError
-    client_kwargs = {}
+    client_kwargs = prepare_client_kwargs_track2(cli_ctx)
+    client_kwargs = _config_location_mode(kwargs, client_kwargs)
     t_blob_service = get_sdk(cli_ctx, CUSTOM_DATA_STORAGE_BLOB,
                              '_blob_service_client#BlobServiceClient')
     connection_string = kwargs.pop('connection_string', None)
     account_name = kwargs.pop('account_name', None)
-
-    location_mode = kwargs.pop('location_mode', None)
-    if location_mode:
-        client_kwargs['_location_mode'] = location_mode
-    client_kwargs.update(_prepare_client_kwargs_track2(cli_ctx))
+    account_key = kwargs.pop('account_key', None)
+    token_credential = kwargs.pop('token_credential', None)
+    sas_token = kwargs.pop('sas_token', None)
     if connection_string:
-        return t_blob_service.from_connection_string(conn_str=connection_string, **client_kwargs)
+        try:
+            return t_blob_service.from_connection_string(conn_str=connection_string, **client_kwargs)
+        except ValueError as err:
+            from azure.cli.core.azclierror import InvalidArgumentValueError
+            raise InvalidArgumentValueError('Invalid connection string: {}, err detail: {}'
+                                            .format(connection_string, str(err)),
+                                            recommendation='Try `az storage account show-connection-string` '
+                                                           'to get a valid connection string')
 
     account_url = get_account_url(cli_ctx, account_name=account_name, service='blob')
-    credential = get_credential(kwargs)
+    credential = account_key or sas_token or token_credential
 
-    if account_url and credential:
-        return t_blob_service(account_url=account_url, credential=credential, **client_kwargs)
-    raise CLIError("Please provide valid connection string, or account name with account key, "
-                   "sas token or login auth mode.")
+    return t_blob_service(account_url=account_url, credential=credential, **client_kwargs)
 
 
 def cf_blob_client(cli_ctx, kwargs):
diff --git a/src/storage-blob-preview/azext_storage_blob_preview/commands.py b/src/storage-blob-preview/azext_storage_blob_preview/commands.py
--- a/src/storage-blob-preview/azext_storage_blob_preview/commands.py
+++ b/src/storage-blob-preview/azext_storage_blob_preview/commands.py
@@ -66,13 +66,9 @@ def get_custom_sdk(custom_module, client_factory, resource_type=ResourceType.DAT
                             custom_command_type=get_custom_sdk('blob', client_factory=cf_blob_client,
                                                                resource_type=CUSTOM_DATA_STORAGE_BLOB)) as g:
         from azure.cli.command_modules.storage._format import transform_blob_output
-        from ._transformers import transform_blob_list_output, transform_blob_json_output, transform_metadata,\
+        from ._transformers import transform_blob_json_output, transform_metadata,\
             create_boolean_result_output_transformer
-        g.storage_custom_command_oauth('list', 'list_blobs', client_factory=cf_container_client,
-                                       transform=transform_blob_list_output,
-                                       table_transformer=transform_blob_output)
 
-        g.storage_custom_command_oauth('copy start', 'copy_blob')
         g.storage_command_oauth('delete', 'delete_blob')
         g.storage_custom_command_oauth('download', 'download_blob')
         g.storage_command_oauth('exists', 'exists', transform=create_boolean_result_output_transformer('exists'))
diff --git a/src/storage-blob-preview/setup.py b/src/storage-blob-preview/setup.py
--- a/src/storage-blob-preview/setup.py
+++ b/src/storage-blob-preview/setup.py
@@ -16,7 +16,7 @@
 
 # TODO: Confirm this is the right version number you want and it matches your
 # HISTORY.rst entry.
-VERSION = '0.5.0'
+VERSION = '0.5.1'
 
 # The full list of classifiers is available at
 # https://pypi.python.org/pypi?%3Aaction=list_classifiers


Test patch: