@@ -233,12 +233,13 @@ In the body of your algorithm, paste the source code below, replacing the `COLLE
233233
234234``` python
235235import Algorithmia
236-
237- client = Algorithmia.client()
236+ from Algorithmia import ADK
238237
239238def apply (input ):
240- data_uri = " data://COLLECTION_OWNER/COLLECTION_NAME/" + input .get(" filename" )
241- client.file(data_uri).put(input .get(" data" ))
239+ Algorithmia.client().file(" data://COLLECTION_OWNER/COLLECTION_NAME/" + input .get(" filename" )).put(input .get(" data" ))
240+
241+ algorithm = ADK(apply)
242+ algorithm.init(" Algorithmia" )
242243```
243244
244245<img src =" {{site.cdnurl}}{{site.baseurl}}/images/post_images/eventlisteners/algorithmia-web-ide-azure-sb-subscriber.png " >
@@ -326,20 +327,20 @@ In the body of your algorithm, paste the source code below, replacing the `QUEUE
326327
327328``` python
328329import os
330+ import json
329331
330332import Algorithmia
333+ from Algorithmia import ADK
331334from azure.servicebus import ServiceBusClient, ServiceBusMessage
332335
333- CONNECTION_STR = os.getenv( " CONNECTION_STR" )
336+ CONNECTION_STR = " CONNECTION_STR"
334337QUEUE_NAME = " QUEUE_NAME"
335338
336-
337339def send_single_message (sender , message ):
338340 # Send the message to the queue
339341 sender.send_messages(message)
340342 print (" Sent a single message." )
341343
342-
343344def apply (input ):
344345 """ Send a message to the queue.
345346
@@ -348,7 +349,7 @@ def apply(input):
348349 """
349350
350351 # Create a Service Bus message
351- message = ServiceBusMessage(input .get( " data " ))
352+ message = ServiceBusMessage(json.dumps( input ))
352353 # Create a Service Bus client using the connection string
353354 servicebus_client = ServiceBusClient.from_connection_string(
354355 conn_str = CONNECTION_STR ,
@@ -360,6 +361,9 @@ def apply(input):
360361 # Send one message
361362 send_single_message(sender, message)
362363 return " Sent a message to the queue."
364+
365+ algorithm = ADK(apply)
366+ algorithm.init(" Algorithmia" )
363367```
364368
365369Click the ** Save** and ** Build** buttons, and then ** Publish** the algorithm.
0 commit comments