Azure recently announced the public preview of Azure SQL trigger for Azure Functions to build event-driven applications. The new functionality is currently available only for C# functions and can be triggered by changes to an Azure SQL table.
The Azure SQL trigger uses the SQL change tracking functionality to monitor a table for changes and triggers an Azure function when a row is created, updated, or deleted. Drew Skwiers-Koballa, senior program manager at Microsoft, writes:
Change tracking is available for Azure SQL Database, Azure SQL Managed Instance, and SQL Server, making the Azure SQL trigger for Azure Functions a flexible component for event-driven applications.
The C# library uses the SqlTrigger attribute to declare the SQL trigger on the function and supports authentication options such as managed identity. A table name (TableName) and a connection string (ConnectionStringSetting) for the SQL database are stored in the application settings of the function. The Sql_Trigger_BatchSize, Sql_Trigger_PollingIntervalMs, and Sql_Trigger_MaxChangesPerWorker are optional settings for the SQL trigger.
Source: https://learn.microsoft.com/en-us/azure/azure-functions/functions-bindings-azure-sql-trigger?tabs=in-process%2Cportal&pivots=programming-language-csharp
Gaurav Prakash, engineering lead at Gartner, questions the support for C# only:
That's a bit weird to me. If an event fires an Azure function, it should not care about the function's runtime. That is how Lambda functions on AWS work. Good to know support for the rest of the languages is in the works.
Isaac Abraham, author of "Get Programming with F#", tweets:
Just saw that Azure Functions is soon going to have bindings for SQL triggers. I can only begin to imagine how this is going to be abused and lead to terrible coupling.
While some developers asked for the capability in the past, others agree that the lack of an event bus could be a risk. Sean Feldman, owner of Highco Consulting and Azure MVP, suggests:
Eliminating timed batch jobs with Azure SQL trigger for Azure Functions?
SQL triggers are not the only way to connect a database with a serverless function: with Azure SQL bindings, data can be input from a database to the function (with an input binding) or can be output from the function to the database (with an output binding). Skwiers-Koballa adds:
Support for Java and PowerShell has been added to the existing public preview for Azure SQL bindings for Azure Functions, which now supports C#, JavaScript, Python, Java, and PowerShell.
Separately the cloud provider announced the public preview of external REST endpoints integration, the ability to call a REST endpoint natively from an Azure SQL database.
Azure SQL is not the only database supporting the feature. Azure functions can be triggered from CosmosDB and other cloud providers integrate as well triggers from relational databases to FaaS. AWS supports invoking a Lambda function from an Aurora MySQL or PostgreSQL database cluster and RDS for PostgreSQL.
Examples of how to use the new functionality on Azure are available in a GitHub repository. The Azure SQL trigger is currently in public preview and only supported on premium and dedicated plans.