Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Query Azure SQL Database using Rest-API

I have a SQL database server in Microsoft Azure. I want to use Azure Rest-API to select some records from a table. When I refer to Azure SQL Database REST API I can't find any section for this purpose, just I can get a DB information, server info or something like this. here is no suitable API to select or update a table. Could you please help me?

like image 363
Sohrab Avatar asked Feb 27 '18 11:02

Sohrab


People also ask

How do I write a SQL query in REST API?

To run a SQL statement through REST, you POST a JSON document that includes the SQL statement to execute against the /api/servers/{alias}/databases/{dbname}/sql URI endpoint.

How do I run a query on Azure SQL Database?

On your SQL database Overview page in the Azure portal, select Query editor (preview) from the left menu. On the sign-in screen, provide credentials to connect to the database. You can connect using SQL authentication or Azure AD.


2 Answers

As mentionned in the article, the Azure SQL Database REST API is designed for the management of the database and the server.

To query a SQL Database with REST queries, you can have a look at ODATA as explained on this post : How to expose Azure Sql Server database using OData.

like image 95
Rom Eh Avatar answered Oct 11 '22 08:10

Rom Eh


I asked this question in Microsoft Azure Forum. The answer is like Rom Eh answer. You can see Microsoft team's answer in the following: You cannot make a query against your database hosted in Azure SQL Database using Azure Resource Manager REST API. The built-in REST API is supported for server and database management. This means you can only perform CRUD at server or database level (e.g. creating a new database, updating some settings). You can use OData as it is supported in Azure SQL Database query.

And related link: https://social.msdn.microsoft.com/Forums/azure/en-US/25d9baa4-2510-4ce4-b857-70a07e4ddea4/query-azure-sql-database-using-restapi?forum=azureapimgmt

like image 29
Sohrab Avatar answered Oct 11 '22 07:10

Sohrab