Open spaelling opened 5 years ago
@spaelling Have you tried the -Clobber
switch (see Push-OutputBinding syntax)?
@spaelling Have you tried the
-Clobber
switch (see Push-OutputBinding syntax)?
Still the same error. Also I do not believe that -Clobber
works like this. In some cases Push-OutputBinding
only accepts a single output, ex. Http (Wouldn't make sense to output an array of html objects/code). In this case you can use -Clobber
to overwrite the existing value, whereas if it was a queue it would add another object to the queue, or overwrite if using -Clobber
.
@spaelling Thank you, I see what you mean, -Clobber
is not supposed to solve this. We'll need to think how to make this configurable, as the current behavior is also desirable sometimes: either use -Force
as you suggested, or come up with another parameter.
@spaelling Thank you, I see what you mean,
-Clobber
is not supposed to solve this. We'll need to think how to make this configurable, as the current behavior is also desirable sometimes: either use-Force
as you suggested, or come up with another parameter.
Perhaps make it work like Out-File
where -NoClobber
:
NoClobber prevents an existing file from being overwritten and displays a message that the file already exists. By default, if a file exists in the specified path, Out-File overwrites the file without warning.
In the case of table storage the default behavior could be to overwrite an existing row, but one could work around this using the -NoClobber
switch.
But it would probably be best to adopt the two upsert operations already established in table storage
You could implement this by adding an -Upsert
parameter (only works with table storage)
$Entity = @{
partitionKey = "SOME_PARTITION_KEY"
rowKey = "key_that_already_exists_in_the_table"
}
# replaces the existing row with data from $Entity
Push-OutputBinding -Name outputTable -Value $Entity -Upsert Replace
# merges the data from existing row with data from $Entity
Push-OutputBinding -Name outputTable -Value $Entity -Upsert Merge
Is there already an update on this topic?
Are there any plans to implement this?
As a workaround https://github.com/PalmEmanuel/AzBobbyTables is an excellent module that I use for this task instead of output bindings and can use the same storage account credentials as the functions host (including managed identity if you migrated to that)
Are there any updates on this?
If the rowKey already exists in the table the entity is not overwritten, but an error is raised. This makes
Push-OutputBinding
a one-trick-pony wrt. table storage and any workaround defeats the purpose of making integration with Azure Table Storage easy and straightforward.I would suggest adding a
-Force
parameter that means overwrite existing entries. This should be trivial as instead of using theinsert
operation you could use theupsert
operation.Not sure if this should then be an
insert or replace
or ainsert or merge
. Perhaps something that can be defined in the integration itself, but either will do as a temporary measure.Or am I missing something since I could find no mention of this issue anywhere?