Giter Site home page Giter Site logo

pjontir / azure-functions-sql-extension Goto Github PK

View Code? Open in Web Editor NEW

This project forked from azure/azure-functions-sql-extension

0.0 0.0 0.0 8.95 MB

Azure SQL bindings for Azure Functions ⚡️ supports Azure SQL Database, Azure SQL Managed Instance, and SQL Server 2016+

Home Page: https://aka.ms/sqlbindings

License: MIT License

JavaScript 0.98% Python 1.45% Java 5.13% C# 90.55% PowerShell 1.89%

azure-functions-sql-extension's Introduction

Azure SQL bindings for Azure Functions - Preview

Table of Contents

Introduction

This repository contains the Azure SQL bindings for Azure Functions extension code as well as a quick start tutorial and samples illustrating how to use the binding in different ways. The types of bindings supported are:

  • Input Binding: takes a SQL query or stored procedure to run and returns the output to the function.
  • Output Binding: takes a list of rows and upserts them into the user table (i.e. If a row doesn't already exist, it is added. If it does, it is updated).
  • Trigger Binding: monitors the user table for changes (i.e., row inserts, updates, and deletes) and invokes the function with updated rows.

For a more detailed overview of the different types of bindings see the Bindings Overview.

For further details on setup, usage and samples of the bindings see the language-specific guides below:

Further information on the Azure SQL binding for Azure Functions is also available in the docs.

Supported SQL Server Versions

This extension uses the OPENJSON statement which requires a database compatibility level of 130 or higher (2016 or higher). To view or change the compatibility level of your database, see this documentation article for more information.

Databases on SQL Server, Azure SQL Database, or Azure SQL Managed Instance which meet the compatibility level requirement above are supported.

Known Issues

  • The table used by a SQL binding or SQL trigger cannot contain two columns that only differ by casing (Ex. 'Name' and 'name').
  • Non-CSharp functions using SQL bindings against tables with columns of data types BINARY or VARBINARY need to map those columns to a string type. Input bindings will return the binary value as a base64 encoded string. Output bindings require the value upserted to binary columns to be a base64 encoded string.
  • SQL bindings against tables with columns of data types GEOMETRY and GEOGRAPHY are not supported. Issue is tracked here.

Output Bindings

  • Output bindings against tables with columns of data types NTEXT, TEXT, or IMAGE are not supported and data upserts will fail. These types will be removed in a future version of SQL Server and are not compatible with the OPENJSON function used by this Azure Functions binding.

  • .NET In-Proc output bindings against tables with columns of data types DATE, DATETIME, DATETIME2, DATETIMEOFFSET, or SMALLDATETIME will convert values for those columns to ISO8061 format ("yyyy'-'MM'-'dd'T'HH':'mm':'ss'.'fffZ") before upsertion. This does not happen for functions written in C# out-of-proc or other languages.

  • Output bindings execution order is not deterministic (azure-webjobs-sdk#1025) and so the order that data is upserted is not guaranteed. This can be problematic if, for example, you upsert rows to two separate tables with one having a foreign key reference to another. The upsert will fail if the dependent table does its upsert first.

    Some options for working around this :

    • Have multiple functions, with dependent functions being triggered by the initial functions (through a trigger binding or other such method)
    • Use dynamic (imperative) bindings (.NET only)
    • Use IAsyncCollector and call FlushAsync in the order desired (.NET only)
  • For PowerShell Functions that use hashtables must use the [ordered]@ for the request query or request body assertion in order to upsert the data to the SQL table properly. An example can be found here.

  • Java, PowerShell, and Python Functions using Output bindings cannot pass in null or empty values via the query string.

    • Java: Issue is tracked here.
    • PowerShell: The workaround is to use the $TriggerMetadata[$keyName] to retrieve the query property - an example can be found here. Issue is tracked here.
    • Python: The workaround is to use parse_qs - an example can be found here. Issue is tracked here.

Trigger Bindings

  • Trigger bindings will exhibit undefined behavior if the SQL table schema gets modified while the user application is running, for example, if a column is added, renamed or deleted or if the primary key is modified or deleted. In such cases, restarting the application should help resolve any errors.

Telemetry

This extension collect usage data in order to help us improve your experience. The data is anonymous and doesn't include any personal information. You can opt-out of telemetry by setting the AZUREFUNCTIONS_SQLBINDINGS_TELEMETRY_OPTOUT environment variable or the AzureFunctionsSqlBindingsTelemetryOptOut app setting (in your *.settings.json file) to '1', 'true' or 'yes';

Trademarks

This project may contain trademarks or logos for projects, products, or services. Authorized use of Microsoft trademarks or logos is subject to and must follow Microsoft’s Trademark & Brand Guidelines. Use of Microsoft trademarks or logos in modified versions of this project must not cause confusion or imply Microsoft sponsorship. Any use of third-party trademarks or logos are subject to those third-party’s policies.

azure-functions-sql-extension's People

Contributors

charles-gagnon avatar lucyzhang929 avatar vasubhog avatar maddydev avatar jatinsanghvi avatar chlafreniere avatar sophiatev avatar glennamanns avatar ameyarele avatar dzsquared avatar zijchen avatar yorek avatar microsoftopensource avatar cgillum avatar anthonychu avatar apmurali avatar microsoft-github-operations[bot] avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.