简体   繁体   中英

Python Azure BlobTrigger how to get metadata

I'm creating a new function app for a blob event trigger by using the command func new --template BlobTrigger . The generated Python entrypoint for the BlobTrigger looks as follows:

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")

The myblob contains the image blob data that was uploaded to the blob storage. I'd need the corresponding metadata to this blob as well. I haven't found any way to get the metadata from the myblob parameter, looking at the available functions and attributes, it doesn't have any to retrieve the metadata from it.

Is there a way to get the metadata from this object or would I have to do a separate call to the Blob storage to retrieve that info?

I suggest you getting an idea of event-based triggers in Azure Data Factory to implement your requirements. You could configure the blob account:

在此输入图像描述

When an event trigger fires for a specific blob, you could captures the folder path and file name of the blob into the properties @triggerBody().folderPath and @triggerBody().fileName .

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM