- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
我有一个在 Linux 系统中运行的 azure 函数应用程序。在其中,我创建了两个函数,一个由 blob 触发器触发,另一个由 timetrigger 触发。
这两个功能都是通过azure DevOps部署的,但是当我进入门户时,时间触发功能不存在。
为了部署这些功能,我在 Git 存储库中拥有代码,并将其复制到 .zip 文件夹以构建工件。构建工件后,将使用 azure cli 将其部署到功能应用程序。
代码:
函数.json
{
"schedule": "0 30 14 * * *",
"name": "myTimer",
"type": "timerTrigger",
"direction": "in",
"runOnStartup": false
}
主机.json
{
"version": "2.0",
"logging": {
"fileLoggingMode": "always",
"applicationInsights": {
"samplingSettings": {
"isEnabled": true
}
}
},
"extensions": {
"queues": {
"maxPollingInterval": "00:00:02",
"visibilityTimeout" : "00:00:30",
"batchSize": 8,
"maxDequeueCount": 5,
"newBatchThreshold": 4,
"messageEncoding": "base64"
}
},
"extensionBundle": {
"id": "Microsoft.Azure.Functions.ExtensionBundle",
"version": "[3.3.0, 4.0.0)"
},
"functionTimeout": "-1",
"retry": {
"strategy": "fixedDelay",
"maxRetryCount": 0,
"delayInterval": "00:00:05"
}
}
init.py
import datetime
import logging
import azure.functions as func
def main(mytimer: func.TimerRequest) -> None:
utc_timestamp = datetime.datetime.utcnow().replace(
tzinfo=datetime.timezone.utc).isoformat()
if mytimer.past_due:
logging.info('The timer is past due!')
logging.info('Python timer trigger function ran at %s', utc_timestamp)
解决方案
我配置了错误的 function.json 文件。正确的内容是:
{
"bindings": [
{
"schedule": "0 30 14 * * *",
"name": "myTimer",
"type": "timerTrigger",
"direction": "in",
"runOnStartup": false
}
],
"disabled": false,
"scriptFile": "__init__.py"
}
最佳答案
感谢您确认@vll1990,将解决方案作为答案发布,这对于解决类似问题的其他成员来说是有益的,以便他们能够找到并解决他们的问题。
我们尝试使用计时器触发器创建一个 python azure 函数,并发现我们需要以下格式的 function.json
文件。
您使用的function.json
是:
{
"schedule": "0 30 14 * * *",
"name": "myTimer",
"type": "timerTrigger",
"direction": "in",
"runOnStartup": false
}
相反,我们需要在 .json
文件中添加值之前指定绑定(bind)
。例如:-
{
"bindings": [
{
"schedule": "0 30 14 * * *",
"name": "myTimer",
"type": "timerTrigger",
"direction": "in",
"runOnStartup": false //
}
],
"disabled": false,
"scriptFile": "__init__.py"
}
部署后,我们将能够在 Portal 本身的函数应用程序中看到计时器函数。
有关更多信息,请参阅此微软文档 | Timer trigger for Azure Functions .
关于python - 门户中不存在 Azure 函数 timeTrigger,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/72698107/
我目前无法在使用 Function CLI 版本 2.3.148 和 2.3.199 的 macO 中运行 TimeTrigger 函数: 这是我的 csproj: netstanda
我有一个名为 POEditorTranslations 的 Azure 函数,其 TimeTrigger 设置为: * */10 * * * * 首先是公共(public)静态异步任务 POEdito
我有一个在 Linux 系统中运行的 azure 函数应用程序。在其中,我创建了两个函数,一个由 blob 触发器触发,另一个由 timetrigger 触发。 这两个功能都是通过azure DevO
我正在尝试创建一个 Azure WebJob,它将在设定的计时器上执行 Functions.Methods。我在 VS2017 中设置了一个简单的 WebJob 项目,并添加了 Microsoft.A
我已遵循 Microsoft 指南创建和注册后台任务:https://msdn.microsoft.com/en-us/library/windows/apps/mt299100.aspx 我有我的主
当我尝试从“新解决方案”模板创建“计时器触发器”应用程序时,Visual Studio Professional 2022(创建新项目 -> Azure Functions -> 计时器触发器)会创建
当我尝试从“新解决方案”模板创建“计时器触发器”应用程序时,Visual Studio Professional 2022(创建新项目 -> Azure Functions -> 计时器触发器)会创建
在我的 UWP 应用程序中,我有一个由 TimeTrigger 触发的后台任务。在后台任务的代码中,我有这个片段(我的示例中的“第一个事件”和“第二个事件”几乎不消耗任何资源): var deferr
在我的 Windows 8 Metro 应用程序的后台任务中运行时,Client.GetAsync 对我来说似乎失败了。 我尝试同时使用 TimeTrigger 和 MaintenanceTrigge
我发现使用 TimeTrigger 是 Windows 10 (UWP) 上计划后台任务的方式。但是看起来我们需要给出的最小数字是 15 分钟。只是想知道,即使我们安排它在接下来的 1 分钟内运行,警
这是我的场景:我在同一个解决方案中有一个 Windows Phone 8.1 应用程序 (MainApp)、一个类库和一个 Windows 运行时组件 (BackgroundTask)。 当我加载我的
我已在 Visual Studio Code 中成功创建了 Azure 时间触发器。 我在上传到 Azure 门户之前在 VSC 中对其进行了测试,并且运行正常 当我在 Azure 中运行它时,它给我
我已在 Visual Studio Code 中成功创建了 Azure 时间触发器。 我在上传到 Azure 门户之前在 VSC 中对其进行了测试,并且运行正常 当我在 Azure 中运行它时,它给我
我是一名优秀的程序员,十分优秀!