0
votes

I have created a simple blob trigger in visual studio for which init.py is as below

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 function.json is as below

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

local.settings.json looks as below

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

This code works fine with visual studio on local machine. But when published on azure portal it can not read blob path from function.json and gives error as

Invalid blob path specified : ''. Blob identifiers must be in the format 'container/blob'.

I have published function using command to push contains of local.settings.json.

func azure functionapp publish FUNCTIONNAME --build-native-deps --publish-local-settings -i

. Can anyone please guid me what I am missing after publishing.

1

1 Answers

1
votes

Are you using the run button in the Azure portal to test your function? The way this works for blob triggers is that in the 'Test' tab on the right hand side, you can specify the name of the blob you want to manually send a trigger event for, forcing your function to run:

enter image description here

The idea is that you should edit the contents of the request body box and put in the path to a valid blob in your account. That way the trigger runs and finds the blob and retrieves it. So if you don't modify the request body box, then it will look for a blob and fail to find it and throw the 404 error.

Also please take a look at below document for configuring container name

https://docs.microsoft.com/en-us/azure/azure-functions/functions-bindings-storage-blob#storage-blob-trigger

Also please verify if you setting has been published in the portal or not.

func azure functionapp publish "functionname" --publish-local-settings

Hope it helps.