Q:

Checking if record exists in Azure Function (C#)

I am trying to figure out how to check if a record exists before adding it using BindAsync in an Azure Function. Is there a way to do this using my existing implementation or do I need to use a different method?
Specifically check out the bottom of the function around the "output" local variable.
[FunctionName("Signup")]
public static async Task<IActionResult> Signup([HttpTrigger(AuthorizationLevel.Anonymous, "post", Route ="user/signup")] HttpRequest Req, Binder binder, ILogger log)
{
    var UserId = System.Guid.NewGuid().ToString();
    var FirstName = Req.Form["FirstName"];
    var LastName = Req.Form["LastName"];
    string FbId = null;
    if (Req.Form.ContainsKey("FbId"))
    {
        FbId = Req.Form["FbId"];
    }
    var Email = Req.Form["Email"];
    var PasswordPlain = Req.Form["Password"];
    string hash;
    hash = BCrypt.Net.BCrypt.HashPassword(PasswordPlain);

    var ProfilePic = Req.Form.Files.GetFile("ProfilePic");
    var ProfilePicStream = ProfilePic.OpenReadStream();
    var ProfilePicFileName = await UploadImage(ProfilePicStream, UserId, binder);

    if (FbId == null)
    {
        log.LogInformation("No FB detected");
    }
    else
    {
        log.LogInformation("FB detected");
    }
    var NewUser = new UserTableEntity
    {
        PartitionKey = 1.ToString(),
        RowKey = UserId,
        FirstName = FirstName,
        LastName = LastName,
        FbId = FbId,
        Email = Email,
        ProfilePic = ProfilePicFileName,
        Password = hash
    };

    var attributes = new System.Attribute[]
    {
        new StorageAccountAttribute("TabbrDevCosmosDb"),
        new TableAttribute("Users")
    };

    var output = await binder.BindAsync<IAsyncCollector<UserTableEntity>>(attributes);
    await output.AddAsync(NewUser);
    return new OkObjectResult(JsonConvert.SerializeObject(NewUser));
}  

A:

We have to do it in a basic way, execute query to find whether there's a record duplicate.
Add declarative Table input binding for the sake of query
public static async Task<IActionResult> Signup(
    [HttpTrigger(AuthorizationLevel.Anonymous, "post", Route = "user/signup")] HttpRequest Req, 
    [Table("Users", Connection = "TabbrDevCosmosDb")]CloudTable table, 
    Binder binder, ILogger log)

Execute query,  take Email as an example.
TableQuery<UserTableEntity> existQuery = new TableQuery<UserTableEntity>().Where(
    TableQuery.GenerateFilterCondition("Email", QueryComparisons.Equal, Email));

var queryResult = table.ExecuteQuerySegmentedAsync(existQuery, null).Result.Results;

if (queryResult.Count == 0)
{
    var attributes = new System.Attribute[]
    {
        new StorageAccountAttribute("TabbrDevCosmosDb"),
        new TableAttribute("Users")
    };
    var output = await binder.BindAsync<IAsyncCollector<UserTableEntity>>(attributes);
    await output.AddAsync(NewUser);
    return new OkObjectResult(JsonConvert.SerializeObject(NewUser));
}
else
{
    return new BadRequestObjectResult("Already exists");
}

