ds_provider_azure_py_lib.linked_service.storage_account

File: storage_account.py Region: ds_provider_azure_py_lib/linked_service/storage_account

Azure Linked Service

This module implements a linked service for Azure Storage services (Blob and Table). Authentication supports either an account access key (shared key) or an Azure AD service principal (client credentials).

Example (access key): >>> linked_service = AzureLinkedService( … settings=AzureLinkedServiceSettings( … account_name=”account name”, … access_key=”account key”, … ), … id=uuid.uuid4(), … name=”testazurepackage”, … version=”0.0.1”, … description=”testazurepackage” … )

Example (client credentials): >>> linked_service = AzureLinkedService( … settings=AzureLinkedServiceSettings( … account_name=”account name”, … tenant_id=”tenant id”, … client_id=”client id”, … client_secret=”client secret”, … ), … id=uuid.uuid4(), … name=”testazurepackage”, … version=”0.0.1”, … description=”testazurepackage” … )

Attributes

logger

_AUTH_REQUIRED_MESSAGE

AzureLinkedServiceSettingsType

Classes

AzureLinkedServiceSettings

The object containing the Azure linked service settings.

AzureLinkedServiceConnection

The object containing the Azure linked service connection clients.

AzureLinkedService

Linked service for connecting to AzureLinkedService.

Module Contents

ds_provider_azure_py_lib.linked_service.storage_account.logger
ds_provider_azure_py_lib.linked_service.storage_account._AUTH_REQUIRED_MESSAGE = 'Access Key, or Tenant ID, Client ID and Client Secret, are required for Azure authentication.'
class ds_provider_azure_py_lib.linked_service.storage_account.AzureLinkedServiceSettings[source]

Bases: ds_resource_plugin_py_lib.common.resource.linked_service.LinkedServiceSettings

The object containing the Azure linked service settings.

Either access_key or the full set of tenant_id, client_id and client_secret must be provided.

account_name: str
access_key: str | None = None
tenant_id: str | None = None
client_id: str | None = None
client_secret: str | None = None
ds_provider_azure_py_lib.linked_service.storage_account.AzureLinkedServiceSettingsType
class ds_provider_azure_py_lib.linked_service.storage_account.AzureLinkedServiceConnection[source]

The object containing the Azure linked service connection clients.

blob_service_client: azure.storage.blob.BlobServiceClient
table_service_client: azure.data.tables.TableServiceClient
class ds_provider_azure_py_lib.linked_service.storage_account.AzureLinkedService[source]

Bases: ds_resource_plugin_py_lib.common.resource.linked_service.LinkedService[AzureLinkedServiceSettingsType], Generic[AzureLinkedServiceSettingsType]

Linked service for connecting to AzureLinkedService.

settings: AzureLinkedServiceSettingsType
_blob_service_client: azure.storage.blob.BlobServiceClient | None = None
_table_service_client: azure.data.tables.TableServiceClient | None = None
_credential: azure.core.credentials.AzureNamedKeyCredential | azure.identity.ClientSecretCredential | None = None
check_settings_is_set() → None[source]

Check if settings are set correctly.

Either access_key or the full set of tenant_id, client_id and client_secret must be provided.

Returns:

None

Raises:
  • AttributeError – If settings are not set correctly.

  • AuthenticationError – If the account name, or a full set of credentials (access key, or tenant/client id and secret), is missing.

property type: ds_provider_azure_py_lib.enums.ResourceType

Get the type of the linked service.

Returns:

ResourceType

property connection: AzureLinkedServiceConnection

Get the connection object for Azure StorageAccount.

Returns:

AzureLinkedServiceConnection

property blob_service_client: azure.storage.blob.BlobServiceClient

Get the BlobServiceClient instance.

Returns:

BlobServiceClient

Raises:

ConnectionError – If blob service client is not connected.

property table_service_client: azure.data.tables.TableServiceClient

Get the TableServiceClient instance.

Returns:

TableServiceClient

Raises:

ConnectionError – If table service client is not connected.

get_blob_service() → azure.storage.blob.BlobServiceClient[source]

Connect to Azure Blob StorageAccount.

Returns:

BlobServiceClient

get_table_service() → azure.data.tables.TableServiceClient[source]

Connect to Azure Table StorageAccount.

Returns:

TableServiceClient

get_credential() → azure.core.credentials.AzureNamedKeyCredential | azure.identity.ClientSecretCredential[source]

Build the credential used to authenticate against Azure Storage.

Prefers the account access key when set, otherwise falls back to client credential (service principal) authentication.

Returns:

AzureNamedKeyCredential | ClientSecretCredential

Raises:

AuthenticationError – If the account name, or a full set of credentials (access key, or tenant/client id and secret), is missing.

connect() → None[source]

Connect to Azure Storage (Blob and Table), ensuring both service clients are initialized.

Returns:

None

test_connection() → tuple[bool, str][source]

Test the connection to Azure Storage (Blob or Table).

Returns:

tuple[bool, str]

close() → None[source]

No need to close the linked service. Just to comply with the interface.

Returns:

None

__enter__() → AzureLinkedService[AzureLinkedServiceSettingsType][source]

Enter context manager.

Returns:

Returns self for use in with statement.

Return type:

AzureLinkedService

__exit__(exc_type: object, exc_val: object, exc_tb: object) → None[source]

Exit context manager and close the connection.

Parameters:
  • exc_type – Exception type if an exception occurred.

  • exc_val – Exception value if an exception occurred.

  • exc_tb – Exception traceback if an exception occurred.

Returns:

None