Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/jandev/azurefunctions-sqlbinding
A lightweight project with a MS SQL Server binding for Azure Functions
https://github.com/jandev/azurefunctions-sqlbinding
azure azure-functions sql-server
Last synced: 17 days ago
JSON representation
A lightweight project with a MS SQL Server binding for Azure Functions
- Host: GitHub
- URL: https://github.com/jandev/azurefunctions-sqlbinding
- Owner: Jandev
- License: apache-2.0
- Created: 2019-05-28T08:22:11.000Z (over 5 years ago)
- Default Branch: develop
- Last Pushed: 2024-01-17T08:17:18.000Z (11 months ago)
- Last Synced: 2024-11-07T21:46:30.961Z (about 2 months ago)
- Topics: azure, azure-functions, sql-server
- Language: C#
- Homepage:
- Size: 75.2 KB
- Stars: 4
- Watchers: 4
- Forks: 3
- Open Issues: 2
-
Metadata Files:
- Readme: README.md
- Contributing: contributing.md
- License: LICENSE
Awesome Lists containing this project
README
# Overview
This project is created to provide a simple
Microsoft SQL Server binding for Azure Functions.# Supported features
The following commands are supported as of now.
## Input binding
The input binding can be used as like the following
piece of code.```csharp
[FunctionName(nameof(GetSingleRecord))]
public static IActionResult GetSingleRecord(
[HttpTrigger(AuthorizationLevel.Anonymous, "get", Route = nameof(GetSingleRecord))]
HttpRequest req,
[SqlServer(Query = "SELECT TOP 1 Id, Name, Description FROM MyTable")]
SqlServerModel model)
{
return new OkObjectResult(model.Record.Id);
}[FunctionName(nameof(GetCollectionFromSqlServer))]
public static IActionResult GetCollectionFromSqlServer(
[HttpTrigger(AuthorizationLevel.Anonymous, "get", Route = nameof(GetCollectionFromSqlServer))]
HttpRequest req,
[SqlServer(Query = "SELECT TOP 100 Id, Name, Description FROM MyTable")]
IEnumerable collection)
{
return new OkObjectResult(collection.Select(m => m.Record.Id));
}
```In order for this to work you need a `local.settings.json`
file with a proper connectionstring. If not specified
the default name `SqlServerConnectionString` will be used.```json
{
"IsEncrypted": false,
"Values": {
"AzureWebJobsStorage": "UseDevelopmentStorage=true",
"FUNCTIONS_WORKER_RUNTIME": "dotnet"
},
"ConnectionStrings": {
"SqlServerConnectionString": "Server=(localdb)\\myInstance;Database=MySqlBindingDatabase;Trusted_Connection=True",
"providerName": "System.Data.SqlClient"
}
}
```