[英]how to read the Azure blob file with Azure function in python?
I am new in Azure cloud.我是 Azure 云的新手。 Now I hope to create a work flow: upload a audio file to the blob --> Blob trigger is invoked --> deployed python function read the upload audio file and extract harmonics --> harmonics output as json file and save in another container.
现在我希望创建一个工作流程:将音频文件上传到 blob --> 调用 Blob 触发器 --> 部署的 python 函数读取上传的音频文件并提取谐波 --> 谐波输出为 json 文件并保存在另一个容器中. Blow is my code but it doesn't work:
Blow 是我的代码,但它不起作用:
import logging
import azure.function as func
import audio_read
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")
audio_info = audioread.audio_open(myblob.read())
logging.info(f"{audio_info}")
It returns me an error:它返回一个错误:
Exception: UnicodeDecodeError: "utf-8" codec can't decode byte 0x80 in position 40: invalid start byte.
例外:UnicodeDecodeError:“utf-8”编解码器无法解码位置 40 中的字节 0x80:起始字节无效。
my function.json is:我的 function.json 是:
{
"scriptFile": "__init__.py",
"bindings": [
{
"name": "myblob",
"type": "blobTrigger",
"direction": "in",
"path": "examplecontainer/{name}",
"connection": "AzureWebJobsStorage"
}
]
}
The input binding allows you to read blob storage data as input to an Azure Function.输入绑定允许您读取 Blob 存储数据作为 Azure 函数的输入。
For more details refer this document : https://docs.microsoft.com/en-us/azure/azure-functions/functions-bindings-storage-blob-input?tabs=python有关更多详细信息,请参阅此文档: https : //docs.microsoft.com/en-us/azure/azure-functions/functions-bindings-storage-blob-input?tabs=python
And make sure that you have given the proper content type and encoding while uploading audio file as blob in azure storage并确保在将音频文件作为 blob 上传到 azure 存储中时提供了正确的内容类型和编码
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.