Azure / azure-functions-python-worker

Python worker for Azure Functions.
http://aka.ms/azurefunctions
MIT License
336 stars 104 forks source link

[FeatureRequest] type serviceBus direction out - specify content-type #878

Open freedev opened 3 years ago

freedev commented 3 years ago

It seems not possible define the content-type for an out message. In my function.json I have an out serviceBus that works fine but I'm unable to define the content-type.

{
  "type": "serviceBus",
  "direction": "out",
  "connection": "AzureServiceBusConnectionString",
  "name": "outmsg",
  "topicName": "%DIGICD_NOTIFICATION%"
}

but outmsg is defined as azure.functions.Out[str]. Honestly, I'm not fluent in Python, It seems to me that Out is a monad, an object that contains a string. it is not clear if we can define Out with another type other than str. And in any case even if the message is sent as str with content-type for the receiver is application/xml; charset=utf-8

I think we should be able at least to specify the content type. Something like this:

outmsg.set(json.dumps({ 'key':'value' })) 
outmsg.setContentType('application/json') 

Or we could extend the function.json adding the default content type parameter of out messages.

freedev commented 2 years ago

any update here?