Azure Function Python V2 with bindings to Azure SQL Database

Louis Deconinck 0 Reputation points
2024-04-29T12:55:35.0966667+00:00

I'm using Azure Functions V2 (Python 3.11). Here you can read that V2 replaces the function.json file with function decorators: https://techcommunity.microsoft.com/t5/azure-compute-blog/azure-functions-v2-python-programming-model-is-generally/ba-p/3827474

I would like to create a binding between my Azure Function and my Azure SQL database. This documentation explains how to do this, but it uses function.json (which is only available in Azure Functions Python V1 and not in the newer V2): https://learn.microsoft.com/en-us/azure/azure-functions/functions-bindings-azure-sql-input?pivots=programming-language-python&tabs=isolated-process%2Cnodejs-v4#http-trigger-get-multiple-rows-3

So my question is: How to create a binding between Azure Function Python V2 and Azure SQL Database?

Azure SQL Database
Azure Functions
Azure Functions
An Azure service that provides an event-driven serverless compute platform.
4,347 questions
0 comments No comments
{count} votes

1 answer

Sort by: Most helpful
  1. Amira Bedhiafi 16,071 Reputation points
    2024-05-02T21:20:23.2833333+00:00

    Model V2 does not have function.json, bindings are defined inside the function_app.py file. check this document

    Azure Functions expects a function to be a stateless method in your Python script that processes input and produces output. By default, the runtime expects the method to be implemented as a global method in the function_app.py file. Triggers and bindings can be declared and used in a function in a decorator based approach. They're defined in the same file, function_app.py, as the functions.

    0 comments No comments