I have made a simple Azure Function with blob trigger. It is working fine in my development environment using Azure storage Explorer. However, when I created the function in Azure portal it is not working.
I also want to mention that it is free subscription account, so it never asked me to select the storage account while creating function (Check snapshot below).
I have already added the storage connection string (Check snapshot below).
If I check the monitoring invocation, it gives zero success and 0 failure, means it never even triggered.
Moreover, if I run the diagnose, it is giving me a suggestion to create two settings, WEBSITE_CONTENTSHARE and WEBSITE_CONTENTAZUREFILECONNECTIONSTRING.
In "WEBSITE_CONTENTAZUREFILECONNECTIONSTRING" storage account connection string will be used but what should I configure in "WEBSITE_CONTENTSHARE"?
Following is the C# function code:
using System;
using System.IO;
using Microsoft.Azure.WebJobs;
using Microsoft.Azure.WebJobs.Host;
using Microsoft.Extensions.Logging;
using SixLabors.ImageSharp;
using SixLabors.ImageSharp.Formats;
using SixLabors.ImageSharp.Formats.Jpeg;
using SixLabors.ImageSharp.Processing;
namespace ThumbnailGenerator
{
public class ThumbnailFunction
{
[FunctionName(nameof(ThumbnailFunction))]
public void Run([BlobTrigger("wpm/{name}", Connection = "wpmStorageConn")]Stream myBlob,
[Blob("thumbnail/{name}",FileAccess.Write, Connection = "wpmStorageConn")] Stream outputStream, string name, ILogger logger)
{
logger.LogInformation($"Function triggered for wpm container\n Name:{name} \n Size: {myBlob.Length} Bytes");
//Stream outputStream= null;k
resize(myBlob, ref outputStream);
logger.LogInformation("Thumbnail created");
}
private static void resize(Stream myBlob, ref Stream outputStream)
{
using (Image image = Image.Load(myBlob))
{
int width = 50;
int height = 0;
image.Mutate(x => x.Resize(width, height));
image.Save(outputStream, JpegFormat.Instance);
}
}
}
}







