gpt4 book ai didi

python - Python 函数应用程序的 Blob 触发器未触发

转载 作者:行者123 更新时间:2023-12-04 01:46:17 26 4
gpt4 key购买 nike

我正在使用 Ubuntu 16.04.5 LTS 本地计算机,使用 CLI 和 Azure Functions Core Tools ( Ref ) 创建 Python Function App 并将其发布到 Azure。我已经配置了 Blob 触发器,我的 function.json 文件如下所示:

{
"disabled": false,
"scriptFile": "__init__.py",
"bindings": [
{
"name": "<Blob Trigger Name>",
"type": "blobTrigger",
"direction": "in",
"path": "<Blob Container Name>/{name}",
"connection": "<Connection String having storage account and key>"
},
{
"name": "outputblob",
"type": "blob",
"path": "<Blob Container Name>",
"connection": "<Connection String having storage account and key>",
"direction": "out"
}
]
}

我的 init.py 函数如下所示。

def main(<Blob Trigger Name>: func.InputStream, doc: func.Out[func.Document]):
logging.info(f"Python blob trigger function processed blob \n"
f"Name: {<Blob Trigger Name>.name}\n"
f"Blob Size: {<Blob Trigger Name>.length} bytes")
logging.basicConfig(filename='example.log',level=logging.DEBUG)
logging.debug('This message should go to the log file')
logging.info('So should this')
logging.warning('And this, too')

# Write text to the file.
file = open("QuickStart.txt", 'w')
file.write("Hello, World!")
file.close()

# Create the BlockBlockService that is used to call the Blob service for the storage account
block_blob_service = BlockBlobService(account_name='<Storage Account Name>', account_key='<Storage Account Key>')
container_name='<Blob Container Name>'

# Set the permission so the blobs are public.
block_blob_service.set_container_acl(container_name, public_access=PublicAccess.Container)

# Upload the created file, use local_file_name for the blob name
block_blob_service.create_blob_from_path(container_name, 'QuickStart.txt', '')

功能应用程序“始终开启”,但当我在存储中上传 blob 时,该功能不会被触发。另一个引用链接是这个(Ref).

出了什么问题?

谢谢和问候,沙申克

最佳答案

您是否检查过 local.settings.json(存储帐户的连接字符串)也位于 Azure 的函数应用中?默认情况下,它们不会从本地计算机发布。

您可以在门户中手动配置它们或使用publish-local-settings标志:

func azure functionapp publish "functionname" --publish-local-settings

关于python - Python 函数应用程序的 Blob 触发器未触发,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/55136263/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com