From 182700218a68001f2aa4a1cf1386965cc8fc1f22 Mon Sep 17 00:00:00 2001 From: Viktor Seifert Date: Wed, 12 Oct 2022 16:44:47 +0200 Subject: [PATCH] Added logging output to azure storage to better diagnose connection problems --- pyinfra/storage/adapters/azure.py | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/pyinfra/storage/adapters/azure.py b/pyinfra/storage/adapters/azure.py index f954e38..6a3ac4d 100644 --- a/pyinfra/storage/adapters/azure.py +++ b/pyinfra/storage/adapters/azure.py @@ -10,8 +10,8 @@ from pyinfra.config import Config, get_config CONFIG = get_config() logger = logging.getLogger(CONFIG.logging_level_root) -logging.getLogger("azure").setLevel(logging.WARNING) -logging.getLogger("urllib3").setLevel(logging.WARNING) +logging.getLogger("azure").setLevel(logging.INFO) +logging.getLogger("urllib3").setLevel(logging.INFO) class AzureStorageAdapter(object): @@ -38,6 +38,8 @@ class AzureStorageAdapter(object): blob_client.upload_blob(data, overwrite=True) def exists(self, bucket_name, object_name): + logger.info(f"Checking if object with object_name={object_name} exists in bucket bucket_name={bucket_name}") + container_client = self.__provide_container_client(bucket_name) blob_client = container_client.get_blob_client(object_name) return blob_client.exists() @@ -77,4 +79,6 @@ class AzureStorageAdapter(object): def get_azure_storage(config: Config): - return AzureStorageAdapter(BlobServiceClient.from_connection_string(conn_str=config.storage_azureconnectionstring)) + azureconnectionstring = config.storage_azureconnectionstring + logger.info(f"Connecting to azure storage via {azureconnectionstring}") + return AzureStorageAdapter(BlobServiceClient.from_connection_string(conn_str=azureconnectionstring))