This project is an Azure Function App built with .NET 8 that exposes an HTTP endpoint for running SQL queries against a SQL Server database. It is designed for integration with AI agents or other automated systems.
- HTTP-triggered Azure Function
- Accepts SQL queries via POST requests
- Connects to SQL Server using a connection string from configuration
- Returns query results or error details as JSON
- .NET 8 SDK
- Azure Functions Core Tools
- SQL Server instance
- Clone the repository:
git clone https://github.com/jishnuap/sql-query-runner.git cd sql-query-runner
- Set the SQL Server connection string in
local.settings.json
:{ "IsEncrypted": false, "Values": { "AzureWebJobsStorage": "UseDevelopmentStorage=true", "FUNCTIONS_WORKER_RUNTIME": "dotnet", "SqlConnectionString": "Server=YOUR_SERVER;Database=YOUR_DB;User Id=YOUR_USER;Password=YOUR_PASSWORD;" } }
- Run the function locally:
func start
Send a POST request to the function endpoint with a JSON body:
{
"query": "SELECT TOP 10 * FROM YourTable"
}
Response will be JSON with either results or error details.
Follow Azure Functions deployment documentation to deploy to Azure.
MIT
For more details, see the source code and comments.