1
votes

I have recently started reading about Azure Functions so decided to give it a go.

I created a test Azure Function in Visual Code using Python, which should fire off a trigger when a blob has been uploaded to the specified container but for some reason I am getting this error below:

2021-01-14T11:27:32Z   [Error]   Executed 'Functions.TestBlobTrigger' (Failed, Id=dfd0dd15-d937-486d-b6f3-1634745ff14d, Duration=37ms)

To provide more context, this is my function.json file:

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

This is my _init_.py file:

import logging

import azure.functions as func


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

And finally this is my local.settings.json file:

{
  "IsEncrypted": false,
  "Values": {
    "AzureWebJobsStorage": "DefaultEndpointsProtocol=https;AccountName=XXXX;AccountKey=XXXX;EndpointSuffix=core.windows.net",
    "FUNCTIONS_WORKER_RUNTIME": "python"
  }
}

I'd appreciate any tips in order to guide me in the right direction.

1
Have you solved the problem ? - Hury Shen
nope had no luck as of yet - jcoke
May I know if you already have a function app on azure portal and then deploy the local function to that function app ? Or when you deploy the local function, create the function app on azure portal at the same time ? - Hury Shen
I already have everything set up, so the function app is already up and running and I have made a test function using a timer trigger and that works fine - jcoke
So you deploy the local function code to a function app which already exists on portal ? - Hury Shen

1 Answers

1
votes

The problem was caused by the two AzureWebJobsStorage(in local and on portal) are different. When you deploy the function from local to azure, it will not upload the AzureWebJobsStorage in local.settings.json to the application settings of function on portal.

So the solution is copy the value of AzureWebJobsStorage in local.settings.json to replace AzureWebJobsStorage in application settings of function on portal.