Azure SQL has native JSON support which is a key factor to simplify a lot — and make developer-friendly — the interaction between the database and any service that needs to handle data in even the most exotic way.

As depicted in the image above, JSON can be passed as-is and with just one line of code can be sent to Azure SQL where it can processed and returned in a JSON format. I’m using Python in this sample but really, no matter which language you are using for your project, the workflow is the same. And the result is that, as a developer, you won’t see any recordset or anything that resemble a tabular structure in any way. Just JSON, that can easily be serialized and de-serialized into an object for maximum convenience and easiness of development. Or just kept as a JSON document if you prefer.

All the heavy lifting, in fact, is done by Azure SQL for you thanks to functions like JSON_VALUE and FOR JSON.

JSON in Azure SQL

To make things even easier, Python has an amazing framework named Flask that make the creation of REST API pretty simple. But there’s even more. Flask has an extension on its own to make that process even easier. You just have to create your class with a method for each verb you wan to support. Impressive, really. Here’s the two libraries you have to use:

You can find a full explanation along with the source code (hosted on GitHub) and al the details to deploy the solution in Azure. You’ll be able to create and deploy your API in less than 5 minutes!

#azure sql #python #api #flask #json #rest

Architecting REST API with Python, Flask and Azure SQL
11.35 GEEK