ds_provider_azure_py_lib.linked_service¶
File: __init__.py
Region: ds_provider_azure_py_lib/linked_service
Azure Linked Service
This module implements a linked service for Azure storage. Authentication supports either an account access key (shared key) or an Azure AD service principal (client credentials).
- Example (access key):
>>> azure_linked_service = AzureLinkedService(settings=AzureLinkedServiceSettings( ... account_name="your_account_name", ... access_key="access key")) >>> azure_linked_service.connect()
- Example (client credentials):
>>> azure_linked_service = AzureLinkedService(settings=AzureLinkedServiceSettings( ... account_name="your_account_name", ... tenant_id="tenant id", ... client_id="client id", ... client_secret="client secret")) >>> azure_linked_service.connect()
Submodules¶
Classes¶
Linked service for connecting to AzureLinkedService. |
|
The object containing the Azure linked service settings. |
Package Contents¶
- class ds_provider_azure_py_lib.linked_service.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_keyor the full set oftenant_id,client_idandclient_secretmust 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:
- __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
- class ds_provider_azure_py_lib.linked_service.AzureLinkedServiceSettings[source]¶
Bases:
ds_resource_plugin_py_lib.common.resource.linked_service.LinkedServiceSettingsThe object containing the Azure linked service settings.
Either
access_keyor the full set oftenant_id,client_idandclient_secretmust 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¶