question

abuhurairazahid536 avatar image
abuhurairazahid536 asked

CallerEntityProfile is always Null when I execute Azure Function from a Rule on Triggering Player_added_title event

I am trying to execute an Azure Function from a Rule that executes on event player_added_title. Upon debugging I got to know that context.CallerEntityProfile is null in azure when it executes due to which fucntion doesnt executes successfully. I know that this event has payload with callerentityprofile but azure function is getting it null. Please help me out I'm stuck.

Player DataPlayer Inventory
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

·
Neils Shi avatar image
Neils Shi answered

Please note that if you want to execute the Azure Function from Rule, you should use “var context=JsonConvert.DeserializeObject<PlayerPlayStreamFunctionExecutionContext>(await req.ReadAsStringAsync());” to get the context and obtain the info you want. For more information, please refer to PlayFab CloudScript using Azure Functions Context Models - PlayFab | Microsoft Learn.

2 comments
10 |1200

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

abuhurairazahid536 avatar image abuhurairazahid536 commented ·
  PlayerPlayStreamFunctionExecutionContext<dynamic> context = JsonConvert.DeserializeObject<PlayerPlayStreamFunctionExecutionContext<dynamic>>(await req.ReadAsStringAsync());

I'm using this to store context from a com.player_added_title playstream event.

0 Likes 0 ·
Neils Shi avatar image Neils Shi abuhurairazahid536 commented ·

As mentioned before, if you want to execute function via rule, then you need to use “var context=JsonConvert.DeserializeObject<PlayerPlayStreamFunctionExecutionContext>(await req.ReadAsStringAsync());” You can get the information you want via PlayStreamEventEnvelope property in PlayerPlayStreamFunctionExecutionContext. For more info, you can refer to How should the rule context be handled in azure function? - Playfab Community.

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.