Azure Functions and Azure SQL Database
    • Dark
      Light
    • PDF

    Azure Functions and Azure SQL Database

    • Dark
      Light
    • PDF

    Article Summary

    #ServerlessTips - Azure Functions
    Author: Steef-Jan Wiggers Azure MVP

    Bindings in Azure Functions are extensions, which abstract away the connectivity and retrieving input or pushing output into Azure services like Storage, Service Bus and Cosmos DB. Microsoft provides several of these bindings themselves, or you can build your custom binding.

    Alternatively, you can build up the connection to an Azure service yourself such as SQL Azure database and retrieve- or push data. You can use the connection string in Function App settings, and retrieve the actual string from KeyVault, import the SqlClient library from NuGet and start coding your function.

    Azure Function and Azure SQL database

    The above code shows how you could insert a value into a table using the connection string from the settings in the SqlConnection object and using an instance of that object with the SqlCommand. The execution of the code results in an inserted row in the SQL table in SQL Azure.

    Azure Function and Azure SQL database -2

    The Microsoft docs explain a similar scenario with Azure Functions and SQL Azure, which you also can explore. Eventually, you as a developer can make a trade off if you want to code a custom binding if there’s no one available or code it out leveraging NuGet packages (libraries). Both approaches have advantages – custom binding is reusable, while the other can be quicker to do.

    Azure-functions.png


    Was this article helpful?