0

I have an azure function with blob trigger. Function should trigger once a day but it works sometimes. I found that is function is not awake when file arrives to path used as trigger, it doesn't launch and file is not processed. If I go to portal and refresh the function, it start working and processes all queued files.
Is there a way to make the function triggers without "refreshing" it?
Function code is written in python and it is created in azure using azure devops pipeline.
I attach host.json configuration for more details:

{
  "version": "2.0",
  "logging": {
    "fileLoggingMode": "always",
    "applicationInsights": {
      "samplingSettings": {
        "isEnabled": true
      }
    }
  },
  "extensions": {
    "queues": {
      "maxPollingInterval": "00:00:02",
      "visibilityTimeout" : "00:00:30",
      "batchSize": 8,
      "maxDequeueCount": 5,
      "newBatchThreshold": 4,
      "messageEncoding": "base64"
    }
  },
  "extensionBundle": {
    "id": "Microsoft.Azure.Functions.ExtensionBundle",
    "version": "[3.3.0, 4.0.0)"
  },
  "functionTimeout": "-1",
  "retry": {
    "strategy": "fixedDelay",
    "maxRetryCount": 0,
    "delayInterval": "00:00:05"
  }
    
}

Below you can find function.json file with trigger details

{
  "scriptFile": "__init__.py",
  "bindings": [
    {
      "name": "inStr",
      "type": "blobTrigger",
      "direction": "in",
      "path": "container/path_to_file/{name}",
      "connection": "AzureWebJobsStorage"
    }
  ]
}

And this is part of the code of python function, file init.py

def main(in_str):
    uri = in_str.uri
    split_uri = uri.replace("//", "/").split("/")
    source_bucket = split_uri[2]
    source_key = '/'.join(split_uri[3:])
    source_directory = '/'.join(split_uri[3:-1])
    file_name = source_key.split('/')[-1]
    print(f"File name is {file_name}")

vll1990
  • 311
  • 3
  • 17
  • It does not look like a blob trigger...are you sure you pasted the right file ? – Anand Sowmithiran Jun 13 '22 at 07:12
  • Azure function for Blob trigger in Python , [reference](https://learn.microsoft.com/en-us/azure/azure-functions/functions-bindings-storage-blob-trigger?tabs=in-process%2Cextensionv5&pivots=programming-language-python), notice the `bindings` section in function.json, see the reference for [bindings](https://learn.microsoft.com/en-us/azure/azure-functions/functions-bindings-storage-blob-input?tabs=in-process%2Cextensionv5&pivots=programming-language-python) – Anand Sowmithiran Jun 13 '22 at 07:16
  • Hi, I had passed only host.json file, the configuration of app function. I have edit the post and pass function.json file with trigger configuration. – vll1990 Jun 13 '22 at 09:19
  • Share the code fragments of the trigger function – Anand Sowmithiran Jun 13 '22 at 10:47
  • Your python function need not do all these string splits, parsing etc. The function gets a `InputStream` as input argument, `in_str.name` gives you the name of the blob file that just got added to the storage container. See MS doc [example](https://learn.microsoft.com/en-us/azure/azure-functions/functions-bindings-storage-blob-trigger). – Anand Sowmithiran Jun 14 '22 at 07:02
  • 1
    Refer this [Microsoft Document](https://techcommunity.microsoft.com/t5/apps-on-azure-blog/blob-trigger-function-does-not-fire-unless-you-visit-the-portal/ba-p/807948) for Blob Trigger Function does not fire unless you visit the portal. – RajkumarPalnati Jun 15 '22 at 03:37
  • Thanks for answers. RajkumarPalnati-MT, I see the link but I can't change the storage and I tried to launch the function with EventGrid trigger but we have thousands of files to process and EventGrid is too slow, so we have to rollback to blob trigger – vll1990 Jun 21 '22 at 08:29

0 Answers0