5

I'm trying to set up an Azure Function that I want to trigger when a message is put on a Service Bus queue. However, I can´t get it to work. The first "log.Info" does not trigger.

I deployed an Http trigger together with my Service Bus trigger and that works.

Some screenshots is shown below. I´ve already tried to remove the json string with key "generatedBy", as I saw as a suggestion on Google.

There are two files in my Visual Studio project which I have not edited: host.json and local.settings.json, I can´t find information about how to set them up or if it´s necessary at all.

Can anyone help me?

Several screen shots

Martin Nilsson
  • 459
  • 1
  • 5
  • 15

2 Answers2

11

The Connection property of ServiceBusTrigger attribute should refer to a setting name, e.g. ServiceBusConnectionString.

Then, you should put the setting with same name to local.settings.json for local development and to Application settings for Azure.

Mikhail Shilkov
  • 34,128
  • 3
  • 68
  • 107
  • @Martin, https://learn.microsoft.com/en-us/azure/azure-functions/functions-run-local#local-settings-file – evilSnobu Mar 02 '18 at 11:18
  • Note: "Settings in the local.settings.json file are only used by Functions tools when running locally. By default, these settings are not migrated automatically when the project is published to Azure. Use the --publish-local-settings switch when you publish to make sure these settings are added to the function app in Azure." Docs: https://learn.microsoft.com/en-us/azure/azure-functions/functions-run-local Alternatively, you can add them by clicking "Manage Application Settings..." in the Publish screen, and entering the key/value pair there. – BobbyA May 31 '18 at 19:47
  • Here's documentation on "Manage Application Settings": https://blogs.msdn.microsoft.com/webdev/2017/11/15/improvements-to-azure-functions-in-visual-studio/#ManageApplicationSettings – BobbyA May 31 '18 at 19:59
  • A doubt: For example if I have { "clients": { "mapId": "AZ35" } } in my local.settings.json, what do I have to put in Application settings in the cloud? Even more, for serviceBus triggers the doc says that you can use "whateverSBConnectionStringName", but after lots of testing we found that it only works if you put inside "values" in local.settings.json as: { "values": { "whateverSBConnectionStringName": ""} }. How does it translate to Application settings for Azure?. Docs are not clear at all – zameb Sep 30 '21 at 20:47
4

I needed to append this bit to my ServiceBusConnectionString when running locally: ;TransportType=AmqpWebSockets

Rachel
  • 686
  • 1
  • 6
  • 18