Home > Back-end >  Azure function not firing after deploy
Azure function not firing after deploy

Time:07-30

I have created azure function of type Blob trigger. It runs successfully locally. But when I deployed the c# code using Visual studio publish, the trigger never fired.

Please suggest any solution. Even the simple trigger function created on the portal is not firing. I followed this video to create function.

[FunctionName("ImageResizeFunction")]
        public void Run(
            [BlobTrigger("normal-size/{name}")] Stream inputBlob,
            [Blob("reduced-size/{name}", FileAccess.Write)] Stream outputBlob,
            string name,
            ILogger log)
        {
            log.LogInformation($"C# Blob trigger function Processed blob\n Name:{name} \n Size: {inputBlob.Length} Bytes");

            try
            {
                this.imageResizer.Resize(inputBlob, outputBlob);
                log.LogInformation("Reduced image saved to blob storage");
            }
            catch (Exception e)
            {
                log.LogError("Resize fails", e);
            }
        }

CodePudding user response:

We have also tried to create sample function app using blob trigger and it works fine in local and Azure well.

Here are the workaround we follow;

Created one simple Azure function in local and provide the storage account endpoint details in localsettings.json and provide the container name in function.cs file and trying to upload files on container and it works.

using System;
using System.IO;
using Microsoft.Azure.WebJobs;
using Microsoft.Azure.WebJobs.Host;
using Microsoft.Extensions.Logging;

namespace Company.Function
{
    public class BlobTrigger1
    {
        [FunctionName("BlobTrigger1")]
        public void Run([BlobTrigger("ajaytest/{name}", Connection = "cloudtestajaymt_STORAGE")]Stream myBlob, string name, ILogger log)
        {
            log.LogInformation($"C# Blob trigger function Processed blob\n Name:{name} \n Size: {myBlob.Length} Bytes");
        }
    }
}

OUTPUT IN LOCAL:-

enter image description here

Then when publish this blob trigger to Azure function we need to specify the connection string of storage account in configuration of Azure function . As on our localsettings.json .

As shown below:- enter image description here enter image description here

After set the application settings goto >Function>Monitor> And check the Invocations where you will be able to see the logs of upload files/images to the blob.

NOTE:- This logs takes upto 5 minutes to be loaded in invocations.

OUTPUT LOGS FROM PORTAL:-

enter image description here enter image description here

For more information please refer this Blog|Deploy Azure Function - Blob Trigger From Visual Studio

  • Related