Closed SuperFexy closed 4 years ago
I found a solution. I needed to Base64 encode my string before sending it into the queue. Here's the working code:
from azure.storage.queue import QueueService
from azure.storage.queue.models import QueueMessageFormat
import json
queue_service = QueueService(account_name=os.environ["AzureQueueServiceAccountName"], account_key=os.environ["AzureQueueServiceAccountKey"])
d = {"keyword": "salmon recipes", "correlationId": "202007011854"}
queue_msg = QueueMessageFormat.text_base64encode(json.dumps(d))
queue_service.put_message('score-search-keyword', queue_msg)
Which service(blob, file, queue) does this issue concern?
Queue Trigger
Which version of the SDK was used? Please provide the output of
pip freeze
.azure-common==1.1.25 azure-functions==1.2.1 azure-storage-common==2.1.0 azure-storage-queue==2.1.0 certifi==2020.4.5.1 cffi==1.14.0 chardet==3.0.4 cryptography==2.9.2 idna==2.9 pycparser==2.20 pymongo==3.10.1 python-dateutil==2.8.1 requests==2.23.0 six==1.15.0 urllib3==1.25.9
What problem was encountered?
I can manually insert an object (
{"keyword": "chicken recipes", "correlationId": "20200630123500"}
) into a queue via the Storage Explorer UI and my code runs fine. If I insert that same object into the queue via my Python code:I'll get an error with the following output: [6/30/2020 3:47:47 PM] Executing 'Functions.SocialFanoutQueueTrigger' (Reason='New queue message detected on 'score-social'.', Id=a465c694-573f-4499-b565-fa5320fe6707) [6/30/2020 3:47:47 PM] Trigger Details: MessageId: 30d98577-4a44-4a86-a74c-dbc147271836, DequeueCount: 1, InsertionTime: 2020-06-30T15:47:45.000+00:00 [6/30/2020 3:47:47 PM] Executed 'Functions.SocialFanoutQueueTrigger' (Failed, Id=a465c694-573f-4499-b565-fa5320fe6707) [6/30/2020 3:47:47 PM] System.Private.CoreLib: Exception while executing function: Functions.SocialFanoutQueueTrigger. Microsoft.Azure.WebJobs.Host: Exception binding parameter 'msg'. System.Private.CoreLib: The input is not a valid Base-64 string as it contains a non-base 64 character, more than two padding characters, or an illegal character among the padding characters.
Have you found a mitigation/solution?
I haven't found a way to get around it yet. Thanks!
Note: for table service, please post the issue here instead: https://github.com/Azure/azure-cosmosdb-python.