我在使用 python 在 Azure 中为 blobtrigger 案例定义多个输出时遇到问题。如何将 WhileLoop 的所有尝试设置为 Outputblob?现在,我只得到最后一个实体(替换以前的实体)。我把代码用于--init--.py:
import logging
import json
import azure.functions as func
from urllib.request import urlopen
#from azure.storage import blob
def main(inputblob: func.InputStream,
outputblob: func.Out[func.InputStream]):
logging.info(f"Python blob trigger function processed blob \n"
f"Name: {inputblob.name}\n"
f"Blob Size: {inputblob.length} bytes")
blob= inputblob.read()
blob_invoices= json.loads(blob)
Number_of_Invoices=int(len(blob_invoices))
j=0
while j < Number_of_Invoices:
Invoice_url= blob_invoices[j]["invoiceFile"]['url']
invoice_opening= urlopen(Invoice_url)
invoice_content= invoice_opening.read()
outputblob.set(invoice_content)
if __name__ == "__main__":
main()
和function.json:
{
"scriptFile": "__init__.py",
"bindings": [
{
"name": "inputblob",
"type": "blobTrigger",
"direction": "in",
"path": "data4test1/{name}.json",
"connection": "data4test_STORAGE"
},
{
"name": "outputblob",
"type": "blob",
"direction": "out",
"path": "data4test2/{name}.xml",
"connection": "data4test_STORAGE"
}
],
"disabled": false