Im trying to debug an Azure Function locally, calling it from Unity and im not sure if im doing it correctly. Everything runs fine on Azure but im unable to do it in local. I followed https://learn.microsoft.com/en-us/gaming/playfab/features/automation/cloudscript-af/local-debugging-for-cloudscript-using-azure-functions to prepare my local environment to debug these functions.
Im getting an exception on this line from the ExecuteFunctions.cs local file
using (var profileResponseMessage = await httpClient.PostAsync(getProfileUrl, profileRequestContent)) {
// Execute the get entity profile request
using (var profileResponseMessage =
await httpClient.PostAsync(getProfileUrl, profileRequestContent))
{
using (var profileResponseContent = profileResponseMessage.Content)
{
string profileResponseString = await profileResponseContent.ReadAsStringAsync();
// Deserialize the http response
getProfileResponseSuccess =
PlayFabSimpleJson.DeserializeObject<PlayFabJsonSuccess<GetEntityProfileResponse>>(profileResponseString);
// Extract the actual get profile response from the deserialized http response
getProfileResponse = getProfileResponseSuccess?.data;
}
}
Im not sure what im doing wrong. First thing i do is connect to PlayFab from unity to get the PlayFab entity from the user, and then i call the local function i want to debug but it doesnt even get to the actual function i want to debug as the intercepting ExecuteFunction.cs throws:
System.Private.CoreLib: Exception while executing function: ExecuteFunction. System.Net.Http: The requested name is valid, but no data of the requested ty
pe was found. (playfabapi.com:443). System.Net.Sockets: The requested name is valid, but no data of the requested type was found.
This is the unity code:
public IEnumerator PostNewAccount()
{
PlayFabCloudScriptAPI.ExecuteFunction(new ExecuteFunctionRequest()
{
Entity = new PlayFab.CloudScriptModels.EntityKey()
{
Id = PlayFabSettings.staticPlayer.EntityId, //Get this from when you logged in,
Type = PlayFabSettings.staticPlayer.EntityType, //Get this from when you logged in
},
FunctionName = "HelloWorld", //This should be the name of your Azure Function that you created.
FunctionParameter = new Dictionary<string, object>() { { "inputValue", "Test" } }, //This is the data that you would want to pass into your function.
GeneratePlayStreamEvent = false //Set this to true if you would like this call to show up in PlayStream
}, (ExecuteFunctionResult result) =>
{
if (result.FunctionResultTooLarge ?? false)
{
Debug.Log("This can happen if you exceed the limit that can be returned from an Azure Function, See PlayFab Limits Page for details.");
return;
}
Debug.Log($"The {result.FunctionName} function took {result.ExecutionTimeMilliseconds} to complete");
Debug.Log($"Result: {result.FunctionResult.ToString()}");
}, (PlayFabError error) =>
{
Debug.Log($"Opps Something went wrong: {error.GenerateErrorReport()}");
});
yield return WaitForExecution();
}
And this is the Azure Function running in local
public static class HelloWorld
{
[FunctionName("HelloWorld")]
public static async Task Run(
[HttpTrigger(AuthorizationLevel.Function, "post", Route = null)] HttpRequestMessage req, ILogger log)
{
var context = await FunctionContext.Create(req);
var playerId = context.CallerEntityProfile.Lineage.MasterPlayerAccountId;
await PlayerRepository.HelloWorld(context.AuthenticationContext, playerId);
}
}