Azure-Functions icon indicating copy to clipboard operation
Azure-Functions copied to clipboard

Unclear how to implement custom bindings in Visual Studio via function.json

Open bobmclaren opened this issue 8 years ago • 4 comments

I am authoring an Azure Function project in Visual Studio 2017 with multiple functions. I would like to leverage binding in order to delete records from Azure Table Storage. As stated in this article, since update/delete is not yet supported in entity bindings, the recommended approach is to create a custom binding and map it to a CloudTable instance. However, since the function.json is generated at build time, it is unclear to me where to author these custom bindings in Visual Studio.

Any help would be greatly appreciated.

bobmclaren avatar Jun 01 '18 21:06 bobmclaren

Understandable - something I hear frequently so need to figure out how to make more clear in docs. With C# the function.json is automatically generated, but all features are usable via Attributes in C#. So to create a CloudTable binding in your code would look something like:

[FunctionName("Function1")]
        public static async Task<HttpResponseMessage> Run([HttpTrigger(AuthorizationLevel.Function, "get", "post", Route = null)]HttpRequestMessage req,
            [Table("myTable")] CloudTable outputTable,
            TraceWriter log)
        {
            log.Info("C# HTTP trigger function processed a request.");

            outputTable.ExecuteAsync(...);
            .....
         }

jeffhollan avatar Jun 14 '18 21:06 jeffhollan

Relevant doc

jeffhollan avatar Jun 14 '18 21:06 jeffhollan

Thanks @jeffhollan, sometimes it's hard to see the forest with these stupid trees in the way.

bobmclaren avatar Jun 15 '18 14:06 bobmclaren

You and me both. Happy to help 😃

jeffhollan avatar Jun 15 '18 14:06 jeffhollan