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:
- Identify the
returnstatement 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");
}
else
{
bool blnValidEmail = false;
if (email.Length > 0)
{
blnValidEmail = true;
}
return...