http trigger function app to upload file to blob storage

Achraf DRIDI 86 Reputation points
2022-02-15T10:06:58.993+00:00

hello, i'm new to azure and i've been trying to upload file (from local or using url ) to azure blob storage using Function App, i defined out binding to blob storage and i wrote some code to upload the file but when i test it from Postman i get "500 internal server Error"
can you help me , please.
these are my init.py and function.json

174472-image.png

174454-image.png

Azure Functions
Azure Functions
An Azure service that provides an event-driven serverless compute platform.
Azure Blob Storage
Azure Blob Storage
An Azure service that stores unstructured data in the cloud as blobs.
0 comments No comments
{count} votes

Answer accepted by question author
  1. MughundhanRaveendran-MSFT 12,511 Reputation points
    2022-02-15T13:15:58.327+00:00

    @Achraf DRIDI ,

    Thanks for reaching out to Q&A and welcome to Azure Functions!

    You are alredy using the Azure.storage.blob python SDK to upload the blob so there is no need to define the output binding in the Function.json. You have defined two output bindings, one is http and other is blob. You can remove the blob output binding and try again. The Function.json should look like the following for a http trigger. Also debug the code and see if the function is working as expected. Then try it in PostMan tool.

    {
    "scriptFile": "init.py",
    "bindings": [
    {
    "authLevel": "function",
    "type": "httpTrigger",
    "direction": "in",
    "name": "req",
    "methods": [
    "get",
    "post"
    ]
    },
    {
    "type": "http",
    "direction": "out",
    "name": "$return"
    }
    ]
    }

    I hope this helps!

    Please 'Accept as answer' and ‘Upvote’ if it helped so that it can help others in the community looking for help on similar topics.


0 additional answers

Sort by: Most helpful

Your answer

Answers can be marked as 'Accepted' by the question author and 'Recommended' by moderators, which helps users know the answer solved the author's problem.