Functions (1 / 54): A logistics company wants to build a system that can handle incoming requests for package pickups and deliveries. They need a function that gets triggered every time a new pickup or delivery request is placed. The function should then push this information to a queue for further processing. How would you approach this requirement? Fill in the triggers and bindings in the following code:
[FunctionName("HandleDeliveryRequest")]
public static void Run(
/* Triggers and Bindings here */
ILogger log)
{
// Process the incoming delivery request
// Prepare the output request
// The output request is automatically added to the queue
}
Answer:
Queue Storage could be the trigger in this scenario. When a new pickup or delivery request is received, a new message could be added to a Queue Storage, which would trigger the function. The function could then perform necessary processing or further add the information to another queue for further processing.
[FunctionName("HandleDeliveryRequest")]
public static void Run(
[QueueTrigger("<queue-name>", Connection = "StorageConnectionString")]
DeliveryRequest deliveryRequest,
[Queue("<output-queue-name>", Connection = "StorageConnectionString")]
out DeliveryRequest outputRequest,
ILogger log)
{
// Process the incoming delivery request
// Prepare the output request
// The output request is automatically added to the queue
}