Tutorial: Local debugging for Cloudscript using Azure Functions
With Azure Functions, you can now test and debug your CloudScript code locally. After you have completed this tutorial, you can run your local Azure Functions app under the debugger (e.g. in VS Code or Visual Studio), set your breakpoints and run your game client. In this tutorial you learn how to:[!div class=“checklist”] * Add an implementation of ExecuteFunction to your local Azure Functions app * Add a settings file to tell the PlayFab SDK to call that local implementation from your game
Prerequisites
- Currently local debugging is supported in the following SDKs:
Add a local implementation of ExecuteFunction
For C# Azure Functions apps
To get the local implementation of ExecuteFunction set up in your C# Azure Functions app, add the ExecuteFunction.cs file to your local Azure Functions app.Required environment variables for local implementation of ExecuteFunction
Add the following settings to yourlocal.settings.json file:
For example:
Configure PlayFab SDK to call local ExecuteFunction implementation
To tell the PlayFab SDK to redirect ExecuteFunction API calls to your local implementation, add a file calledplayfab.local.settings.json to one of two places:
- The temporary directory on your machine
- On Windows, this is the TEMP environment variable
- On Linux/Mac, this is the TMPDIR environment variable
- The directory of your game executable
playfab.local.settings.json file.
Additional resources
Azure Functions has a great guide on how to test and debug your Functions locally. Here are some highlights from the above document.- Make sure that your Azure Functions Core Tools are installed
- Configure your local settings file. For more information, Develop Azure Functions by using Visual Studio Code
- Set a break point in your code
- Select F5 to start debugging
