Modifying the Azure Function code

While this is all quite exciting (it should be, this is really cool tech), we need to make a few changes to the Azure Function to meet our requirements:

  1. Identify the return statement in your Azure Function. It will look as follows:
      return name == null 
        ? req.CreateResponse(HttpStatusCode.BadRequest,         "Please pass a name on the query string or in the request           body") 
        : req.CreateResponse(HttpStatusCode.OK, "Hello " + name); 

Let's simplify the code a bit and just return true if the email address is not empty. Replace the return statement with the following code:

      if (email == null) 
        return req.CreateResponse(HttpStatusCode.BadRequest,         "Please pass an email address on the query string or in the request body"); ...

Get C# 7 and .NET Core 2.0 Blueprints now with the O’Reilly learning platform.

O’Reilly members experience live online training, plus books, videos, and digital content from nearly 200 publishers.