Functions (1 / 54): A media company requires an Azure function to accumulate real-time news data from various online sources (webhooks) and subsequently deposit the collected data in a particular format into a database. Given the need to store large amounts of unstructured data that will be accessed infrequently, what approach would you suggest? Please provide the triggers and bindings in the provided code:
[FunctionName("CollectNewsData")]
public static async Task<IActionResult> Run(
/* Triggers and Bindings here */
ILogger log)
{
// Parse the incoming data
// Process the news data, if necessary
// Add the news data to storage
// Return a success response
}
Answer:
To gather real-time news data from diverse web sources, an HTTP trigger could be utilized. The function could then reformat the amassed data and employ an output binding to a service that specializes in storing large amounts of unstructured data and is cost-effective for infrequent data access - Azure Blob Storage - to deposit the data.
[FunctionName("CollectNewsData")]
public static async Task<IActionResult> Run(
[HttpTrigger(AuthorizationLevel.Function, "post", Route = null)]
HttpRequest req,
[Blob("<container-name>/<blob-name>", FileAccess.Write, Connection = "<storage-connection-string>")]
Stream outputBlob,
ILogger log)
{
// Parse the incoming data
// Process the news data, if necessary
// Add the news data to storage
// Return a success response
}