Reputation: 89
I'm a newbie to Azure Functions, and i have written an Azure function to create a new resource for me in Azure . The function returns an Id wrapped in a type ive created.
The main reason for this is that i have written integrations tests that does some checks and teardown process based on the Id returned from the function.
[FunctionName("SomeAzFunction")]
public async Task<MyNewReturnType> Run(
[ServiceBusTrigger("%topic-name%", "some-subscription", Connection = "service-bus-connection-string")]
string message,
ILogger log)
However When deployed, i'm getting this following error. Is it mandatory to have a output bindings if an Azure function has return values? Or am i approaching Azure functions incorrectly?
Function (SomeAzFunction) Error: Microsoft.Azure.WebJobs.Host: Error indexing method 'SomeAzFunction'. Microsoft.Azure.WebJobs.Host: Cannot bind parameter '$return' to type MyNewReturnType&. Make sure the parameter Type is supported by the binding. If you're using binding extensions (e.g. Azure Storage, ServiceBus, Timers, etc.) make sure you've called the registration method for the extension(s) in your startup code (e.g. builder.AddAzureStorage(), builder.AddServiceBus(), builder.AddTimers(), etc.).
Upvotes: 0
Views: 1798
Reputation: 8183
I think you are approaching this slightly wrong.
So you have a function that is consuming messages from your Service Bus. You do some processing and then you are returning a value, where do you expect it to be returned? If you want to place a message back on the service bus then you can use a Service Bus Output binding, see available bindings here.
Or you could create a SubscriptionClient/TopicClient
and publish a message manually to that subscription/topic.
If you are only returning a value for your integration tests to verify, then I suggest you move that code into a separate class that you function calls and test that.
Upvotes: 4