question

Minami avatar image
Minami asked

CallerEntityProfile.DisplayName is null in Azure Functions

Hi, I'm having trouble with FunctionExecutionContext<T>.CallerEntityProfile.DisplayName is null in Azure Functions (C#).

Here's the Azure Functions code in question.

public class Function1
{
    [FunctionName("Function1")]
    public string Run([HttpTrigger(AuthorizationLevel.Function, "get", "post", Route = null)] FunctionExecutionContext<string> request)
    {
        return request.CallerEntityProfile.DisplayName; // this is null
    }
}

* FunctionExecutionContext<T> uses this.
https://github.com/PlayFab/PlayFab-Samples/blob/master/Samples/CSharp/AzureFunctions/CS2AFHelperClasses.cs

I called this Azure Functions from a client using the C# SDK like this

var executeFunctionRequest = new ExecuteFunctionRequest
    {
        Entity = new PlayFab.CloudScriptModels.EntityKey()
        {
            Id = "41BBE5497F9DE458",
            Type = "title_player_account"
        },
        FunctionName = "FunctionA",
    };
    
await PlayFabCloudScriptAPI.ExecuteFunctionAsync(executeFunctionRequest);

At this time, Azure Functions received FunctionExecutionContext<T>.CallerEntityProfile.DisplayName is null.

{
    "CallerEntityProfile": {
        "AvatarUrl": "http://test.avatar.url",
        "Created": "2020-08-02T11:31:17.1484252Z",
        "DisplayName": null,
        "Entity": {
            "Id": "41BBE5497F9DE458",
            "Type": "title_player_account"
        },...

I can see the DisplayName in the GameManager. Is this a bug?

CloudScript
無題.png (22.9 KiB)
10 |1200

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.

1 Answer

·
Sarah Zhang avatar image
Sarah Zhang answered

Currently, it is expected behavior. As this thread says, the classic model and the entity model does not share the same Display Name now. So even if you have set the Display Name in the Game Manager or set it using the API UpdateUserTitleDisplayName. You still cannot get it from Entity Profile. Currently, the server API GetUserAccountInfo is still a reliable way to get the player’s title display name.

1 comment
10 |1200

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.

Minami avatar image Minami commented ·

Thanks for the answer, I understand!

0 Likes 0 ·

Write an Answer

Hint: Notify or tag a user in this post by typing @username.

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.