我有一个函数可以自动递增cosmosdb中的值。我可以通过访问获取该值的网站进行检查,并看到它正在增长:
Universal Time Units (TU): [14010]
。所以我知道该函数正在执行。然而,该函数确实显示它正在任何地方执行。
它is显然正在运行。为什么我这里不能执行死刑?这张图表的含义是否与我认为的含义不同?
然而,它接着说
0 functions loaded
。再次,我可以确认该函数正在运行,因为我可以访问网站并查看值更新。
同样,文件必须存在,否则函数会崩溃并且不会更新值。导入时会失败。
最后,当我尝试在应用程序洞察中查询时,我看不到应用程序运行时出现的任何痕迹:
traces
| order by timestamp desc
| limit 50
不返回任何值。有系统日志:
4/27/2024, 6:48:52.944 PM
No job functions found. Try making your job classes and methods public. If you're using binding extensions (e.g. Azure Storage, ServiceBus, Timers, etc.) make sure you've called the registration method for the extension(s) in your startup code (e.g. builder.AddAzureStorage(), builder.AddServiceBus(), builder.AddTimers(), etc.).
4/27/2024, 6:48:52.942 PM
Generating 0 job function(s)
4/27/2024, 6:48:52.942 PM
0 functions loaded
4/27/2024, 6:48:52.941 PM
A function allow list has been specified, excluding all but the following functions: [resolveActionEvents, actionResolverTimer, ututimer]
4/27/2024, 6:48:52.941 PM
1 functions found (Custom)
4/27/2024, 6:48:52.941 PM
Reading functions metadata (Custom)
4/27/2024, 6:48:52.938 PM
Loading functions metadata
但是我可以确认的函数日志都没有在运行。我需要在其他一些功能中使用日志,但我无法在其他地方确认。确认函数执行的正确方法是什么?
为什么我不能在这里执行?我看不到应用程序运行时会出现的任何痕迹。
上述问题可能存在延迟或配置问题,导致门户无法正确识别已部署的功能。
我使用运行时堆栈 python 创建了 Http 触发器和计时器触发器函数。 检查日志配置和参数,如下面的代码:
功能代码:
import azure.functions as func
import logging
app = func.FunctionApp(http_auth_level=func.AuthLevel.ANONYMOUS)
@app.route(route="http_trigger")
def http_trigger(req: func.HttpRequest) -> func.HttpResponse:
logging.info('Python HTTP trigger function processed a request.')
name = req.params.get('name')
if not name:
try:
req_body = req.get_json()
except ValueError:
pass
else:
name = req_body.get('name')
if name:
return func.HttpResponse(f"Hello, {name}. This HTTP triggered function executed successfully.")
else:
return func.HttpResponse(
"This HTTP triggered function executed successfully. Pass a name in the query string or in the request body for a personalized response.",
status_code=200
)
@app.timer_trigger(schedule="0 */5 * * * *", arg_name="myTimer", run_on_startup=False,
use_monitor=False)
def timer_trigger(myTimer: func.TimerRequest) -> None:
if myTimer.past_due:
logging.info('The timer is past due!')
logging.info('Python timer trigger function executed.')
我已成功将功能部署到门户中,并且也能够在门户中运行功能。 检查以下内容以了解成功执行计数:
我能够在应用程序洞察中获取执行日志。检查下面:
输出:
检查功能应用程序配置中的环境变量,如下所示: