question

webdornald avatar image
webdornald asked

admin api call problem in azure,Why aren't some admin functions called?

I am using the admin api and have a problem. Even though I created a function instance with the same settings, some functions are executed, but some functions say that I need to set the developer key. However, the developer key is already set. What's the problem?

    [FunctionName("SampleAdminFunc")]
         public static async Task<dynamic> SampleAdminFunc(
             [HttpTrigger(AuthorizationLevel.Function, "get", "post", Route = null)] HttpRequest req, ILogger log)
         {
             string body = await req.ReadAsStringAsync();
             log.LogInformation($"Body: {body}");
        
             var apiSettings = new PlayFabApiSettings
             {
                 TitleId = Environment.GetEnvironmentVariable("PLAYFAB_TITLE_ID", EnvironmentVariableTarget.Process),
                 DeveloperSecretKey =
                     Environment.GetEnvironmentVariable("PLAYFAB_DEV_SECRET_KEY", EnvironmentVariableTarget.Process),
             };
        
             var playfabAdminApi = new PlayFabAdminInstanceAPI(apiSettings);
                
             // error is called 1
             var task1 = await PlayFabAdminAPI.GetUserAccountInfoAsync(new AdminModels.LookupUserAccountInfoRequest()
             {
                 PlayFabId = "playfabId",
             });
        
             // error is called 2
             var task2 = await PlayFabAdminAPI.GetPlayedTitleListAsync(new AdminModels.GetPlayedTitleListRequest()
             {
                 PlayFabId = "playfabId"
             });
                
             // running well
             var task3 = await playfabAdminApi.DeleteMasterPlayerAccountAsync(new AdminModels.DeleteMasterPlayerAccountRequest()
             {
                 PlayFabId = "playfabId"
             });
        
             return null;
         }

,I call the admin function to delete the master player or query the player info, but it tells me to set the developer key. However, since the developer key is already set, some functions are called fine. Why does this situation happen?

    [FunctionName("SampleAdminFunc")]
         public static async Task<dynamic> SampleAdminFunc(
             [HttpTrigger(AuthorizationLevel.Function, "get", "post", Route = null)] HttpRequest req, ILogger log)
         {
             string body = await req.ReadAsStringAsync();
             log.LogInformation($"Body: {body}");
        
             var apiSettings = new PlayFabApiSettings
             {
                 TitleId = Environment.GetEnvironmentVariable("PLAYFAB_TITLE_ID", EnvironmentVariableTarget.Process),
                 DeveloperSecretKey =
                     Environment.GetEnvironmentVariable("PLAYFAB_DEV_SECRET_KEY", EnvironmentVariableTarget.Process),
             };
        
             var playfabAdminApi = new PlayFabAdminInstanceAPI(apiSettings);
                
             // error is called 1
             var task1 = await PlayFabAdminAPI.GetUserAccountInfoAsync(new AdminModels.LookupUserAccountInfoRequest()
             {
                 PlayFabId = "playfabId",
             });
        
             // error is called 2
             var task2 = await PlayFabAdminAPI.GetPlayedTitleListAsync(new AdminModels.GetPlayedTitleListRequest()
             {
                 PlayFabId = "playfabId"
             });
                
             // running well
             var task3 = await playfabAdminApi.DeleteMasterPlayerAccountAsync(new AdminModels.DeleteMasterPlayerAccountRequest()
             {
                 PlayFabId = "playfabId"
             });
        
             return null;
         }
apis
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

·
Rick Chen avatar image
Rick Chen answered

I see that you have set up the developer secret key to an instance API in line 14. However, you didn't use the instance API in the task 1 and task 2, only use it in task 3.

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.