Azure Function Compiler Issues

796 views Asked by At

I have titled this post as a compiler issue, but can't possibly understand what's going wrong, consider the following beforehand,

System.Security.Claims.ClaimsPrincipal pCPlFacebookUser = System.Security.Claims.ClaimsPrincipal.Current;
String pStrEmail = pCPlFacebookUser.FindFirst(System.Security.Claims.ClaimTypes.Email).Value;
Storage pStoMembership = new Storage("TableStorageRootURL", "AzureWebJobsStorage", "ServiceInfo");
User pUsrUser = pStoMembership.GetUser(pStrEmail);

This works fine, function continues normally, at this point and at this state, my pUsrUser object should be null, there's nothing in storage, so it's definitely null, can't be anything else.

If I write the line,

return(req.CreateResponse(HttpStatusCode.OK, "WTF?"));

I get "WTF?" returned by the function, great. But if I do this,

if(pUsrUser == null)
{
    return(req.CreateResponse(HttpStatusCode.OK, "WTF?"));
}

I get the following,

{"Message":"An error has occurred."}

What's going on?? I can't evaluate the return value from GetUser, any attempt to do so results in this error, even directly within the if statement.

1

There are 1 answers

2
Nick On BEST ANSWER

Typical, that as usual, after beating my head against a wall to try and resolve something, a few moments after asking on a forum, I find the answer.

Basically what I did to flush the error out was to try the function locally using the Azure Function Tools for Visual Studio. Although my function still won't work locally for another reason, it did point out that I was missing an assembly reference used by the User class. After adding the assembly reference to my Azure Function, the problem went away. In this instance it was,

#r "Microsoft.WindowsAzure.Storage"

using Microsoft.WindowsAzure.Storage.Table;

Nick.