Is your feature request related to a problem? Please describe.
The storage clients (blob, queue, ...) doesn't seem to support the type AzureNamedKeyCredential. This is inconsistent with many other parts of the API. For instance the table client allows it:
|
class AccountHostsMixin(object): # pylint: disable=too-many-instance-attributes |
|
def __init__( |
|
self, |
|
account_url, # type: Any |
|
credential=None, # type: Optional[Union[AzureNamedKeyCredential, AzureSasCredential, "TokenCredential"]] |
|
**kwargs # type: Any |
|
): |
It is also frustrating that the credential is typed as Any.
|
credential=None, # type: Optional[Any] |
This causes a lot of guessing what kind of credential the clients support 😕
Describe the solution you'd like
The signature should get proper type annotations, and this function should simply handle AzureNamedKeyCredential.
|
def _format_shared_key_credential(account_name, credential): |
|
if isinstance(credential, six.string_types): |
|
if not account_name: |
|
raise ValueError("Unable to determine account name for shared key credential.") |
|
credential = {"account_name": account_name, "account_key": credential} |
|
if isinstance(credential, dict): |
|
if "account_name" not in credential: |
|
raise ValueError("Shared key credential missing 'account_name") |
|
if "account_key" not in credential: |
|
raise ValueError("Shared key credential missing 'account_key") |
|
return SharedKeyCredentialPolicy(**credential) |
|
return credential |
Perhaps the private type SharedKeyCredentialPolicy should be even completely be replaced by AzureNamedKeyCredential.
Describe alternatives you've considered
Type guessing and constantly converting from and to AzureNamedKeyCredential and the plain {"account_name": str, "account_key": str} that the blob storage wants.
Is your feature request related to a problem? Please describe.
The storage clients (blob, queue, ...) doesn't seem to support the type
AzureNamedKeyCredential. This is inconsistent with many other parts of the API. For instance the table client allows it:azure-sdk-for-python/sdk/tables/azure-data-tables/azure/data/tables/_base_client.py
Lines 76 to 82 in c8a0268
It is also frustrating that the
credentialis typed asAny.azure-sdk-for-python/sdk/storage/azure-storage-blob/azure/storage/blob/_shared/base_client.py
Line 71 in c8a0268
This causes a lot of guessing what kind of credential the clients support 😕
Describe the solution you'd like
The signature should get proper type annotations, and this function should simply handle
AzureNamedKeyCredential.azure-sdk-for-python/sdk/storage/azure-storage-blob/azure/storage/blob/_shared/base_client.py
Lines 348 to 359 in c8a0268
Perhaps the private type
SharedKeyCredentialPolicyshould be even completely be replaced byAzureNamedKeyCredential.Describe alternatives you've considered
Type guessing and constantly converting from and to
AzureNamedKeyCredentialand the plain{"account_name": str, "account_key": str}that the blob storage wants.