Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

AVRO deserialization fails on Service Bus Subscription Trigger to Azure Function #19759

Closed
2 of 6 tasks
aleromano92 opened this issue Jan 10, 2022 · 6 comments
Closed
2 of 6 tasks
Assignees
Labels
Client This issue points to a problem in the data-plane of the library. customer-reported Issues that are reported by GitHub users external to the Azure organization. issue-addressed Workflow: The Azure SDK team believes it to be addressed and ready to close. question The issue doesn't require a change to the product in order to be resolved. Most issues start as that Schema Registry

Comments

@aleromano92
Copy link

aleromano92 commented Jan 10, 2022

  • Package Name: @azure/schema-registry-avro
  • Package Version: 1.0.0-beta.5
  • Operating system: Linux
  • nodejs
    • version: 14
  • browser
    • name/version:
  • typescript
    • version: 3.3.3
  • Is the bug related to documentation in

Describe the bug
We are using Azure Service Bus (topic/subscription) to decouple a producer which is a Java Microservice and a consumer which is a Node/Typescript Azure Function.
The AF is triggered everytime a message arrives on a particular subscription.

Although we are not using Event Hubs, we created one to use the Schema Registry as we want to use AVRO as protocol for the messages exchanged on service bus.

For simple AVRO Message, it works fine by just passing the Uint8Array conversion of the message received:
const received = await serializer.deserialize(new Uint8Array(Buffer.from(serviceBusMessage)));

But with a more complex AVRO message, it seems the byte array produced by the Java application and sent to the service bus is not the same we get when we parse the triggered message.

To Reproduce
Steps to reproduce the behavior:

  1. Create a Java producer which uses Azure SDK to serialize a message using AVRO Generated classes. contentType we set is application/octect-stream (we tried avro/binary with same results, changed it as suggested here )
  2. Under the hood your node library uses avsc
  3. YOu can run the below program which contains
    a. the AVRO Schema as defined on the Schema Registry
    b. arr2 which is the byte array I get from the Java Log of the producer
    c. arr3 which is the byte array I get in my Azure Function using JSON.stringify(Object.values(Buffer.from(serviceBusMessage))
const avro = require('avsc');

const type = avro.Type.forSchema({
    "name": "CompanyDataUpsert",
    "type": "record",
    "fields": [
        {
            "name": "vatNumber",
            "type": "string"
        },
        {
            "name": "businessName",
            "type": ["null", "string"],
            "doc": "Ragione Sociale"
        },
        {
            "name": "fiscalCode",
            "type": ["null", "string"],
            "doc": "Codice Fiscale dell'azienda"
        },
        {
            "name": "cervedSubjectId",
            "type": ["null", "string"],
            "doc": "Codice Soggetto Cerved dell'azienda"
        },
        {
            "name": "certifiedEmails",
            "type": [
                "null",
                {
                    "type": "array",
                    "items": "string"
                }
            ],
            "doc": "PEC aziendlai"
        },
        {
            "name": "websiteURL",
            "type": ["null", "string"],
            "doc": "Sito web aziendale"
        },
        {
            "name": "phoneNumber",
            "type": ["null", "string"],
            "doc": "Telefono fisso sede principale"
        },
        {
            "name": "address",
            "type": [
                "null",
                {
                    "name": "ProviderCompanyAddress",
                    "type": "record",
                    "fields": [
                        {
                            "name": "region",
                            "type": "string",
                            "doc": "Regione sede principale"
                        },
                        {
                            "name": "province",
                            "type": "string",
                            "doc": "Provincia sede principale"
                        },
                        {
                            "name": "municipality",
                            "type": "string",
                            "doc": "Comune sede principale"
                        },
                        {
                            "name": "zipCode",
                            "type": ["null", "string"],
                            "doc": "CAP sede principale"
                        },
                        {
                            "name": "toponym",
                            "type": ["null", "string"],
                            "doc": "Via/Viale/Piazza..."
                        },
                        {
                            "name": "addressName",
                            "type": "string",
                            "doc": "Nome della via/piazza sede principale"
                        },
                        {
                            "name": "addressNumber",
                            "type": "string",
                            "doc": "Numero Civico sede principale"
                        },
                        {
                            "name": "latitude",
                            "type": ["null", "double"],
                            "doc": "Latitudine sede principale"
                        },
                        {
                            "name": "longitude",
                            "type": ["null", "double"],
                            "doc": "Longitudine sede principale"
                        },
                        {
                            "name": "istatMunicipalityCode",
                            "type": ["null", "string"],
                            "doc": "Codice ISTAT Comune sede principale"
                        },
                        {
                            "name": "istatGeographicZone",
                            "type": ["null", "string"],
                            "doc": "Nome della via/piazza sede principale"
                        }
                    ]
                }
            ],
            "doc": "Indirizzo della sede principale dell'azienda"
        },
        {
            "name": "userModifiedAddress",
            "type": [
                "null",
                {
                    "name": "UserCompanyDataAddress",
                    "type": "record",
                    "fields": [
                        {
                            "name": "region",
                            "type": ["null", "string"],
                            "doc": "Regione sede principale"
                        },
                        {
                            "name": "province",
                            "type": ["null", "string"],
                            "doc": "Provincia sede principale"
                        },
                        {
                            "name": "municipality",
                            "type": ["null", "string"],
                            "doc": "Comune sede principale"
                        },
                        {
                            "name": "zipCode",
                            "type": ["null", "string"],
                            "doc": "CAP sede principale"
                        },
                        {
                            "name": "toponym",
                            "type": ["null", "string"],
                            "doc": "Via/Viale/Piazza..."
                        },
                        {
                            "name": "addressName",
                            "type": ["null", "string"],
                            "doc": "Nome della via/piazza sede principale"
                        },
                        {
                            "name": "addressNumber",
                            "type": ["null", "string"],
                            "doc": "Numero Civico sede principale"
                        },
                        {
                            "name": "latitude",
                            "type": ["null", "double"],
                            "doc": "Latitudine sede principale"
                        },
                        {
                            "name": "longitude",
                            "type": ["null", "double"],
                            "doc": "Longitudine sede principale"
                        },
                        {
                            "name": "istatMunicipalityCode",
                            "type": ["null", "string"],
                            "doc": "Codice ISTAT Comune sede principale"
                        },
                        {
                            "name": "istatGeographicZone",
                            "type": ["null", "string"],
                            "doc": "Nome della via/piazza sede principale"
                        }
                    ]
                }
            ],
            "doc": "Indirizzo della sede principale dell'azienda modificata dal cliente"
        },
        {
            "name": "activityStatusCode",
            "type": ["null", "string"],
            "doc": "A=attiva; C=cessata; D=inprocedure; F=fallita; G=amministrazione giudiziaria;I=inattiva; L=in scioglimento/liquidazione; N=in procedura concorsuale; P=iscrizione; R=registrata; S=sospesa; T=cancellata"
        },
        {
            "name": "isOperative",
            "type": ["null", "boolean"],
            "doc": "Flag sintetito che indica status operatività"
        },
        {
            "name": "constitutionDate",
            "type": ["null", "string"],
            "doc": "Data formale atto costitutivo (dd-MM-yyyy)"
        },
        {
            "name": "activityStartDate",
            "type": ["null", "string"],
            "doc": "Data inizio attività (dd-MM-yyyy)"
        },
        {
            "name": "activityEndDate",
            "type": ["null", "string"],
            "doc": "Data fine attività (dd-MM-yyyy)"
        },
        {
            "name": "juridicalNature",
            "type": ["null", "string"],
            "doc": "Natura giuridica"
        },
        {
            "name": "reaCode",
            "type": ["null", "string"],
            "doc": "Codice della Provincia della Camera di Commercio concatenato (tramite spazio singolo) al codice nel Repertorio Economico Amministrativo"
        },
        {
            "name": "reaSubscriptionDate",
            "type": ["null", "string"],
            "doc": "Data di iscrizione nel Repertorio Economico Amministrativo"
        },
        {
            "name": "atecoCode",
            "type": ["null", "string"],
            "doc": "Codice di classificazione dell'attività economica (Codice Ateco ISTAT 2007)"
        },
        {
            "name": "atecoDescription",
            "type": ["null", "string"],
            "doc": "Descrizione del Codice Ateco"
        },
        {
            "name": "atecoMacrosectorCode",
            "type": ["null", "string"],
            "doc": "Codice di classificazione del macrosettore"
        },
        {
            "name": "atecoMacrosectorDescription",
            "type": ["null", "string"],
            "doc": "Descrizione del macrosettore"
        },
        {
            "name": "naceCode",
            "type": ["null", "string"],
            "doc": "Codice di classificazione della nomenclatura delleAttività economiche"
        },
        {
            "name": "naceDeclaration",
            "type": ["null", "string"],
            "doc": "Declaratoria del Codice Nace"
        },
        {
            "name": "naceDescription",
            "type": ["null", "string"],
            "doc": "Descrizione del Codice Nace"
        },
        {
            "name": "naceDeclarationEnglish",
            "type": ["null", "string"],
            "doc": "Declaratoria del Codice Nace in lingua inglese"
        },
        {
            "name": "naceDescriptionEnglish",
            "type": ["null", "string"],
            "doc": "Descrizione del Codice Nace in lingua inglese"
        },
        {
            "name": "sicCodifications",
            "type": [
                "null",
                {
                    "type": "array",
                    "items": {
                        "name": "SicInfo",
                        "type": "record",
                        "fields": [
                            {
                                "name": "sicCode",
                                "type": ["null", "string"],
                                "doc": "Codice SIC"
                            },
                            {
                                "name": "sicDeclarationEnglish",
                                "type": ["null", "string"],
                                "doc": "Declaratoria SIC in inglese"
                            },
                            {
                                "name": "sicDescriptionnEnglish",
                                "type": ["null", "string"],
                                "doc": "Descrizione SIC in inglese"
                            }
                        ]
                    }
                }
            ],
            "doc": "Lista di codifiche SIC"
        },
        {
            "name": "raeCode",
            "type": ["null", "string"],
            "doc": "Codice di classificazione dei rami Attività economiche"
        },
        {
            "name": "raeDeclaration",
            "type": ["null", "string"],
            "doc": "Declaratoria del Codice Rae"
        },
        {
            "name": "saeCode",
            "type": ["null", "string"],
            "doc": "Codice di classificazione dei settori Attività economiche"
        },
        {
            "name": "saeDeclaration",
            "type": ["null", "string"],
            "doc": "Declaratoria del Codice Sae"
        },
        {
            "name": "noREAFormCode",
            "type": ["null", "string"],
            "doc": "Codice della forma del soggetto no REA"
        },
        {
            "name": "noREAFormDescription",
            "type": ["null", "string"],
            "doc": "Descrizione della forma del soggetto no REA"
        },
        {
            "name": "formCode",
            "type": ["null", "string"],
            "doc": "Codice della natura giuridica"
        },
        {
            "name": "formCodeDescription",
            "type": ["null", "string"],
            "doc": "Descirizone della natura giuridica"
        },
        {
            "name": "formClass",
            "type": ["null", "string"],
            "doc": "Codice della classe di natura giuridica del soggetto trovato. Il campo assume come valori possibili i seguenti (valori ammessi SC - Societa di Capitali, SP - Societa di Persone, DI - Ditta Individuale, AL - Altre forme giuridiche"
        },
        {
            "name": "employeesNumber",
            "type": ["null", "int"],
            "doc": "Numero dipendenti"
        },
        {
            "name": "userModifiedEmployeesNumber",
            "type": ["null", "int"],
            "doc": "Numero dipendenti inseriti dal cliente"
        },
        {
            "name": "officesNumber",
            "type": ["null", "int"],
            "doc": "Numero delle sedi dell'attività"
        },
        {
            "name": "lastBalanceClosingDate",
            "type": ["null", "string"],
            "doc": "Data di chiusura dell'ultimo bilancio dell'attività (dd-MM-yyyy)"
        },
        {
            "name": "billing",
            "type": ["null", "int"],
            "doc": "Fatturato in Euro dell'ultimo bilancio (da moltiplicare x 1000 in fase di Produzione messaggio se letto da Cerved)"
        },
        {
            "name": "userModifiedBilling",
            "type": ["null", "int"],
            "doc": "Fatturato in Euro dell'ultimo bilancio inserito dal cliente)"
        },
        {
            "name": "shareCapital",
            "type": ["null", "int"],
            "doc": "Capitale sociale in Euro dell'ultimo bilancio"
        },
        {
            "name": "shareCapitalType",
            "type": ["null", "string"],
            "doc": "Tipologia di Capitale sociale in Euro dell'ultimo bilancio"
        },
        {
            "name": "grossProfit",
            "type": ["null", "int"],
            "doc": "Margine Operativo Lordo dell'ultimo bilancio (da moltiplicare x 1000 in fase di Produzione messaggio se letto da Cerved)"
        },
        {
            "name": "assets",
            "type": ["null", "int"],
            "doc": "Attivo dello Stato Patrimoniale dell'ultimo bilancio (da moltiplicare x 1000 in fase di Produzione messaggio se letto da Cerved)"
        },
        {
            "name": "netWorth",
            "type": ["null", "int"],
            "doc": "Patrimonio netto dell'ultimo bilancio (da moltiplicare x 1000 in fase di Produzione messaggio se letto da Cerved)"
        },
        {
            "name": "profitLoss",
            "type": ["null", "int"],
            "doc": "Utile/perdita dell'esercizio (da moltiplicare x 1000 in fase di Produzione messaggio se letto da Cerved)"
        },
        {
            "name": "referenceTimestamp",
            "type": "string",
            "doc": "Il timestamp del momento in cui è avvenuto l'evento che ha scatentato il messaggio in formato UTC (yyyy-MM-ddThh:mm:ssZ) es: 2021-12-16T14:00:31Z"
        }
    ]
});

const arr2 = [0, 0, 0, 0, 56, 53, 57, 49, 52, 99, 48, 99, 55, 52, 52, 52, 52, 52, 57, 51, 98, 49, 100, 49, 50, 54, 53, 53, 53, 56, 101, 53, 100, 101, 57, 53, 22, 48, 51, 50, 56, 49, 55, 53, 48, 49, 50, 57, 2, 24, 82, 85, 83, 83, 79, 32, 77, 65, 84, 84, 69, 79, 2, 32, 82, 83, 83, 77, 84, 84, 57, 50, 69, 49, 50, 76, 54, 56, 50, 69, 2, 18, 51, 54, 49, 51, 48, 54, 52, 53, 57, 2, 2, 54, 114, 117, 115, 115, 111, 109, 97, 116, 116, 101, 111, 46, 103, 105, 97, 114, 100, 105, 110, 105, 64, 112, 101, 99, 46, 105, 116, 0, 0, 0, 2, 18, 76, 111, 109, 98, 97, 114, 100, 105, 97, 4, 86, 65, 32, 67, 65, 82, 79, 78, 78, 79, 32, 86, 65, 82, 69, 83, 73, 78, 79, 2, 10, 50, 49, 48, 52, 48, 2, 6, 86, 73, 65, 28, 70, 73, 76, 73, 80, 80, 79, 32, 84, 85, 82, 65, 84, 73, 2, 57, 2, -90, 39, 44, -15, -128, -34, 70, 64, 2, -46, -116, 69, -45, -39, -87, 33, 64, 2, 12, 48, 49, 50, 48, 51, 53, 2, 20, 78, 111, 114, 100, 45, 111, 118, 101, 115, 116, 0, 2, 12, 65, 84, 84, 73, 86, 65, 2, 1, 2, 20, 49, 53, 45, 48, 51, 45, 50, 48, 49, 50, 2, 20, 49, 53, 45, 48, 51, 45, 50, 48, 49, 50, 0, 2, 38, 73, 77, 80, 82, 69, 83, 65, 32, 73, 78, 68, 73, 86, 73, 68, 85, 65, 76, 69, 2, 18, 86, 65, 32, 51, 51, 56, 49, 56, 51, 2, 20, 50, 48, 45, 48, 51, 45, 50, 48, 49, 50, 2, 6, 56, 49, 51, 2, -118, 1, 67, 117, 114, 97, 32, 101, 32, 109, 97, 110, 117, 116, 101, 110, 122, 105, 111, 110, 101, 32, 100, 101, 108, 32, 112, 97, 101, 115, 97, 103, 103, 105, 111, 32, 40, 105, 110, 99, 108, 117, 115, 105, 32, 112, 97, 114, 99, 104, 105, 44, 32, 103, 105, 97, 114, 100, 105, 110, 105, 32, 101, 32, 97, 105, 117, 111, 108, 101, 41, 0, 0, 2, 8, 56, 49, 46, 51, 2, 98, 65, 84, 84, 73, 86, 73, 84, 65, 39, 32, 65, 77, 77, 73, 78, 73, 83, 84, 82, 65, 84, 73, 86, 69, 32, 69, 32, 68, 73, 32, 83, 69, 82, 86, 73, 90, 73, 32, 68, 73, 32, 83, 85, 80, 80, 79, 82, 84, 79, 2, 78, 65, 116, 116, 105, 118, 105, 116, 97, 39, 32, 100, 105, 32, 115, 105, 115, 116, 101, 109, 97, 122, 105, 111, 110, 101, 32, 100, 101, 108, 32, 112, 97, 101, 115, 97, 103, 103, 105, 111, 2, 90, 65, 68, 77, 73, 78, 73, 83, 84, 82, 65, 84, 73, 86, 69, 32, 65, 78, 68, 32, 83, 85, 80, 80, 79, 82, 84, 32, 83, 69, 82, 86, 73, 67, 69, 32, 65, 67, 84, 73, 86, 73, 84, 73, 69, 83, 2, 56, 76, 97, 110, 100, 115, 99, 97, 112, 101, 32, 115, 101, 114, 118, 105, 99, 101, 32, 97, 99, 116, 105, 118, 105, 116, 105, 101, 115, 2, 2, 2, 8, 48, 55, 56, 50, 2, 68, 65, 103, 114, 105, 99, 117, 108, 116, 117, 114, 101, 44, 32, 70, 111, 114, 101, 115, 116, 114, 121, 44, 32, 65, 110, 100, 32, 70, 105, 115, 104, 105, 110, 103, 2, 48, 76, 97, 119, 110, 32, 97, 110, 100, 32, 71, 97, 114, 100, 101, 110, 32, 83, 101, 114, 118, 105, 99, 101, 115, 0, 0, 0, 0, 0, 0, 0, 0, 0, 2, 4, 68, 73, 2, 2, 0, 0, 0, 0, 0, 2, -96, 31, 0, 0, 0, 0, 0, 40, 50, 48, 50, 50, 45, 48, 49, 45, 49, 48, 84, 49, 55, 58, 48, 50, 58, 49, 54, 90]
const arr3 = [0, 0, 0, 0, 56, 53, 57, 49, 52, 99, 48, 99, 55, 52, 52, 52, 52, 52, 57, 51, 98, 49, 100, 49, 50, 54, 53, 53, 53, 56, 101, 53, 100, 101, 57, 53, 22, 48, 51, 50, 56, 49, 55, 53, 48, 49, 50, 57, 2, 24, 82, 85, 83, 83, 79, 32, 77, 65, 84, 84, 69, 79, 2, 32, 82, 83, 83, 77, 84, 84, 57, 50, 69, 49, 50, 76, 54, 56, 50, 69, 2, 18, 51, 54, 49, 51, 48, 54, 52, 53, 57, 2, 2, 54, 114, 117, 115, 115, 111, 109, 97, 116, 116, 101, 111, 46, 103, 105, 97, 114, 100, 105, 110, 105, 64, 112, 101, 99, 46, 105, 116, 0, 0, 0, 2, 18, 76, 111, 109, 98, 97, 114, 100, 105, 97, 4, 86, 65, 32, 67, 65, 82, 79, 78, 78, 79, 32, 86, 65, 82, 69, 83, 73, 78, 79, 2, 10, 50, 49, 48, 52, 48, 2, 6, 86, 73, 65, 28, 70, 73, 76, 73, 80, 80, 79, 32, 84, 85, 82, 65, 84, 73, 2, 57, 2, 239, 191, 189, 39, 44, 239, 191, 189, 239, 191, 189, 70, 64, 2, 210, 140, 69, 239, 191, 189, 217, 169, 33, 64, 2, 12, 48, 49, 50, 48, 51, 53, 2, 20, 78, 111, 114, 100, 45, 111, 118, 101, 115, 116, 0, 2, 12, 65, 84, 84, 73, 86, 65, 2, 1, 2, 20, 49, 53, 45, 48, 51, 45, 50, 48, 49, 50, 2, 20, 49, 53, 45, 48, 51, 45, 50, 48, 49, 50, 0, 2, 38, 73, 77, 80, 82, 69, 83, 65, 32, 73, 78, 68, 73, 86, 73, 68, 85, 65, 76, 69, 2, 18, 86, 65, 32, 51, 51, 56, 49, 56, 51, 2, 20, 50, 48, 45, 48, 51, 45, 50, 48, 49, 50, 2, 6, 56, 49, 51, 2, 239, 191, 189, 1, 67, 117, 114, 97, 32, 101, 32, 109, 97, 110, 117, 116, 101, 110, 122, 105, 111, 110, 101, 32, 100, 101, 108, 32, 112, 97, 101, 115, 97, 103, 103, 105, 111, 32, 40, 105, 110, 99, 108, 117, 115, 105, 32, 112, 97, 114, 99, 104, 105, 44, 32, 103, 105, 97, 114, 100, 105, 110, 105, 32, 101, 32, 97, 105, 117, 111, 108, 101, 41, 0, 0, 2, 8, 56, 49, 46, 51, 2, 98, 65, 84, 84, 73, 86, 73, 84, 65, 39, 32, 65, 77, 77, 73, 78, 73, 83, 84, 82, 65, 84, 73, 86, 69, 32, 69, 32, 68, 73, 32, 83, 69, 82, 86, 73, 90, 73, 32, 68, 73, 32, 83, 85, 80, 80, 79, 82, 84, 79, 2, 78, 65, 116, 116, 105, 118, 105, 116, 97, 39, 32, 100, 105, 32, 115, 105, 115, 116, 101, 109, 97, 122, 105, 111, 110, 101, 32, 100, 101, 108, 32, 112, 97, 101, 115, 97, 103, 103, 105, 111, 2, 90, 65, 68, 77, 73, 78, 73, 83, 84, 82, 65, 84, 73, 86, 69, 32, 65, 78, 68, 32, 83, 85, 80, 80, 79, 82, 84, 32, 83, 69, 82, 86, 73, 67, 69, 32, 65, 67, 84, 73, 86, 73, 84, 73, 69, 83, 2, 56, 76, 97, 110, 100, 115, 99, 97, 112, 101, 32, 115, 101, 114, 118, 105, 99, 101, 32, 97, 99, 116, 105, 118, 105, 116, 105, 101, 115, 2, 2, 2, 8, 48, 55, 56, 50, 2, 68, 65, 103, 114, 105, 99, 117, 108, 116, 117, 114, 101, 44, 32, 70, 111, 114, 101, 115, 116, 114, 121, 44, 32, 65, 110, 100, 32, 70, 105, 115, 104, 105, 110, 103, 2, 48, 76, 97, 119, 110, 32, 97, 110, 100, 32, 71, 97, 114, 100, 101, 110, 32, 83, 101, 114, 118, 105, 99, 101, 115, 0, 0, 0, 0, 0, 0, 0, 0, 0, 2, 4, 68, 73, 2, 2, 0, 0, 0, 0, 0, 2, 239, 191, 189, 31, 0, 0, 0, 0, 0, 40, 50, 48, 50, 50, 45, 48, 49, 45, 49, 48, 84, 49, 55, 58, 48, 57, 58, 49, 48, 90]

const buf2 = Buffer.from(arr2);
const buf3 = Buffer.from(arr3);

console.log(type.fromBuffer(buf2.slice(36))); // Works.
console.log(type.fromBuffer(buf3.slice(36))); // Works.

Expected behavior
arr3 should be equal to arr2 and be correctly parsed.
Arr2 is correctly parsed, it seems the Serivce Bus is doing something wrong with the message before invoking the Azure Function.

Screenshots
correctly parsed arr2
error on arr3

Additional context

This is the Azure Function code

const serviceBusTopicTrigger: AzureFunction = async function (context: Context, mySbMsg: any): Promise<void> {

    context.log('*** COMPANY_DATA INGESTION START');

    const { received, schemaName } = await deserializeAVROMessage(context, mySbMsg);

    context.log('*** COMPANY_DATA DESERIALIZATION COMPLETE');

    await writeJSONToStorage(schemaName, context, received, 'company-data');

    context.log('*** COMPANY_DATA INGESTION END');
};

This is the parsing code:

export const deserializeAVROMessage = async (context: Context, serviceBusMessage: any) => {

    const client = new SchemaRegistryClient(
        process.env.AVRO_SCHEMA_REGISTRY_FQDN,
        new ClientSecretCredential(
            process.env.AZURE_TENANT_ID,
            process.env.AVRO_SCHEMA_REGISTRY_CLIENT_ID,
            process.env.AVRO_SCHEMA_REGISTRY_CLIENT_SECRET,
        )
    );

    const serializer = new SchemaRegistryAvroSerializer(client, { groupName: 'ALL_AVRO_SCHEMA' });

    context.log('Schema Registry Serializer obtained.');

    context.log(context.bindingData.contentType);
    context.log(JSON.stringify(Object.values(Buffer.from(serviceBusMessage))))
    const received = await serializer.deserialize(new Uint8Array(Buffer.from(serviceBusMessage)));

    context.log('AVRO Message deserialized.');

    // const objSchemaId: string[] = []
    // Object.values<number>(secondo).slice(4, 36).forEach(item => objSchemaId.push(String.fromCharCode(item)));
    // const schemaId = objSchemaId.join('');
    // const schemaInfo = await client.getSchema(schemaId);
    // const schemaDefinition = JSON.parse(schemaInfo.definition)
    // const schemaName = schemaDefinition.name

    // context.log('AVRO Message obtained is: ', schemaName);

    return { received, schemaName: 'ciaone' }
};

Already asked help to avsc maintainer with helped me but no luck in solving it: mtth/avsc#376

Thanks a lot

@ghost ghost added needs-triage Workflow: This is a new issue that needs to be triaged to the appropriate team. customer-reported Issues that are reported by GitHub users external to the Azure organization. question The issue doesn't require a change to the product in order to be resolved. Most issues start as that labels Jan 10, 2022
@aleromano92
Copy link
Author

If anyone is still suffering from passing binary data to Azure triggered Functions, you need to add this parameter...

{
  "bindings": [
    {
      "name": "mySbMsg",
      "type": "serviceBusTrigger",
+     "dataType": "binary",
      "direction": "in",
      "topicName": "%TOPIC_NAME%",
      "subscriptionName": "%ONBOARDING_DATA_SUBSCRIPTION_NAME%",
      "connection": "SERVICEBUS_CONNECTION_STRING"
    }
  ],
  "scriptFile": "../dist/OnboardingDataTrigger/index.js"
}

I think the documentation here https://docs.microsoft.com/en-us/azure/azure-functions/functions-bindings-service-bus-trigger?tabs=javascript#configuration should be improved to document this field.

Thanks

@ramya-rao-a ramya-rao-a added Client This issue points to a problem in the data-plane of the library. Schema Registry labels Feb 4, 2022
@ghost ghost removed the needs-triage Workflow: This is a new issue that needs to be triaged to the appropriate team. label Feb 4, 2022
@deyaaeldeen
Copy link
Member

@Axel92Dev Thanks for your report! Do I understand correctly that this is no longer an issue based on your comment in #19759 (comment)?

@aleromano92
Copy link
Author

@Axel92Dev Thanks for your report! Do I understand correctly that this is no longer an issue based on your comment in #19759 (comment)?

Yes, it is not a problem for me anymore. But if you don't add this information in your docs, the next developer who tries to pass binary data on service bus will struggle for days.

Thanks

@deyaaeldeen deyaaeldeen added the issue-addressed Workflow: The Azure SDK team believes it to be addressed and ready to close. label Jan 5, 2023
@ghost
Copy link

ghost commented Jan 5, 2023

Hi @Axel92Dev. Thank you for opening this issue and giving us the opportunity to assist. We believe that this has been addressed. If you feel that further discussion is needed, please add a comment with the text “/unresolve” to remove the “issue-addressed” label and continue the conversation.

@lilyjma
Copy link
Contributor

lilyjma commented Jan 6, 2023

Thanks for the feedback @Axel92Dev ! cc @shreyabatra4

@ghost
Copy link

ghost commented Jan 13, 2023

Hi @Axel92Dev, since you haven’t asked that we “/unresolve” the issue, we’ll close this out. If you believe further discussion is needed, please add a comment “/unresolve” to reopen the issue.

@ghost ghost closed this as completed Jan 13, 2023
@github-actions github-actions bot locked and limited conversation to collaborators Apr 13, 2023
This issue was closed.
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Client This issue points to a problem in the data-plane of the library. customer-reported Issues that are reported by GitHub users external to the Azure organization. issue-addressed Workflow: The Azure SDK team believes it to be addressed and ready to close. question The issue doesn't require a change to the product in order to be resolved. Most issues start as that Schema Registry
Projects
None yet
Development

No branches or pull requests

4 participants