首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >使用Azure函数访问Playfab数据

使用Azure函数访问Playfab数据
EN

Stack Overflow用户
提问于 2021-12-16 05:33:31
回答 1查看 702关注 0票数 0

如何使用Azure函数访问读/写/修改/删除Playfab数据?

EN

回答 1

Stack Overflow用户

发布于 2021-12-17 04:19:50

下面的步骤将帮助您使用Playfab访问azure函数

  1. 在VS代码中创建Azure函数,将azure函数部署到门户,并使用云脚本注册您的函数,下面是使用playfab.

中的azure函数调用云脚本的示例代码。

代码语言:javascript
复制
//This snippet assumes that your game client is already logged into PlayFab.

using PlayFab;
using PlayFab.CloudScriptModels;

private void CallCSharpExecuteFunction()
{
    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()}");
    });
}

PlayFab CloudScript Context, Variables and Server SDKs

  1. 您需要通过Package安装PlayFab SDK。若要在Visual代码中执行此打开终端或CMD控制台,请输入:dotnet add package PlayFabAllSDK

  1. 我们已经创建了一些将与cSharpSDK.

一起发货的助手

  1. 如果您使用的是最新的.

,则需要编辑.csproj文件,并在默认的PropertyGroup或NETCOREAPP3_1中包含<DefineConstants>NETCOREAPP2_0</DefineConstants>

脚本的

  1. 执行可以通过几种方法(API、计划任务、PlayStream事件、段输入和退出方法)进行。执行的上下文对于实现CloudScript非常重要。有关如何使用脚本的上下文的详细信息,请参阅Using CloudScript context models tutorial .

有关更多信息,请查看Cloud Script Using Azure FunctionsPlayfab Cloud Script

票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/70374253

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档