This has nothing to do with Azure. It's a keyword of the C# programming language.
The async keyword makes it so that the thread that executes the method can temporarily 'exit' the method when it encounters the await keyword in the body of the method, so it can resume doing other useful stuff while the task inside the method that is being awaited is blocking execution.
An async method must declare that it returns either a Task or a void. The nice thing about async is that you don't actually have to return a Task instance with the return keyword, the language will do it for you. Here is an example:
WeatherService represents an external service that may take a relatively long time to return a response. Instead of making the thread that calls the GetWeatherReportAsync() method sit around and do nothing, the await keyword allows it to exit the method and go and do something else. When a response returns from the external service, the virtual machine will try to grab the original thread that was executing the method if it is idle, and let it execute the remainder of the async method.
You can write the same logic without async, but you'll see that it is much less pleasant:
posted 2 weeks ago
Thanks. If this is a http trigger call then does it have to wait in such cases for the slow operation to get over to get a return value?
So this is keyword of C# programming language and has nothing to do with azure functions. azure functions can be written in Java too. Since there is no such keyword in Java, how is the same thing achieved in java?
Stephan van Hulst
posted 2 weeks ago
In Java the preferred way to do this is to submit a task to an ExecutorService. However, in many frameworks creating your own executors is usually a bad idea. I don't know if Azure provides executors for you to submit your tasks to. I think your best bet is to ask this question on an Azure message board.