I have an Azure PowerShell Function that queries API Management analytics for a list of API's, and then outputs to a Table Store table via a Function integration.
A row is created for each API, with the PartitionKey being the name of the API and the RowKey being the date which the analytics are from.
This leads to an error should analytics for an API be requested more than once per day. At this point, Function exectution fails with a status of 500 Internal Server Error and I'm presented with the following error -
Error while handling parameter _binder after function returned: -> The specified entity already exists.
While I plan to run the Function on a schedule, thus avoiding this issue most of the time, it would be better to have a solution in place, with the ideal scenario being to overwrite an existing entry. Is this possible?
$apiIds.GetEnumerator() | ForEach-Object {
$analytic = $_.Value | Get-ApiManagementAnalytics -Context $context -StartDate $startDate -EndDate $endDate -AccessToken
$tableRow = $analytic.value
$tableRow | Add-Member -NotePropertyName PartitionKey -NotePropertyValue $tableRow.name
$tableRow | Add-Member -NotePropertyName RowKey -NotePropertyValue ((Get-Date).ToString("yyyy-MM-dd"))
$tableRows += $tableRow
}
$tableRows | ConvertTo-Json | Out-File -Encoding UTF8 $outputTable