How to remove @strin3http//schemas.microsoft.com/2003/10/Serialization/� received from service bus queue received in python script? How to remove @strin3http//schemas.microsoft.com/2003/10/Serialization/� received from service bus queue received in python script? azure azure

How to remove @strin3http//schemas.microsoft.com/2003/10/Serialization/� received from service bus queue received in python script?


The issue was similiar with the SO thread Interoperability Azure Service Bus Message Queue Messages.

Per my experience, the data from Azure Stream Analytics to Service Bus was sent via AMQP protocol, but the protocol of receiving the data in Python is HTTP. The excess content was generated by AMQP during transmission.

Assumption that receiving the message via the code below, please see https://azure.microsoft.com/en-us/documentation/articles/service-bus-python-how-to-use-queues/#receive-messages-from-a-queue. The function receive_queue_message with the False value of the argument peek_lock wrapped the REST API Receive and Delete Message (Destructive Read).

msg = bus_service.receive_queue_message('taskqueue', peek_lock=False)print(msg.body)

According to the source code of Azure Service Bus SDK for Python include the functions receive_queue_message, read_delete_queue_message and _create_message, I think you can directly remove the excess content from the msg.body using the string common function lstrip or strip.


This TechNet article suggests the following code:

// Get indices of actual messagevar start = jsonString.IndexOf("{");var end = jsonString.LastIndexOf("}") + 1;var length = end - start;// Get actual messagestring cleandJsonString = jsonString.Substring(start, length);

Pretty primitive but whatever works I suppose...


I ran into this issue as well. The previous answers are only workarounds and do not fix the root cause of this issue. The problem you are encountering is likely due to your Stream Analytics compatibility level. Compatibility level 1.0 uses an XML serializer producing the XML tag you are seeing. Compatibility level 1.1 "fixes" this issue.

See my previous answer here: https://stackoverflow.com/a/49307178/263139.