2017-10-10 10 views
2

I結合サービスバス(トピック)出力を持っているPythonで書かれたAzureの機能を持っています。この関数は別のキューによってトリガされ、Blobストレージからいくつかのファイルを処理し、別のメッセージをキューに入れます。Azureの機能 - Pythonの - ServiceBus出力は、バインディング - カスタムプロパティの設定

マイfunction.jsonファイルは以下のようになります。私の機能で

{ 
"bindings": [ 
    { 
    "type": "serviceBus", 
    "connection": "Omnibus_Input_Send_Servicebus", 
    "name": "outputMessage", 
    "queueName": "validation-output-queue", 
    "accessRights": "send", 
    "direction": "out" 
    } 
], 
"disabled": false 
} 

が、私はそのような別のキューにメッセージを送ることができます:それは正常に動作している

with open(os.environ['outputMessage'], 'w') as output_message: 
    output_message.write('This is my output test message !') 

。今私はトピックにメッセージを送信したいと思います。私はSQLFilterとサブスクリプションを作成していると私はBrokeredMessageにいくつかのカスタムプロパティを設定する必要があります。 azure sdk for pythonから

、私は(私はピップを使用して紺碧のモジュールをインストールした)そのようにカスタムプロパティを追加できることを発見しました:

from azure.servicebus import Message 
sent_msg = Message(b'This is the third message', 
    broker_properties={'Label': 'M3'}, 
    custom_properties={'Priority': 'Medium', 
         'Customer': 'ABC'} 
) 

私の新しいfunction.jsonファイルは以下のようになります。

{ 
"bindings": [ 
    { 
    "type": "serviceBus", 
    "connection": "Omnibus_Input_Send_Servicebus", 
    "name": "outputMessage", 
    "topicName": "validation-output-topic", 
    "accessRights": "send", 
    "direction": "out" 
    } 
], 
"disabled": false 
} 

そして私はそのように私の機能を変更しました:私は実行すると

from azure.servicebus import Message 
sent_msg = Message(b'This is the third message', 
    broker_properties={'Label': 'M3'}, 
    custom_properties={'Priority': 'Medium', 
         'Customer': 'ABC'} 
) 

with open(os.environ['outputMessage'], 'w') as output_message: 
    output_message.write(sent_msg) 

実際の結合がどのように対処するBrokeredMessageとをサポートしている場合

TypeError: cannot make memory view because object does not have the buffer interface

私は疑問に思って:

TypeError: expected a string or other character buffer object

は、私がbuffermemoryview機能を使用しますが、まだ別の例外を取得しようとしました:機能、私はこの例外を取得しますそれと ? Pythonの(および他のスクリプト言語)のための結合

+0

あなたは試してみました申し訳ありません –

+0

[broker_propertiesは= '{ "ForcePersistence": "マイラベル":偽、 "ラベル"}' sent_msg =メッセージ(b'receiveメッセージ」、 broker_propertiesの=のbroker_properties を)]それは将来実現される予定ですか? git repoで問題を開くべきですか? – Thomas

答えて

1

ServiceBus出力は、指定した文字列が舞台裏で作成したBrokeredMessageの内容となり、単純な文字列のマッピングをサポートしています。すべての拡張プロパティを設定したり、より洗練された何かを行うには、あなたの関数にAzureのPythonのSDKを自分で使用してドロップダウンする必要があります。

+0

を働いていない – Thomas

+0

入力バインディングと同じですか?仲介メッセージにPythonでアクセスできますか? – Thomas

関連する問題