{"action":"created","issue":{"url":"https://api.github.com/repos/mtth/avsc/issues/93","repository_url":"https://api.github.com/repos/mtth/avsc","labels_url":"https://api.github.com/repos/mtth/avsc/issues/93/labels{/name}","comments_url":"https://api.github.com/repos/mtth/avsc/issues/93/comments","events_url":"https://api.github.com/repos/mtth/avsc/issues/93/events","html_url":"https://github.com/mtth/avsc/issues/93","id":215424967,"number":93,"title":"Error while decoding Avro data with NodeJS","user":{"login":"ArunAdPushup","id":20511680,"avatar_url":"https://avatars2.githubusercontent.com/u/20511680?v=3","gravatar_id":"","url":"https://api.github.com/users/ArunAdPushup","html_url":"https://github.com/ArunAdPushup","followers_url":"https://api.github.com/users/ArunAdPushup/followers","following_url":"https://api.github.com/users/ArunAdPushup/following{/other_user}","gists_url":"https://api.github.com/users/ArunAdPushup/gists{/gist_id}","starred_url":"https://api.github.com/users/ArunAdPushup/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/ArunAdPushup/subscriptions","organizations_url":"https://api.github.com/users/ArunAdPushup/orgs","repos_url":"https://api.github.com/users/ArunAdPushup/repos","events_url":"https://api.github.com/users/ArunAdPushup/events{/privacy}","received_events_url":"https://api.github.com/users/ArunAdPushup/received_events","type":"User","site_admin":false},"labels":[],"state":"closed","locked":false,"assignee":null,"assignees":[],"milestone":null,"comments":5,"created_at":"2017-03-20T13:46:40Z","updated_at":"2017-03-23T14:36:30Z","closed_at":"2017-03-23T14:04:09Z","body":"Hi,\r\n\r\nI am using ``Azure EventHubs archive`` to store my event hubs data to an azure blob storage. Eventhubs archive stores the data in ``avro`` format. I've written an ``Azure function`` in ``NodeJS`` that listens to the blob trigger event (fired whenever data is sent to Eventhubs and written to the blob storage in ``avro`` format). \r\n\r\nI am using the [avsc](https://github.com/mtth/avsc) library for doing this. \r\n\r\nAs soon as the trigger is fired, I want to decode the data sent in ``avro`` format (which is a binary buffer) and convert it into ``json``. \r\nI tried using the ``fromBuffer`` method by specifying my ``avro`` schema, but it keeps giving me this error - \r\n```\r\nTypeError: this.buf.utf8Slice is not a function\r\n```\r\nHere's my code - \r\n\r\n```\r\nconst avro = require('avsc');\r\n\r\nmodule.exports = function (context, myBlob) {\r\n    const schema = avro.Type.forSchema({\r\n        \"type\" : \"record\",\r\n        \"name\" : \"EventData\",\r\n        \"namespace\" : \"Microsoft.ServiceBus.Messaging\",\r\n        \"fields\" : [ {\r\n            \"name\" : \"SequenceNumber\",\r\n            \"type\" : \"long\"\r\n        }, {\r\n            \"name\" : \"Offset\",\r\n            \"type\" : \"string\"\r\n        }, {\r\n            \"name\" : \"EnqueuedTimeUtc\",\r\n            \"type\" : \"string\"\r\n        }, {\r\n            \"name\" : \"SystemProperties\",\r\n            \"type\" : {\r\n            \"type\" : \"map\",\r\n            \"values\" : [ \"long\", \"double\", \"string\", \"bytes\" ]\r\n            }\r\n        }, {\r\n            \"name\" : \"Properties\",\r\n            \"type\" : {\r\n            \"type\" : \"map\",\r\n            \"values\" : [ \"long\", \"double\", \"string\", \"bytes\", \"null\" ]\r\n            }\r\n        }, {\r\n            \"name\" : \"Body\",\r\n            \"type\" : [ \"null\", \"bytes\" ]\r\n        } ]\r\n    });\r\n\r\n    if(myBlob.length){\r\n        context.log(\"JavaScript blob trigger function processed blob \\n Name:\", context.bindingData.name, \"\\n Blob Size:\", myBlob.length, \"Bytes\");\r\n        context.log(schema.fromBuffer(myBlob)); // myBlob contains the binary avro buffer data\r\n    }\r\n    context.done();\r\n};\r\n```"},"comment":{"url":"https://api.github.com/repos/mtth/avsc/issues/comments/288739032","html_url":"https://github.com/mtth/avsc/issues/93#issuecomment-288739032","issue_url":"https://api.github.com/repos/mtth/avsc/issues/93","id":288739032,"user":{"login":"ArunAdPushup","id":20511680,"avatar_url":"https://avatars2.githubusercontent.com/u/20511680?v=3","gravatar_id":"","url":"https://api.github.com/users/ArunAdPushup","html_url":"https://github.com/ArunAdPushup","followers_url":"https://api.github.com/users/ArunAdPushup/followers","following_url":"https://api.github.com/users/ArunAdPushup/following{/other_user}","gists_url":"https://api.github.com/users/ArunAdPushup/gists{/gist_id}","starred_url":"https://api.github.com/users/ArunAdPushup/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/ArunAdPushup/subscriptions","organizations_url":"https://api.github.com/users/ArunAdPushup/orgs","repos_url":"https://api.github.com/users/ArunAdPushup/repos","events_url":"https://api.github.com/users/ArunAdPushup/events{/privacy}","received_events_url":"https://api.github.com/users/ArunAdPushup/received_events","type":"User","site_admin":false},"created_at":"2017-03-23T14:36:30Z","updated_at":"2017-03-23T14:36:30Z","body":"Thanks a lot for the explanation @mtth. "}}
{"actor":{"display_login":"ArunAdPushup"}}