1

So i am working on azure function my goal is to have an azure function that is triggerd by an http request that have a blob storage binding which i can retrive files through but when i try to add my blob in binding the function stop working even though i didnt even add any code the main function

this is the binding setting i am using

{
      "type": "blob",
      "direction": "in",
      "name": "inputblob",
      "path": "test/{name}",
      "connection": "MyStorageConnection"
    }

this is the main function i have right now

import logging

import azure.functions as func


def main(req: func.HttpRequest) -> func.HttpResponse:
    logging.info('Python HTTP trigger function processed a request.')

    return func.HttpResponse(f"HTTP triggered function executed successfully. Pass a name in the query string or in the request body for a personalized response.")

but it is not working it give me a 500 error when trying to trigger the function

Peter Bons
  • 26,826
  • 4
  • 50
  • 74

1 Answers1

0

So, in your bindings you specify a blob trigger, but your code is expecting an http trigger. That is not going to work.

The code for a blob trigger takes an InputStream represeting the blob:

import logging
import azure.functions as func


def main(myblob: func.InputStream):
    logging.info('Python Blob trigger function processed %s', myblob.name)

Also, the binding should like this (note: the type is blobTrigger, not blob):

{
    "scriptFile": "__init__.py",
    "disabled": false,
    "bindings": [
        {
            "name": "myblob",
            "type": "blobTrigger",
            "direction": "in",
            "path": "samples-workitems/{name}",
            "connection":"MyStorageAccountAppSetting"
        }
    ]
}

This is also very well explained in the docs

Peter Bons
  • 26,826
  • 4
  • 50
  • 74
  • thank you for your reply may i ask how would this work if i need the trigger to be an HTTP request Note:I tried using the following code and still gave me an error – Bilal Edelbi Dec 28 '22 at 07:28
  • @BilalEdelbi well, you cannot combine an http trigger with a blob trigger so can you tell me more about what you want to accomplish? – Peter Bons Dec 28 '22 at 14:51
  • @BilalEdelbi Also, please post the whole error message. Otherwise it is hard to tell what the exact problem is. – Peter Bons Dec 28 '22 at 14:54
  • my error message is a simple 500 web error which I found it out it means that it didn't find any better error message to give me what I am trying to accomplish basically is that I have 5 excel files that I need to transform using pandas so I did the transformation locally but my goal is to make it so they are uploaded to azure blob storage though another process other people are developing and when i send the http request i want the function to be able to take the files from blob storage and process them in azure function and in the end put the output in another blob somewhere – Bilal Edelbi Dec 29 '22 at 08:28
  • You should check the logs, there must be more information there! – Peter Bons Dec 29 '22 at 14:49