-
Notifications
You must be signed in to change notification settings - Fork 63
Closed
Labels
Description
Hi,
I am trying to output multiple rows to the database with the SQL Output binding but each time only one rows gets inserted.
I've got the following code:
public class StoreMetadata
{
[FunctionName("StoreMetadata")]
public async Task RunAsync(
[QueueTrigger("extracted-blobs", Connection = "BlobStorage")]string myQueueItem,
ILogger log,
[Sql("dbo.Ibans",
CommandType = System.Data.CommandType.Text,
ConnectionStringSetting = "SqlConnectionString")] IAsyncCollector<Iban> ibans
)
{
log.LogInformation("Store metadata function has been triggered!");
DetectedMetadataEvent detectedMetadataEvent = null;
try
{
detectedMetadataEvent = JsonSerializer.Deserialize<DetectedMetadataEvent>(myQueueItem);
}
catch (Exception ex)
{
// TODO: Handle
log.LogError($"Error while deserializing: {ex.Message}");
}
if (detectedMetadataEvent != null)
{
if (detectedMetadataEvent.PiiEntities != null)
{
foreach ( CustomPiiEntity entity in detectedMetadataEvent.PiiEntities)
{
if (entity != null)
{
if (entity.Category.Equals(PiiEntityCategory.InternationalBankingAccountNumber.ToString())){
await ibans.AddAsync(new Iban
{
AccountNumber = entity.Text,
SubCategory = entity.SubCategory,
DocumentId = 4004,
ConfidenceScore = entity.ConfidenceScore,
});
}
}
}
}
await ibans.FlushAsync();
}
}
}
When debugging I can see that the variable 'ibans' does have multiple objects so I don't understand why only 1 rows gets inserted into the database, maybe because '_rowLock' is 1?