Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ServiceBusQueueTrigger not working with azure-functions-cli #128

Closed
riyajahamedi opened this issue Apr 27, 2017 · 9 comments
Closed

ServiceBusQueueTrigger not working with azure-functions-cli #128

riyajahamedi opened this issue Apr 27, 2017 · 9 comments
Labels

Comments

@riyajahamedi
Copy link

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.

@cemarte
Copy link

cemarte commented Apr 29, 2017

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".

@riyajahamedi
Copy link
Author

@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

@lindydonna
Copy link
Contributor

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

@doylestowncoder
Copy link

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

@lindydonna
Copy link
Contributor

@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.

@vimaljnelson
Copy link

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

@BrainCrumbz
Copy link

BrainCrumbz commented Nov 27, 2017

@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:

[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.

@lanatmwan
Copy link

@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.

@lock
Copy link

lock bot commented Dec 18, 2019

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.

@lock lock bot locked as resolved and limited conversation to collaborators Dec 18, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Projects
None yet
Development

No branches or pull requests

7 participants