How to present SQL Database data in browser using Azure Function in APIM

Hunter B 745 Reputation points

I'm currently working on a company project and although I'm a little bit familiar with using APIM, Azure Functions, and Azure AD B2C, I am not as familiar with using SQL databases with them. My specific question involves presenting SQL data. How would I go about presenting data in an SQL database in browser using an Azure Function hosted in APIM, in JSON format? I was considering using Sequelize but I wasn't 100% sure if this was the way to go. Currently I have an APIM instance with Azure Functions using a SPA - I used this link as a guide, and it's all I have so far with the API itself. Thank you in advance!

Azure SQL Database
Azure Functions
Azure Functions
An Azure service that provides an event-driven serverless compute platform.
3,465 questions
{count} votes

Accepted answer
  1. MuthuKumaranMurugaachari-MSFT 16,216 Reputation points

    Hunter B Here are the steps you can follow for your scenario:

    1. Create a HTTP-triggered function in your function app to receive the data via query parameters (or request body).
    2. Use Input binding to get the data from SQL database (Azure SQL input binding) and return data as JSON object to the client app. Here is the sample reference HTTP trigger, get row by ID from query string and more samples/full code snippet are available in InputBindingSamples.

    Alternatively, you can also use Microsoft.Data.SqlClient library instead of extension. I hope this helps and let me know if any questions.

    1 person found this answer helpful.

1 additional answer

Sort by: Most helpful
  1. AirGordon 6,065 Reputation points

    It's usually best to start with how your front end wants the data. Usually yes, JSON is pretty standard. Your Azure function will act as the translation layer for building up the DTO.

    For inspiration, have a look at the Developer CLI templates which combine application & infrastructure code for full app deployment pattern examples;

    0 comments No comments