c# - Using BrokeredMessage with ServiceBus Queue Trigger in Azure Function -


i've created azure function triggered time new message added azure servicebus queue. code works fine:

#r "newtonsoft.json" #load "..\shared\person.csx"  using newtonsoft.json; using newtonsoft.json.serialization;  public static void run(string message, tracewriter log) {     var person = jsonconvert.deserializeobject<person>(message,              new jsonserializersettings() {contractresolver = new camelcasepropertynamescontractresolver()});     log.verbose($"from deserializeobject: {person.firstname} {person.lastname}"); } 

i've seen can bind message poco that:

public static void run(person message, tracewriter log) {     log.verbose($"from deserializeobject: {message.firstname} {message.lastname}"); } 

now bind message brokeredmessage because need have access properties of message.

edit new sdk supports servicebus sdk using #r directive

#r "microsoft.servicebus" using microsoft.servicebus.messaging;  public static void run(brokeredmessage msg, tracewriter log) {     log.info($"c# servicebus queue trigger function processed message: {msg}"); } 

old version

only 2 steps:

i've create project.json file add reference windowsazure.servicebus nuget package (see so post):

{     "frameworks": {         "net46":{             "dependencies": {                 "windowsazure.servicebus": "2.7.6"             }         }     } } 

i've added reference brokered message:

using microsoft.servicebus.messaging;  public static void run(brokeredmessage  message, tracewriter log) {     log.verbose("function has been triggered !!!"); } 

Comments

Popular posts from this blog

Ansible - ERROR! the field 'hosts' is required but was not set -

customize file_field button ruby on rails -

SoapUI on windows 10 - high DPI/4K scaling issue -