简体   繁体   中英

FunctionIndexingException when missing ServiceBusConnectionString

I create the following program:

using System;
using Microsoft.Azure.WebJobs;

namespace StayUpdated.Cpe.PypyFilter
{
    public class Program
    {
        public static void Main()
        {
            var jobHost = new JobHost();
            jobHost.RunAndBlock();
        }

        public static void ProcessQueue([ServiceBusTrigger("start")] String input)
        {
        }
    }
}

In the app.config I add the following connection strings:

<add name="AzureWebJobsDashboard" connectionString="DefaultEndpointsProtocol=https;AccountName=cpepypywebjobstorage;AccountKey=2iCufOrnXeY/B/VJptegGXaAbEmoj1SOgiiAbunk1kDAPqhkgvcOj3NEVGqtm0363GHu/h6Fy8JfoWEpKCP2Rw==" />
<add name="AzureWebJobsStorage" connectionString="DefaultEndpointsProtocol=https;AccountName=cpepypywebjobstorage;AccountKey=2iCufOrnXeY/B/VJptegGXaAbEmoj1SOgiiAbunk1kDAPqhkgvcOj3NEVGqtm0363GHu/h6Fy8JfoWEpKCP2Rw==" />

I get a FunctionIndexingException exception with message, Error indexing method 'ProcessQueue' .

This is caused by the lack of an AzureWebJobsServiceBus connection string. You must either add that connection string or manually connect a ServiceBusConnectionString via a JobHostConfiguration .

You can look at the inner exception on that exception and see that it is a ConfigurationErrorsException with a message:

Configuration is missing required information. Make sure the property 'Endpoint' is defined as part of 'Microsoft.ServiceBus.ConnectionString' key within 'appSettings' section, or Windows Azure configuration settings.

Unfortunately, following the instructions provided in the exception message will not work.

I believe the cause is because without the service bus connection string, the JobHost doesn't load whatever it needs to load in order to successfully parse the ServiceBusTrigger attribute.

It would be much better if the error you received was along the lines of,

Attempted to setup a ServiceBusTrigger without a ServiceBusConnectionString.

Even better would be to just log a warning that there are triggers that will never be hit and continue. One might want to have triggers setup but not always have a service bus connection string.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM