DEV Community

LaBrina Loving for Microsoft Azure

Posted on

Set Azure PlayFab Title Data from Google Sheets with No Code

So recently I've seen a lot of people in the Azure PlayFab community ask how they could create a workflow that takes data that is stored online in Github, Google Sheets, or other files and publish to PlayFab. For example, your game designer might want to tune the experience that is required to reach a level. The game designer is using Google Sheets to store this information. You could go straight into the Game Manager to update this, but it might be better to do this in a more automated way with clear separation of roles on the team. One of my favorite ways to automate tasks like these is with Azure Logic Apps.

What is Azure Logic Apps

Azure Logic Apps provides a serverless engine to build visual automated workflows to integrate apps and move data between applications, usually with little transformation. You build workflows using a visual designer. This means the following tasks can be done with no code:

  • Sending a weekly news summary or leaderboard updates to all players via Discord, email, or other channels.
  • Automatically notifying team when a player is removed from game due to bad behavior or other moderation issues.
  • Exporting PlayStream and other Telemetry events into Excel or Google Sheets for analysis
  • Monitoring tweets or other social media activity of your game, analyze the sentiment, and create alerts or tasks for the team to review.

How Azure Logic Apps works

At it's core, Azure Logic Apps is just a series of steps, or workflow, to define a process. Each workflow is started by a trigger. This could be an event, such as when a someone Tweets about your game, or a scheduled time that occurs daily/weekly, or it could even be run on-demand using an HTTP request.

Once an event is triggered, the workflow begins to run the tasks that you've created. You can pick from the over 400+ connectors as well as using the built-in actions to achieve powerful integrations for your game. One of the built-in connectors is Azure Functions, so you could combine your CloudScripts with other actions in a visual manner.

Prerequisites

  • Azure Subscription - if you don't have one you can sign up for a free account
  • PlayFab account - you can sign up here

Let's Do This

Okay, enough talk, let's go ahead and get started with our first workflow. As mentioned earlier, we want to create a workflow that updates PlayFab Title Data from a Google Sheet that the Game Designer manages.

Because PlayFab Title Data is stored as key/value pairs, and our data is stored in Google Sheets, we'll need to convert it to JSON and then send to PlayFab.
Image description

I log in to the Azure Portal, search for Logic Apps and create.
Azure Logic App Create screen
Fill in the required information:
Resource Group - resource group is a logical grouping of Azure Services together so that they can managed together. Just enter a name that makes sense.
Type - we're going to select Consumption for now as it makes the most sense for now. For more on pricing options for Azure Logic Apps, check here.
Name - Enter a name that makes sense
Region - Pick the region that makes the most sense based on your location.
Enable Log Analytics - Because I'm just doing a demo, I won't turn on Log Analytics, but definitely when running your Logic App in Test and Production, you should enable Log Analytics.

Fill in the information and Review and Create to complete creating the Logic App. When you go to the resource, you'll see the visual designer. You'll be prompted with a bunch of triggers and templates.

Logic App Designer
In our example we will just check our Google Sheet nightly for updates to the level design. To do this we'll select the Recurrence Trigger. When the workflow opens, select the Recurrence trigger and change recurrence to 1 time per day and add the At these Hours and At these Minutes parameters as shown below.
Azure Logic Apps Recurrence Trigger
First thing I'll need to do in my workflow is connect to Google Sheets. Click the plus sign to add a new action, search for Google Sheets and select Get Rows - Google Sheets. Sign in to your Google account to connect and you then will be able to select your Google Sheet.

Next we want to take the items in the Google Sheet and select the values into an array. For this, we will use the built-in Select Data Operation. Add another action and search for Select. In the From field, I will select Records Value. For mapping, I will create two fields Level and XP and map them to the values in my Google Sheet as shown below:
Azure Logic Apps Select Data

Now that we have the data, we can create a JSON object that we will pass into our PlayFab Title API like this. To do this, we will use the Compose action, which creates a single JSON output based on several inputs. We add another action search for Compose. We build the input by pasting the following in the inputs field:
{
"Key": "CharacterLevelRamp",
"Value": ""
}

Then put your cursor in the Value and select Output from the action above.
Azure Logic Apps Compose action

For the last step, we will call the PlayFab Set Title Data API with our data. To do this, add the HTTP action and add the following:
Method - Post
URL - https://[yourTitleID].playfabapi.com/Admin/SetTitleData
Headers - X-SecretKey - Your Developer Key
Body - Select Output from previous step above
Logic App Set Title Data PlayFab Action
...and that's it! Now let's test it out. Make sure you save your workflow. Click Run Trigger to execute your Workflow. You will see trigger running in Runs History. If all goes well, we will see all green checkboxes. Go into PlayFab --> Title Settings --> Engage --> Content --> Edit Title Data and you should see CharacterLevelRamp set.

PlayFabTitleData

Top comments (0)