0

We have a python extraction function which works like: feed audio file(m4a file) to the extraction function. Then the function extract harmonic from audio file and output as json format.

Now, we are trying to deploy this python harmonic extract function to Azure function. So we can just upload audio file(e.g. m4a) to Azure blob then the python extraction function can process the uploaded file on the cloud. However we don’t know how to feed audio file from the Azure blob to the Azure python function.

2 Answers 2

0
  • One of the workarounds for this is to download the harmonic extract JSON file locally and read the file from azure functions.
  • Another method is to directly read the blob file without downloading from the azure function (i.e.. connecting to your azure storage account).

REFERENCES:

  1. How to read a file from Azure Blob Container using Python in function app

  2. How to read json file from blob storage using Azure Functions Blob Trigger with Python - Stack Overflow

  3. python - Azure blob storage to JSON in azure function using SDK - Stack Overflow

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

1 Comment

Thank you for your reply! But our problem is we don't know how to feed audio file from the blob (without downloading) to deployed harmonic extraction function. we use audioread.audio_open(path) to read the audio files locally. However, it doesn't work on the Azure function.
0

This is a good Microsoft article to follow for this, with Python examples: Azure Blob storage trigger for Azure Functions

So your function.json bindings configuration file would have, for example:

{
  "name": "myblob",
  "type": "blobTrigger",
  "dataType": "binary",
  "direction": "in",
  "path": "samples-workitems/{name}",
  "connection": "MyStorageAccountAppSetting"
}

And your __init__.py Python code:

def main(myblob: func.InputStream):
    <<extract function code to read "myblob" here>>

So essentially, you treat myblob as your file that is fed into your function based on the binding configuration.

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.