How to retrieve logging config in Azure Storage Queue Service with Python SDK

Huu Nguyen 40 Reputation points
2023-11-09T02:22:10.1166667+00:00

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

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

User's image

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

Azure Storage Accounts
Azure Storage Accounts
Globally unique resources that provide access to data management services and serve as the parent namespace for the services.
2,703 questions
Azure Queue Storage
Azure Queue Storage
An Azure service that provides messaging queues in the cloud.
97 questions
{count} votes

Accepted answer
  1. SAMIT SARKAR 791 Reputation points Microsoft Employee
    2023-11-11T03:29:20.9933333+00:00

    Welcome to the Microsoft Q&A Platform. Thank you for reaching out, and I hope you are doing well.

    To retrieve logging information for the Azure Storage Queue service using the Python SDK, you can use the Azure Storage Queue service API along with the Azure Storage SDK for Python. Here's a simple example demonstrating how to do this:

    import os, uuid
    from azure.identity import DefaultAzureCredential
    from azure.storage.queue import QueueServiceClient, QueueClient, QueueMessage, BinaryBase64DecodePolicy, BinaryBase64EncodePolicy
    
    # Update the account name
    account_name = ''
    
    print("Azure Queue storage - Python quickstart sample")
    # Create a unique name for the queue
    queue_name = "quickstartqueues-" + str(uuid.uuid4())
    account_url = "https://"+ account_name +".queue.core.windows.net"
    default_credential = DefaultAzureCredential()
    # Create the QueueClient object
    # We'll use this object to create and interact with the queue
    # For Authetication mechanism please refer https://learn.microsoft.com/en-us/azure/storage/queues/storage-quickstart-queues-python?tabs=passwordless%2Croles-azure-portal%2Cenvironment-variable-windows%2Csign-in-azure-cli#code-examples
    
    queue_client = QueueClient(account_url, queue_name=queue_name ,credential=default_credential)
    print("Azure Queue storage created with name :" + queue_name)
    queue_service = QueueServiceClient(account_url, queue_name=queue_name ,credential=default_credential)
    
    # Retrieve logging properties
    logging_properties = queue_service.get_service_properties()
    print(logging_properties)
    print(logging_properties["hour_metrics"])
    print(logging_properties["minute_metrics"])
    print(logging_properties["analytics_logging"])
    

    Please refer https://github.com/Azure/azure-sdk-for-python/blob/main/sdk/storage/azure-storage-queue/samples/queue_samples_service.py

    Thanks

    1 person found this answer helpful.

0 additional answers

Sort by: Most helpful