首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >错误:无法将参数' ExecutionContext‘绑定到类型ExecutionContext

错误:无法将参数' ExecutionContext‘绑定到类型ExecutionContext
EN

Stack Overflow用户
提问于 2019-08-28 06:56:00
回答 1查看 392关注 0票数 1

我有一个Azure框架控制台应用程序,我可以在.Net中成功地将其作为WebJob发布,并看到它正在运行。当我试图向我的函数添加一个ExecutionContext参数时,我收到了上面的错误消息(与参数的位置无关)。

我已经尝试将参数移动到方法签名中的每个位置。每次都有相同的错误。

Startup.cs

代码语言:javascript
复制
            var config = new JobHostConfiguration
            {
                JobActivator = new AuditorSyncActivator(serviceProvider)
            };

            // Setting the value of connection limit to that which the Sandbox would impose
            // which should be sufficient for the application going forward, given demand.
            ServicePointManager.DefaultConnectionLimit = 300;

            // We are using an NCRONTAB expression to run the function on a schedule
            config.UseTimers();
            var host = new JobHost(config);

            // The following code ensures that the WebJob will be running continuously
            host.RunAndBlock();
        }

Functions.cs

代码语言:javascript
复制
        [FunctionName("AuditorSync")]
        public void ProcessQueueMessage(
            [TimerTrigger("0 */5 * * * *", RunOnStartup = false)] TimerInfo timer,
            ExecutionContext executionContext,
            Microsoft.Extensions.Logging.ILogger logger)
        {
            if (timer.IsPastDue)
            {
                _logger.Warning("Timer is running late");
            }

            _logger.Information($"WebJob Function Execution: Id={executionContext.InvocationId}, Action={_config.GetSection("AuditorSyncOptions")["Action"]}");
        }

根据Documentation的说法,我希望它能在Azure上运行,没有问题。我在Azure上的日志中看到的是

代码语言:javascript
复制
[08/27/2019 22:28:03 > e3a876: ERR ] Unhandled Exception: Microsoft.Azure.WebJobs.Host.Indexers.FunctionIndexingException: Error indexing method 'Functions.ProcessQueueMessage' ---> System.InvalidOperationException: Cannot bind parameter 'executionContext' to type ExecutionContext. Make sure the parameter Type is supported by the binding. If you're using binding extensions (e.g. ServiceBus, Timers, etc.) make sure you've called the registration method for the extension(s) in your startup code (e.g. config.UseServiceBus(), config.UseTimers(), etc.).

所有这些都没有很好的文档记录,并且有几个版本被支持...我使用的是2.x版本的WebJobs...

欢迎任何想法:)

EN

回答 1

Stack Overflow用户

回答已采纳

发布于 2019-08-28 12:07:34

您可以将其注册到调用config.UseCore(),之后您将能够使用ExecutionContext来检索有关当前运行的函数的信息。

更多信息,你可以参考这个文档:Core Extensions。下面是我的测试。

代码语言:javascript
复制
static void Main(string[] args)
    {
        var config = new JobHostConfiguration();
        config.DashboardConnectionString = "connection";
        config.UseTimers();
        config.UseCore();


        var host = new JobHost(config);
        host.RunAndBlock();
    }

票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/57683137

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档