question

juanrodriguezgiles avatar image
juanrodriguezgiles asked

Scheduled Task fails to run Azure CloudScript

Hi, i'm trying to execute an Azure CloudScript function through a Scheduled Task but it keeps failing. I need to get and set a value on Internal Title Data. Here's the code and error.

[FunctionName("TaskTest")]
public static async Task Run([HttpTrigger(AuthorizationLevel.Function, "post", Route = null)] HttpRequest req, ILogger log)
{
    string body = await req.ReadAsStringAsync();
    ScheduledTaskFunctionExecutionContext<object> ctx = JsonConvert.DeserializeObject<ScheduledTaskFunctionExecutionContext<object>>(body);

    if (ctx.TitleAuthenticationContext != null)
    {
        SetTitleDataRequest request = new SetTitleDataRequest
        {
            Key = "Test",
            Value = "1",
            TitleId = ctx.TitleAuthenticationContext.Id
        };
        await PlayFabAdminAPI.SetTitleInternalDataAsync(request);
    }
}
4704-error.png (58.8 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

·
Gosen Gao avatar image
Gosen Gao answered

You need to set a Secret Key to call PlayFab Admin APIs. Please add this code before you call the Admin API.

PlayFabSettings.staticSettings.DeveloperSecretKey = "YOUR SECRET KEY";
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.