1

I have some data in the queues which I want to access in my python code.

I am using the following code:

from azure.storage.queue import QueueService

queue_service = QueueService(account_name='', account_key='')

messages = queue_service.get_messages('queue', num_messages=5)

for message in messages:
    print(message.id)
    print(message.content)

But the output of the content is in the form of some coded message.

How do I decode it?

2 Answers 2

2

You could use print(base64.b64decode(message.content)).

from azure.storage.queue import QueueService
import base64

queue_service = QueueService(account_name='', account_key='')

messages = queue_service.get_messages('queue', num_messages=5)

for message in messages:
    print(message.id)
    print(message.content)
    print(base64.b64decode(message.content))

enter image description here

1
from azure.storage.queue import QueueService, QueueMessageFormat
queue_service = QueueService(account_name=account_name, account_key=account_key)
#queue_service.encode_function = QueueMessageFormat.binary_base64decode
queue_service.decode_function = QueueMessageFormat.binary_base64decode
messages = queue_service.get_messages(...

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.