Graham Graham - 1 year ago 139
Node.js Question

How do you perform an upsert with a node.js Azure Function hitting Table Storage?

I have an Azure Function written in node.js/JavaScript and I'm trying to update an entity but am getting the following error:

Exception while executing function: Functions.WebHook-Update.
Microsoft.Azure.WebJobs.Host: Error while handling parameter _binder
after function returned:. Microsoft.WindowsAzure.Storage: 1:The
specified entity already exists.

How can I get the binding to perform an upsert instead of an insert?

Answer Source

The underlying Table binding doesn't support update semantics at this time, only query/add. That applies to all of the languages Functions supports, since all languages use the same underlying binding.

There was another SO question here about this in the context of a C# function. As you can see, the guidance is currently to pull in the storage SDK to perform the update. That would apply to Node as well.

In general, the simplicity that the Functions binding model brings to various Azure services has its limits. We try to simplify the common tasks, but there will always be scenarios that will require you to "drop down" and use the raw SDK.

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download