Azure Blob触发函数启动即陷入超时循环问题求助
Azure Blob触发函数启动即陷入超时循环问题求助
大家好,我最近碰到个Azure Functions的麻烦事,想请各位大佬帮忙分析下:
公司里有个Azure Function突然不能正常工作了,我接手排查后发现,它刚启动就直接陷入了超时循环。因为我本身Azure Functions的经验不算丰富,想着先写个最基础的测试函数来验证环境,结果没想到这个极简版本也遇到了一模一样的问题。
我的环境信息
- 存储模拟工具:Azurite
- Python版本:3.11.5
- Azure.functions包版本:1.17.0
测试用的代码文件
function_app.py
import logging import os import azure.functions as func # Create a custom logger logger = logging.getLogger(__name__) # Create handlers f_handler = logging.FileHandler('file.log') f_handler.setLevel(logging.DEBUG) # Create formatters and add it to handlers f_format = logging.Formatter('%(asctime)s - %(name)s - %(levelname)s - %(message)s') f_handler.setFormatter(f_format) # Add handlers to the logger logger.addHandler(f_handler) logger.warning('This is a warning') logger.error('This is an error') def main(myblob: func.InputStream): filename = os.path.basename(myblob.name) content = myblob.read() # Your code to process the blob content goes here # For example, you can print the blob's filename and length print(f"Blob name: {filename}") print(f"Blob length: {len(content)} bytes")
host.json
{ "version": "2.0", "logging": { "applicationInsights": { "samplingSettings": { "isEnabled": true, "excludedTypes": "Request" } } }, "extensionBundle": { "id": "Microsoft.Azure.Functions.ExtensionBundle", "version": "[4.0.0, 5.0.0)" }, "singleton": { "listenerLockPeriod": "00:00:15" } }
function.json
{ "scriptFile": "function_app.py", "bindings": [ { "name": "myblob", "type": "blobTrigger", "direction": "in", "path": "http://127.0.0.1:10000/devstoreaccount1/default/ECO_DAYINV904951960411607774_231019%20from%20231018.xlsx", "source": "EventGrid", "connection": "UseDevelopmentStorage=true" } ] }
local.settings.json
{ "IsEncrypted": false, "Values": { "AzureWebJobsStorage": "http://localhost:7071/runtime/webhooks/blobs?functionName=Host.Functions.BlobTriggerEventGrid", "FUNCTIONS_WORKER_RUNTIME": "python", "AzureWebJobsFeatureFlags": "EnableWorkerIndexing" } }
调试遇到的困境
我尝试过用调试工具排查,但断点完全停不下来,只能手动暂停程序,这时候发现它已经卡在common.py的超时循环里了。
有没有朋友遇到过类似的问题?或者能给我一些排查方向的建议?
备注:内容来源于stack exchange,提问作者Sebastian Boström
相关产品推荐
相关产品推荐

