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

hampton123 1,165 Reputation points
2023-08-28T16:47:02.39+00:00

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.
4,899 questions
{count} votes

Accepted answer
  1. MuthuKumaranMurugaachari-MSFT 22,311 Reputation points
    2023-08-29T19:57:59.8033333+00:00

    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 7,120 Reputation points
    2023-08-28T17:07:42.9166667+00:00

    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; https://azure.github.io/awesome-azd/?operator=AND&tags=functions&tags=azuresql

    0 comments No comments

Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.