Question:
You're working for an e-commerce company that has high traffic and they're dealing with large amounts of customer orders. The company wants to keep a track of every order received in real-time and then send an automated confirmation email to the customer. Which Azure service would you choose to trigger your Azure function? Fill in the triggers and bindings in the following code:
[FunctionName("ProcessOrder")]
public static void Run(
/* Triggers and Bindings here */
ILogger log)
{
// Process the incoming order
// Prepare an email message
// Assign the message to the 'message' output binding to send email
}
Answer:
In this case, the Azure function could be triggered by the Service Bus where each order corresponds to a message in a Service Bus Queue or Topic. The function could then use the SendGrid output binding to send a confirmation email to the customer.
[FunctionName("ProcessOrder")]
public static void Run(
[ServiceBusTrigger("<queue-name>", Connection = "ServiceBusConnectionString")]
Order order,
[SendGrid(ApiKey = "SendGridApiKey")]
out SendGridMessage message,
ILogger log)
{
// Process the incoming order
// Prepare an email message
// Assign the message to the 'message' output binding to send email
}