Search code examples
azure-blob-storageazure-storageazure-table-storageazure-storage-queues

How to retrieve logging config in Azure Storage Blob, Queue and Table Service with Python Azure SDK


Can someone guide me to retrieve logging information of Storage Queue Service similar to the part I have circled in red as instructed in this article?

Image:

enter image description here

Article link: https://www.trendmicro.com/cloudoneconformity/knowledge-base/azure/StorageAccounts/storage-logging-for-queue-service.html

I use Python Azure SDK to do this

Thank you !

I want to check if the Read-Write-Delete actions are Enabled or Not, but currently, I have not found any similar documentation from Microsoft.


Solution

  • Can someone guide me to retrieve logging information of Storage Queue Service similar to the part I have circled in red as instructed in this article?

    You can use the below code to retrieve logging information of Storage Queue Service using Azure Python SDK.

    You need to install the azure-storage-queue package in your environment.

    Code:

    from azure.storage.queue import QueueServiceClient
    
    connection_string = "xxxx"
    queue_service_client = QueueServiceClient.from_connection_string(connection_string)
    
    service_properties = queue_service_client.get_service_properties()
    analytics_logging = service_properties.get("analytics_logging")
    print(analytics_logging)
    

    The above code is using the Azure Storage Queue Python SDK to connect to an Azure Storage account using the connection string. It then creates a QueueServiceClient object using the connection string and retrieves the service properties of the queue service. Finally, it retrieves the analytics logging setting from the service properties.

    Output:

    {'version': '1.0', 'delete': False, 'read': False, 'write': False, 'retention_policy': <azure.storage.queue._models.RetentionPolicy object at 0x000002288F89A9D0>} 
    

    enter image description here

    Similarly, you can use the azure-storage-blob and azure-storage-table package for retrieve logging information of Azure storage Blob, Table service using Azure Python SDK.