Azure Function SQL Binding: UPDATE statement possible?

Joe Pawlowski (DHL Supply Chain) 30 Reputation points
2023-10-03T19:59:30.75+00:00

I've been wracking my brain and the internet to understand the cababilities of this newer feature but can't get a straight answer.

Should the below excerpt from my function.json file work?

  {
    "type": "sql",
    "direction": "out",
    "name": "sqlUpdate",
    "connectionStringSetting": "SqlConnectionString",
    "tableName": "dbo.ToDo", 
    "commandText": "UPDATE dbo.ToDo SET url = @url WHERE title = @title"
 
  }
Azure Functions
Azure Functions
An Azure service that provides an event-driven serverless compute platform.
5,911 questions
{count} votes

Accepted answer
  1. MuthuKumaranMurugaachari-MSFT 22,441 Reputation points Moderator
    2023-10-03T20:37:23.23+00:00

    Joe Pawlowski (DHL Supply Chain) Thanks for posting your question in Microsoft Q&A. From the code snippet above, you are using SQL output binding to write the data to the table. As per doc: Azure SQL output binding for Azure Functions, the CommandText property should point to the name of the table not SQL statement. The output binding actually uses MERGE statement (T-SQL) to write the data and UPDATE statement is not supported (hence you faced the syntax error).

    We do have a lot of samples available here for different languages such as Python, C# for output bindings and I suggest you referring that for usage. Specifically on UPDATE functionality, check out this discussion and let me know if you face any issues or have any other questions with the samples.

    For any feedback on SQL extension, please submit it via Issues or Discussions and our product team will assist you with that. I hope this helps with your questions.


    If you found the answer to your question helpful, please take a moment to mark it as "Yes" for others to benefit from your experience. Or simply add a comment tagging me and would be happy to answer your questions.


1 additional answer

Sort by: Most helpful
  1. Joe Pawlowski (DHL Supply Chain) 30 Reputation points
    2023-10-09T13:52:57.77+00:00

    Ok, so I've gotten through Create, Read, Update...Delete is next.

    From what I can gather, there currently isn't any way to use the SQL Bindings to delete a record form a table.


Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.