question

luisitolucas avatar image
luisitolucas asked

Sheduled task probllems

iam try to call a function from Scheduled Task using a segment to delete Master Player Accounts but throws fail Invocation of cloud script function "MasterDeleted" failed.

If i return a string, the function runs fine, but if i try to get the context from the request, i get internal server error.

The same function runs fine when called from the client.

   [FunctionName("HelloWorld")]
         public static async Task<string> Run(
             [HttpTrigger(AuthorizationLevel.Function, "post", Route = null)] HttpRequestMessage req,
             ILogger log)
         {
             var context = await FunctionContext.Create(req);
              var playerId = context.CallerEntityProfile.Lineage.MasterPlayerAccountId;
              return await PlayerUtil.HelloWorld(context.AuthenticationContext, playerId);
             return "hello" + context.ToString();
         }
scheduled tasks
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

·
Xiao Zha avatar image
Xiao Zha answered

Since Scheduled Task's context model is different from the context model that used when Azure Function called by the client, you cannot get the MasterPlayerAccountId via “context.CallerEntityProfile.Lineage.MasterPlayerAccountId”. You can use “var context=JsonConvert.DeserializeObject<PlayerPlayStreamFunctionExecutionContext>(await req.ReadAsStringAsync());” to get the context and obtain MasterPlayerAccountId with “context.PlayerProfile.PlayerId”.

For more information about CouldScript using Azure Function, you may refer to PlayFab CloudScript using Azure Functions Quickstart Guide - PlayFab | Microsoft Learn, and for more information about the context model, you may refer to PlayFab CloudScript using Azure Functions Context Models - PlayFab | Microsoft Learn.

10 |1200

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

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.