question

Ethan K. G avatar image
Ethan K. G asked

Call IncrementPlayerStatisticVersion from Azure Functions

Here is the leaderboard reset Azure Functions I used, in case somebody needs it:

        [FunctionName("ResetLB")]
        public static async Task<dynamic> ResetLB(
            [HttpTrigger(AuthorizationLevel.Function, "post", Route = null)] 
            HttpRequestMessage req, ILogger log)
        {
            var context = await FunctionContext<dynamic>.Create(req);
            var args = context.FunctionArgument;
            var lbName = args["LBName"];

            var newRequest = new PlayFab.AdminModels.IncrementPlayerStatisticVersionRequest { StatisticName = lbName };
            var adminApi = new PlayFabAdminInstanceAPI(context.ApiSettings, context.AuthenticationContext); //PlayFabAdminAPI/PlayFabAdminInstanceAPI
            var newResult = await adminApi.IncrementPlayerStatisticVersionAsync(newRequest);
            log.LogInformation($">> ResetLB: {0}, v{1}, DeactivationTime: {2}", newResult.Result.StatisticVersion.StatisticName
                , newResult.Result.StatisticVersion.Version
                , newResult.Result.StatisticVersion.DeactivationTime);

            // return IncrementPlayerStatisticVersionResult (PlayerStatisticVersion in it)
            return new { newResult.Result };
        }


I already added NuGet packages: PlayFabAllSDK & PlayFabCloudScriptPlugin.

Leaderboards and Statistics
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.

Jérémie Fouché avatar image Jérémie Fouché commented ·

The Task is Failed when i try this code.
Someone can help me to solve that please ?

0 Likes 0 ·
screenshot-7.png (49.9 KiB)
Sarah Zhang avatar image
Sarah Zhang answered

Thanks for sharing.

10 |1200

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

yagiFM31 avatar image
yagiFM31 answered

@Ethan K. G

I have a question.

I would like to use this code to reset the leaderboard.

However I can't figure out how to use this code.

If possible, please tell me the detailed usage.

I'm writing code in C# using Visual Studio Code.

I was able to register the sample code with Azure Functions instead of this code.

However, when I write this code in Visual studio code, I get error in "HttpRequestMessage" and "FunctionContext<dynamic>".

I would appreciate it if you would tell me about this. Thank you.

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.

Jérémie Fouché avatar image Jérémie Fouché commented ·

Did you solve that since april ?

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.