Blob 触发器 Azure Function 不会针对指定 Azure 存储容器中的每个文件上传自动触发

问题描述 投票:0回答:1

我已在存储帐户上使用 Blob 触发器创建 Azure 函数,但是当我在存储帐户中上传 Blob 时,函数不会触发。

我已经使用 ConenctionString 和我的存储帐户连接字符串创建了环境变量。

计划类型:应用服务计划

SKU 和尺寸:Premium0V3 P0v3

import azure.functions as func
import logging

app = func.FunctionApp()

@app.blob_trigger(arg_name="myblob", path="container/directory",
                               connection="ConnectionString") 
def blob_trigger(myblob: func.InputStream):
    logging.info(f"Python blob trigger function processed blob"
                f"Name: {myblob.name}"
                f"Blob Size: {myblob.length} bytes")

您能帮忙分享解决方案吗?

我已经使用 ConenctionString 和我的存储帐户连接字符串创建了环境变量。

azure azure-functions azure-blob-trigger
1个回答
0
投票

我已经使用运行时堆栈Python创建了Blob触发函数。 检查下面的代码是否成功运行。 功能代码:

import azure.functions as func
import logging

app = func.FunctionApp()

@app.blob_trigger(arg_name="myblob", path="outcontainer",
                            connection="rithwikstore_STORAGE") 
def blob_trigger(myblob: func.InputStream):
    logging.info(f"Python blob trigger function processed blob"
                f"Name: {myblob.name}"
                f"Blob Size: {myblob.length} bytes")

local.settings.json:

{
  "IsEncrypted": false,
  "Values": {
    "AzureWebJobsStorage": "your-storage conn-string",
    "FUNCTIONS_WORKER_RUNTIME": "python",
    "AzureWebJobsFeatureFlags": "EnableWorkerIndexing",
    "rithwikstore_STORAGE": "your-storage conn-string"
  }
}

enter image description here

确保可以在功能应用程序设置中添加存储帐户的连接字符串,如下所示:

enter image description here

当我运行上面的代码时,我已将 blob 上传到存储容器中,然后它成功触发了功能。检查下面:

enter image description here

我已将该功能部署到门户中功能应用程序的高级计划中。

enter image description here

enter image description here

该功能在 Azure 门户中也有效。检查下面:

输出: enter image description here

© www.soinside.com 2019 - 2024. All rights reserved.