Azure-functions-core-tools: ServiceBusQueueTrigger not working with azure-functions-cli

Created on 27 Apr 2017  路  9Comments  路  Source: Azure/azure-functions-core-tools

Hi,

I tried to run the ServiceBusQueueTrigger function (Javascript) using func run comment. But its giving the following error after putting "AzureWebJobsServiceBus" in appsettings.json.

Error indexing method 'Functions.ServiceBusQueue-JS'
Microsoft.Azure.WebJobs.Host: Error indexing method 'Functions.ServiceBusQueue-JS'. Microsoft.Azure.WebJobs.ServiceBus: Microsoft Azure WebJobs SDK ServiceBus connection string 'AzureWebJobsServiceBus' is missing or empty.

Could you please help me on this.

question

Most helpful comment

I am having the same issue. I am using VS 2017 Preview with Azure Functions Cli 1.0.0-beta.97.

I have the following in local.settings.json:

{
    "IsEncrypted": false,
  "Values": {
    "AzureWebJobsStorage": "DefaultEndpointsProtocol=https;AccountName=co...",
    "AzureWebJobsDashboard": "",
    "AzureWebJobsServiceBus": "Endpoint=sb://...."
  }
}

Then I have the standard method:


  public static class MessageConsumer
    {
        [FunctionName("InboundMessageTopicTrigger")]
        public static void Run([ServiceBusTrigger("......", "......", AccessRights.Manage, Connection = "Endpoint=sb://...")]string mySbMsg, TraceWriter log)
        {
            log.Info($"C# ServiceBus topic trigger function processed message: {mySbMsg}");
        }
    }

When I run it locally I get the following errors:

[5/19/17 7:09:33 PM] Starting Host (HostId=-2101161280, Version=1.0.10955.0, ProcessId=10216, Debug=False, Attempt=0)
[5/19/17 7:09:33 PM] A ScriptHost error has occurred
[5/19/17 7:09:33 PM] Microsoft.Azure.WebJobs.Host: Error indexing method 'Functions.InboundMessageTopicTrigger'. Microsoft.Azure.WebJobs.ServiceBus: Microsoft Azure WebJobs SDK ServiceBus connection string 'AzureWebJobsEndpoint=....' is missing or empty.

No job functions found. Try making your job classes and methods public. 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.).
[5/19/17 7:09:33 PM] Job host started

Any idea what I am doing wrong??? This is a new install and followed the example provided...

https://blogs.msdn.microsoft.com/webdev/2017/05/10/azure-function-tools-for-visual-studio-2017/

Thanks,

Chris

All 9 comments

Hey @riyajahamedi , I think I got it. You need to add the connection string to you appsettings.json file. In your case, you should do:

"Values":{ "AzureWebJobsServiceBus": "${your-connection-string}" }

Don't forget to also add an "AzureWebJobsStorage".

@cemarte I have added connection string in appsetting.json already. After adding that also i'm facing a same problem. Error is not changed after adding AzureWebJobsServiceBus & AzureWebJobsStorage values as well

@riyajahamedi Do you have encrypted=true in your settings file?

I am having the same issue. I am using VS 2017 Preview with Azure Functions Cli 1.0.0-beta.97.

I have the following in local.settings.json:

{
    "IsEncrypted": false,
  "Values": {
    "AzureWebJobsStorage": "DefaultEndpointsProtocol=https;AccountName=co...",
    "AzureWebJobsDashboard": "",
    "AzureWebJobsServiceBus": "Endpoint=sb://...."
  }
}

Then I have the standard method:


  public static class MessageConsumer
    {
        [FunctionName("InboundMessageTopicTrigger")]
        public static void Run([ServiceBusTrigger("......", "......", AccessRights.Manage, Connection = "Endpoint=sb://...")]string mySbMsg, TraceWriter log)
        {
            log.Info($"C# ServiceBus topic trigger function processed message: {mySbMsg}");
        }
    }

When I run it locally I get the following errors:

[5/19/17 7:09:33 PM] Starting Host (HostId=-2101161280, Version=1.0.10955.0, ProcessId=10216, Debug=False, Attempt=0)
[5/19/17 7:09:33 PM] A ScriptHost error has occurred
[5/19/17 7:09:33 PM] Microsoft.Azure.WebJobs.Host: Error indexing method 'Functions.InboundMessageTopicTrigger'. Microsoft.Azure.WebJobs.ServiceBus: Microsoft Azure WebJobs SDK ServiceBus connection string 'AzureWebJobsEndpoint=....' is missing or empty.

No job functions found. Try making your job classes and methods public. 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.).
[5/19/17 7:09:33 PM] Job host started

Any idea what I am doing wrong??? This is a new install and followed the example provided...

https://blogs.msdn.microsoft.com/webdev/2017/05/10/azure-function-tools-for-visual-studio-2017/

Thanks,

Chris

@doylestowncoder You can't use a connection string directly in the attribute. Use "Connection" = "ConnectionStringKey", and specify the value of that key in local.settings.json.

Missing value for AzureWebJobsStorage in local.settings.json. This is required for all triggers other than HTTP. You can run 'func azure functionapp fetch-app-settings ' or specify a connection string in local.settings.json.

Can you share a sample local.settings.json

@vimaljnelson In our team we incurred in this same issue. Actual structure of local.settings.json was not really clear to us as well.

Our understanding is that your connection string key+value should end up within "Values" section of JSON file (and not "ConnectionStrings" section as pointed to by other docs found around). So you end up with something like:

{
  "IsEncrypted": false,
  "Values": {
    "AzureWebJobsStorage": "DefaultEndpointsProtocol=https;AccountName <CONN. STRING TO STORAGE ACCOUNT>",
    "AzureWebJobsDashboard": "DefaultEndpointsProtocol=https;AccountName <CONN. STRING TO STORAGE ACCOUNT>",
    "YourServiceBusConnectionKey": "Endpoint=sb:// <CONN. STRING TO SERVICE BUS>",
  }
}

and in code you have:

c# [FunctionName("YourFunctionName")] public static void Run( [ServiceBusTrigger("your-queue-name", AccessRights.Manage, Connection = "YourServiceBusConnectionKey")]string myQueueItem, TraceWriter log)

Also, in Azure portal, make sure to add that connection string key+value within Application Settings in Function App configuration blade.

@doylestowncoder You can't use a connection string directly in the attribute. Use "Connection" = "ConnectionStringKey", and specify the value of that key in local.settings.json.

This is an old thread but I wanted to note that using the vs 2019 wizard for creating a service bus topic triggered function automatically puts your connection string directly in the ServiceBusTrigger attribute. Your suggested fix still works but the product is still broken.

This thread has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs.

Was this page helpful?
0 / 5 - 0 ratings