1

I am working on one of the Azure Function which is written in Python and it should get called based on Blob trigger event. However, the trigger is not firing when I am uploading a zip file in a blob container to which azure function is supposed to monitor.

Following is local.settings.json file -

{
  "IsEncrypted": false,
  "Values": 
    {
    "AzureWebJobsStorage": "blob (connection string) that was created when Azure function is created",
    "FUNCTIONS_WORKER_RUNTIME": "python",
    "My_STORAGE": "blob (connection string) that function should monitor"
    }
} 

Following is function.json file -

{
  "scriptFile": "__init__.py",
  "bindings": [
    {
      "name": "myblob",
      "type": "blobTrigger",
      "direction": "in",
      "path": "mycontainer/{name}",
      "connection": "My_STORAGE"
    }
  ]
}

Following is my code init.py - (test_func is user defined function to do some business logic)

def main(myblob: func.InputStream):
test_func(myblob.name)
logging.info(f"Python blob trigger function processed blob \n"
             f"Name: {myblob.name}\n"
             f"Blob Size: {myblob.length} bytes")

When I'm uploading zip file in "mycontainer" container, the azure function is not firing.

The "mycontainer" of StorageV2 (general purpose v2) account kind. I am using Python 3.8 version.

This "mycontainer" has automatically created a container named $logs that has day wise folder to have a log file mentioning the file that I'm uploading in "mycontainer", however, there is no sign of blob trigger event on Azure function.

"My_STORAGE" is added as Application Settings in Azure Function's Configuration settings. I am uploading Local Settings after Azure Function deployment.

Any idea what is going wrong?

Thank you.

13
  • Did you test the function in local ? And could you please check if there is any error when execute test_func(myblob.name) ? Commented Jan 13, 2021 at 8:39
  • I removed test_func(myblb.name) function. still no luck. Not sure, how would I test this on local? Commented Jan 13, 2021 at 8:58
  • Run this command: func host start in your VS code Terminal window to start your function. Commented Jan 13, 2021 at 8:59
  • 1
    yes, changed account name to storage account name and deployed. Commented Jan 13, 2021 at 9:20
  • 1
    You do not need to re-deploy it to portal, you just need to change the My_STORAGE in application settings of your function app on portal. "local.settings.json" will not be deployed to azure portal when you do deployment. Commented Jan 13, 2021 at 9:24

3 Answers 3

3

I've had a similar problem. It was solved by adding the connection string as a key-value pair to the Application Settings in Function App->Configuration->Settings. I assume that it has to be done if Azure Functions Apps are deployed in a different storage container, for which there needs to be a different connection string.

Sign up to request clarification or add additional context in comments.

1 Comment

THIS IS THE ANSWER! You need to create a key-value pair like this: <storageaccount>_STORAGE : <connection string for the storage account>
1

The problem was caused by mistake in connection string. The AccountName in connection string should be storage account name but not the name of container.

So just change AccountName=mycontainer to AccountName=<storage account name>, then it works.

And by the way:

The connection string should be: DefaultEndpointsProtocol=https;AccountName=<storage account name>;AccountKey=xxxxxxxxxx==;EndpointSuffix=core.windows.net

The "path" in "function.json" should be: "path": "<container name>/{name}"

3 Comments

thanks Hury, indeed the path in function.json was incorrect.
just a quick question, is the container name within the path supposed to be enclosed with the < and > symbol ?
Sorry, forgot @ you. @user3396351 do not need < and >.
0

Copy the <storage_account>_STORAGE key from local.settings.json file to a new application setting key-value:

enter image description here

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.