Hello
just wondering if i can get some help on this as i am going through the docs and samples and am stuck
I am trying to wrap my head around azure functions and trying to create a simple call to azure functioins that will return a random drop table result string
here is the code for azure functions which seems to be alright
public static class GetCloudScript { [FunctionName("GetRandomDropItem")] public static async Task<dynamic> GetRandomDropItem( [HttpTrigger(AuthorizationLevel.Function, "post", Route = null)] HttpRequestMessage req, ILogger log) { /* Create the function execution's context through the request */ var context = await FunctionContext<dynamic>.Create(req); var args = context.FunctionArgument; string tableid; if (args.tableid != null) tableid = args.tableid; else tableid = "RandomBadDropTable"; /* Create the request object through the SDK models */ var request = new EvaluateRandomResultTableRequest() { TableId = args.tableId }; /* Use the ApiSettings and AuthenticationContext provided to the function as context for making API calls. */ var serverApi = new PlayFabServerInstanceAPI(context.ApiSettings, context.AuthenticationContext); /* The PlayFabServerAPI SDK methods provide means of making HTTP request to the PlayFab Main Server without any * extra code needed to issue the HTTP requests. */ return await serverApi.EvaluateRandomResultTableAsync(request); } }
And I am trying to create a function for azurefunction calls and i am trying to use the code in the tictactoe demonstration to create this within unity:
public static IEnumerator ExecuteRequest(string FunctionName) { var request = new ExecuteFunctionRequest { FunctionName = FunctionName, FunctionParameter = new PlayFabIdRequest { PlayFabId = PlayerId }, AuthenticationContext = new PlayFabAuthenticationContext { EntityToken = Player.EntityToken } }; PlayFabCloudScriptAPI.ExecuteFunction(request, (result) => { ExecutionCompleted = true; AIMoveResult = PlayFabSimpleJson.DeserializeObject<TicTacToeMove>(result.FunctionResult.ToString()); }, (error) => { throw new Exception($"Could: {error.ErrorMessage}, Code: {error.HttpCode}"); }); yield return WaitForExecution(); }
I have the playfabid from the login - but where does this entitytoken come from?
and I am not sure how the below relates to the below from the docs to the above
// Models via ExecuteFunction API public class FunctionExecutionContext<T> { public PlayFab.ProfilesModels.EntityProfileBody CallerEntityProfile { get; set; } public TitleAuthenticationContext TitleAuthenticationContext { get; set; } public bool? GeneratePlayStreamEvent { get; set; } public T FunctionArgument { get; set; } } public class FunctionExecutionContext : FunctionExecutionContext<object> { }
then there is the fact that i would have to return via an ienumerator which isnt gonna be so nice and clean - currently the original cloudscript i call via a normal void method and i just raise a callback with the appropriate info provide to a listener and a way it goes....any issues with that - i am thinking not.
If you can help me wrap my head around what i need to put in the executefunction request then i think i can figure out the rest...Also the original cloudscript function automatically provides the playfabid - is this not the case - what automatically is passed ? - like is playstream events true or false by default?
thanks!
Daniel