0
votes

I am getting System.OutOfMemoryException exception for Blob Trigger Azure Function. When I am executing locally it is working fine.

enter image description here

Blog Trigger Azure Function:

public static class ProcessEvent
    {
        [FunctionName(nameof(ProcessEvent))]
        public static async Task Run([BlobTrigger(BlobStorageContainer.Name + "/{name}",
            Connection = "AzureWebJobsStorage")]
            Stream eventBlob, string name,
            [Inject] ILoggingService loggingService,
            [Inject] IEventProcessorService eventProcessor,
            [Inject] IBlobClient blobClient)
        {
            var logger = new Logger(loggingService);
            try
            {
                logger.Info($"Starting blob job tracker for file name {name}",
                    nameof(ProcessEvent));

                var eventContent = eventBlob.ReadAsString();

                var result = await eventProcessor.HandleProcessor(eventContent, logger);

                if (result)
                {
                    await blobClient.DeleteBlobAsync(BlobStorageContainer.Name, name);
                    logger.Info($"Blob deleted successfully file name: {name}");
                }
                else
                {
                    logger.Warning($"Unable to process blob job for file with name: {name}");
                }
            }
            catch (Exception ex)
            {
                logger.Error($"Unable to process blob job for file with name: {name}", ex,
                    nameof(ProcessEvent));
            }
        }
    }

My App Service Plan:

enter image description here

1
How big is the blobfile? - Daniel Björk
Usual size is between 4-5kb, but in some requests it can be 500-800kb - Rakesh Kumar
how many other functions are defined and running within the function app? how much overall concurrency is occurring per instance? - Daniel Björk
we have total 14 azure functions in this app - Rakesh Kumar
So then its likely that they together consume all the memory and you either have to scale up the plan or scale out the functions. - Daniel Björk

1 Answers

1
votes

You can diagnose the memory usage in portal->your function app->Diagnose and solve problem->Memory Analysis->View Full Report. enter image description here

It shows the overall percent physical memory usage per instance over the last 24 hours.

https://docs.microsoft.com/en-us/azure/app-service/overview-diagnostics#health-checkup-graphs