Share via

AzureFunction in JAVA - Getting QueueName from output binding

Anonymous
2021-11-22T11:48:36.763+00:00

My question regards Azure FunctionApp run in JAVA that uses Azure Queue Storage as function output.

There is a sample in Microsoft doc (source: https://learn.microsoft.com/en-us/azure/azure-functions/functions-bindings-storage-queue-output?tabs=java#example)

   @FunctionName("httpToQueue")  
   @QueueOutput(name = "item", queueName = "myqueue-items", connection = "MyStorageConnectionAppSetting")  
    public String pushToQueue(  
        @HttpTrigger(name = "request", methods = {HttpMethod.POST}, authLevel = AuthorizationLevel.ANONYMOUS) final String message,  
        @HttpOutput(name = "response") final OutputBinding<String> result) {  
          result.setValue(message + " has been added.");  
          return message;  
    }  

Is it possible to get the Queue Name from the "result" output?
It means, I would like to get the "request" variable in abovementioned sample.
I would need it for logging purposes. The name of Queue can be parametrized and set as environment variable as well, so getting the name of output queue from the "result" variable is the safest way, I suppose.

Azure Functions
Azure Functions

An Azure service that provides an event-driven serverless compute platform.

Azure Queue Storage
Azure Queue Storage

An Azure service that provides messaging queues in the cloud.

0 comments No comments

Answer accepted by question author

Pramod Valavala 20,661 Reputation points Microsoft Employee Moderator
2021-11-23T04:33:10.147+00:00

anonymous user There is no way to get the queue name when using an output binding. Like you said, it can be an environment variable, so the only way would be to get it from there directly in your code.

Was this answer helpful?

0 comments No comments

0 additional answers

Sort by: Most helpful

Your answer

Answers can be marked as 'Accepted' by the question author and 'Recommended' by moderators, which helps users know the answer solved the author's problem.