I have an Azure function that every time a blob is added to a container in my storage account, it performs a series of operations with it and then sends a message.
Everything works correctly in my local Visual Studio solution using the connection to the real Azure storage account
but when I publish everything seems to be going well however when I add blobs to the container there is no invocation of my function and I don't know what could be failing or missing.
This is the code that works fine in local
public static class InsertarConcursosEnBBDD
{
[FunctionName("InsertarConcursosEnBBDD")]
public static void Run(
[BlobTrigger("test/{name}", Connection = "AzureWebJobsStorage")] Stream blobStream,
[SendGrid(ApiKey = "SendGridApiKey")] ICollector<SendGridMessage> sender,
string name,
ILogger log)
{
if (name.ToLower().EndsWith("xlsx"))
{
log.LogInformation($"Blob trigger function Processed blob\n Name:{name}");
ExcelPackage.LicenseContext = LicenseContext.NonCommercial;
DestriparExcel destripaExcel = new DestriparExcel();
var _insertarDatos = new InsertarDatos();
var emailPrincipal = "rquintela@fulcrum.es";
var emailCopia = "ariesco@fulcrum.es";
var message = new SendGridMessage();
message.From = new EmailAddress(Environment.GetEnvironmentVariable("EmailSender"));
message.AddTo(emailPrincipal);
message.AddCc(emailCopia);
using (ExcelPackage package = new ExcelPackage(blobStream))
{
ExcelWorksheet worksheet = package.Workbook.Worksheets.FirstOrDefault();
List<ConcursoExcel> listaConcursosExcel = destripaExcel.ImportarDatos(name, worksheet);
List<Concurso> listaConcursosAInsertar = _insertarDatos.TransformarConcursosExcelAConcursosBoletus(listaConcursosExcel);
var registrosAñadidos = _insertarDatos.InsertarConcursos(listaConcursosAInsertar);
message.Subject = "Concursos diarios";
message.HtmlContent = $"{registrosAñadidos} Concursos añadidos correctamente a la BBDD correspondientes al fichero {name}";
sender.Add(message);
log.LogInformation($"Se han añadido {registrosAñadidos} concursos a la base de datos");
}
}
else
{
log.LogInformation($"El fichero {name} no tiene extension xlsx");
}
}
}
}
Any idea, please?
Thanks