Search code examples
c#azureazure-functionsazure-table-storage

How to send an azure queued message to an azure sql database


I have set up an ASP.NET C# application that sends information to an azure storage account queue. Next l need to send the message text from within the queue to an azure sql database via means of a function. Format of the message text is as follows:

Id:VaccinationCenter:VaccinationDate:VaccineSerialNumber

E.g. 010203040506:Dubai:01/01/2002:AASB44

The table is created within Azure Database and contains the following columns: ID, Vaccination_Centre, Vaccination_Date, Vaccine_Serial_Number Any ideas how to achive this? Thanks


Solution

  • As @Scott Mildenberger commented we can alternatively use Azure Logic Apps to perform your requirement as below: Firstly, I have created a service bus queue as below:

    enter image description here

    Then create Logic App Then inside the workflow of the Logic App: Firstly, create a trigger when a new message comes inside the service bus queue as below: enter image description here

    The the queue messafe to string using base64ToString(triggerBody()?['ContentData']) as below:

    enter image description here

    Then split the queue message using split(variables('emo'),':') as below:

    enter image description here

    Then you can message to Sql Databse table using (Sql connector) create row as below:

    enter image description here

    enter image description here

    For id its variables('div')[0] VaccinationCenter its variables('div')[1] vaccinationdate its variables('div')[2] and VaccineSerialNumber it is variables('div')[3]

    Then now send the message in Service bus queue as below:

    enter image description here

    Now time to check the run result:

    enter image description here

    enter image description here

    enter image description here

    Now its also in Sql database table:

    enter image description here

    If you follow this process, you will get your row inserted as mine got inserted.