page_type | languages | products | name | description | urlFragment | ||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
sample |
|
|
ToDo API backend with Azure SQL bindings |
Implement the ToDo Backend in .NET with Azure SQL bindings for Azure Functions |
todo-backend-dotnet-azure-sql-bindings-azure-functions |
This project implements the Todo Backend API using Azure Functions (.NET) and Azure SQL through HTTP triggers and Azure SQL input/output bindings.
This project implements a ToDo endpoint with the following actions:
- GET all ToDos
- GET a ToDo by Id
- POST a new ToDo
- PATCH an update to a ToDo
- DELETE a ToDo by Id
- DELETE all ToDos
- Configure your development environment for creating Azure Functions with .NET. This VS Code example includes the .NET SDK, Azure Functions Core Tools, and the C# and Azure Functions extensions for VS Code.
- Clone the repository to your environment
- Create an Azure SQL Database and execute the script in /sql/create.sql to create the table and stored procedure used by this example. Optionally the local development can be done against an local database, such as in a Docker container.
This example uses 2 application settings to control either secret or deployment-specific information. During local development, these values are stored in local.settings.json
at the project root.
- Connection string to SQL database (General format) "SqlConnectionString": "Server=tcp:SERVERNAME,PORT;Initial Catalog=DATABASENAME;Persist Security Info=False;User ID=USERNAME;Password=USERPASSWORD;"
- Primary endpoint URL "ToDoUri": "http://localhost:7071/api/ToDo"
Using the REST Client extension for VS Code, the testing.http file provides example requests for the functionality.
The ToDo backend specification has an accompanying runner for tests that validate the functionality. To run these tests on the demo endpoint, go to http://todobackend.com/specs/index.html?https://azuresqltodo.azurewebsites.net/api/ToDo.
The functions runtime and SQL database may have gone idle when you test the link, if you find tests fail retry after a few seconds.