我想在本地开发环境(Node,OS X)中执行计时器触发的功能,但似乎需要对我拥有的HTTP触发功能设置进行一些更改。
这是到目前为止与计时器功能相关的代码:
/cron-job/function.json
定义了计划每分钟运行的计时器输入绑定。它还引用了代码入口点(从Typescript编译):
{
"bindings": [
{
"type": "timerTrigger","direction": "in","name": "timer","schedule": "0 */1 * * * *"
}
],"scriptFile": "../dist/cron-job/index.js"
}
/cron-job/index.ts
import { AzureFunction,Context } from '@azure/functions'
const timerTrigger: AzureFunction = async function (
context: Context,timer: any,) {
console.log('context',context)
console.log('timer',timer)
// move on with async calls...
}
export default timerTrigger
/local.settings.json
{
"IsEncrypted": false,"Values": {
"FUNCTIONS_WORKER_RUNTIME": "node","AzureWebJobsStorage": ""
}
}
当我尝试启动功能应用程序时:
~/Projects/test-api (dev) $ func start --verbose
我得到一个错误:
Missing value for AzureWebJobsStorage in local.settings.json. This is required for all triggers other than httptrigger,kafkatrigger. You can run 'func azure functionapp fetch-app-settings <functionAppName>' or specify a connection string in local.settings.json.
当我将AzureWebJobsStorage
设置添加到local.settings.json
时,出现另一个错误:
The listener for function 'Functions.cron-job' was unable to start.
The listener for function 'Functions.cron-job' was unable to start. microsoft.Azure.Storage.Common: Connection refused. System.Net.Http: Connection refused. System.Private.CoreLib: Connection refused.