azure-functions-powershell-worker
azure-functions-powershell-worker copied to clipboard
Unable to set custom properties on a ServiceBus message when using push-outputbinding
When working with Azure Functions V2 (Powershell) ServiceBus output binding we are not able to add any user attributes to the servicebus message since the push-outputbinding cmdlet takes the object passed in "value" as the message body (it will serialize the object and submit that as the message text/body). ideally one could craft a Service Bus message of type Microsoft.Azure.ServiceBus.Message and use this object as the input for the push-outputbinding which will then :
- Use the $message.body value as the contents of the serviceBus message,
- Allow us to set any other $message attributes we need and honor them. For example the custom attribute is of upmost importance:
Import-Module .\modules\Microsoft.Azure.ServiceBus.dll
$Message = New-Object Microsoft.Azure.ServiceBus.Message
$Message.UserProperties.Add("name", "alex")
# Should be able to send the message object out also and not just a string
Push-OutputBinding -Name demooutputSbMsg -Value $Message
Instead, when you call push-outputbinding, the whole $message object is processed as the actual body of the message, making it impossible to set custom attributes
see example:
Any update on this? This makes routing the messages really hard.
Hi I am also facing same issue. please let us know when it iwll be fixed?
This would need to be updated in the Service Bus output binding code as it doesn't look like it currently supports it https://docs.microsoft.com/en-us/azure/azure-functions/functions-bindings-service-bus?tabs=csharp#output
As an alternative, you can import the SDK and create the message and custom properties. I saw a sample on https://github.com/robotechredmond/Azure-PowerShell-Snippets/blob/master/Service%20Bus%20-%20Send%20to%20Queue.ps1 for doing this.
You can get the path to the to the servicebus dll from Split-path (Get-Module -ListAvailable -Name Az.ServiceBus | Select Path).Path
Agreed that this would be very helpful. In addition to routing being difficult, it's also difficult to instrument application insights to track a request as it moves through queues.
I haven't looked at the Push-OutputBinding
code, but seems having Push-OutputBinding
detect a ServiceBus.Message
object type and handles accordingly would be most helpful. Could also add a -ServiceBusMessage
or -Message
parameter in lieu of -Value
or have a objecttype
parameter in the bindings json.
Hi!
Any update on this?
Currently using my own service bus client code for output, but it would be nice to be able to use simple bindings. Service Bus without custom props makes it impossible to do proper pubsub.
Thanks in advance!
also running into this issue. has there been any updates from the team regarding passing userproperties/systemproperties?