public static async Task <dynamic> Run( [HttpTrigger(AuthorizationLevel.Function, "get", "post", Route = null)] HttpRequest req, ILogger log) { FunctionExecutionContext <dynamic> context = JsonConvert.DeserializeObject <FunctionExecutionContext <dynamic> >(await req.ReadAsStringAsync()); var apiSettings = new PlayFabApiSettings { TitleId = "F6F60", //TitleId = Environment.GetEnvironmentVariable("PLAYFAB_TITLE_ID", EnvironmentVariableTarget.Process), DeveloperSecretKey = "KNFWWBZ3FM4F4HU63E3RA446UBM995GPXXIHGU76977WXC4WJM" //DeveloperSecretKey = Environment.GetEnvironmentVariable("PLAYFAB_DEV_SECRET_KEY", EnvironmentVariableTarget.Process), }; var server = new PlayFabServerInstanceAPI(apiSettings); var args = context.FunctionArgument; string newName = args["Name"]; //Modificar Datos de la base de datos var updateUserDataResult = await server.UpdateUserReadOnlyDataAsync(new PlayFab.ServerModels.UpdateUserDataRequest() { PlayFabId = context.CallerEntityProfile.Lineage.MasterPlayerAccountId, // usuario de testing: "39212472BC0FB314" Data = new Dictionary <String, String>() { { "Name", newName }, { "RankExp", "0" }, //Misma idea que con la experiencia de personajes, guardo solo la exp y en el cliente ya calculamos el rango { "StoryCleared", "0" }, //Apuntamos cuantas stages ha completado. { "MissionsCleared", " " } //Separamos por espacios los ID de las misiones que ha completado } }); // REGALAR PERSONAJES var updateInventoryResult = await server.GrantItemsToUserAsync(new PlayFab.ServerModels.GrantItemsToUserRequest() { PlayFabId = context.CallerEntityProfile.Lineage.MasterPlayerAccountId, ItemIds = new List <string> { "6", "5", "3", "4", "46", "47", "48", "49" }, CatalogVersion = "Characters" }); foreach (PlayFab.ServerModels.GrantedItemInstance elements in updateInventoryResult.Result.ItemGrantResults) { var updateInventoryDataResult = await server.UpdateUserInventoryItemCustomDataAsync(new PlayFab.ServerModels.UpdateUserInventoryItemDataRequest() { PlayFabId = context.CallerEntityProfile.Lineage.MasterPlayerAccountId, ItemInstanceId = elements.ItemInstanceId, Data = new Dictionary <String, String>() { { "exp", "0" }, { "awaken", "0" } } }); } ////////////////// //Leer Datos de la base de datos var result = await server.GetUserReadOnlyDataAsync(new PlayFab.ServerModels.GetUserDataRequest() { PlayFabId = context.CallerEntityProfile.Lineage.MasterPlayerAccountId, //context.CallerEntityProfile.Lineage.MasterPlayerAccountId, // usuario de testing: "39212472BC0FB314" }); var UserName = "******"; if (result.Error != null) { // Handle error if any } else { if (result.Result.Data == null || !result.Result.Data.ContainsKey("Name")) { Console.WriteLine("No Country"); } else { if (result.Result.Data.ContainsKey("Name")) { Console.WriteLine("Name: " + result.Result.Data["Name"].Value); UserName = result.Result.Data["Name"].Value; } } } var message = $"Hello there!"; log.LogInformation(message); return(new { messageValue = newName }); }