Azure Serverless Computing Cookbook
上QQ阅读APP看书,第一时间看更新

Create Storage Queue binding to the HTTP Trigger

Perform the following steps:

  1. Navigate to the Integrate tab of the RegisterUser function and click on the New Output button to add a new output binding.
  1. Choose Azure Queue Storage and click on the Select button to add the binding and provide the values shown in the following screenshot and then click on Save button. Please make note of the Queue name (in this case, notificationqueue), which will be used in a moment:

  1. Navigate to the Run method of the RegisterUser function and make the following highlighted changes. We added another Queue output binding and added an empty message to trigger the Queue Trigger function. For now, we didn't add any message to the queue. We will make changes to the NotificationQueueItem.AddAsync(""); method in the upcoming recipe of this chapter:
public static async Task<IActionResult> Run(
HttpRequest req,
CloudTable objUserProfileTable,
IAsyncCollector<string> objUserProfileQueueItem,
IAsyncCollector<string> NotificationQueueItem,
ILogger log)
{
log.LogInformation("C# HTTP trigger function processed a request.");
string firstname=null,lastname = null;
...
...
await NotificationQueueItem.AddAsync("");
return (lastname + firstname) != null
? (ActionResult)new OkObjectResult($"Hello, {firstname + " " + lastname}")
: new BadRequestObjectResult("Please pass a name on the query" +
"string or in the request body");
}