PlayFab Match History - Extending PlayFab during Hackweek 2021

Extending PlayFab with a Match History

Published on Thursday, 21 October 2021

In my last post, I talked about extending PlayFab with Azure Functions.

In today's post, we expand on this topic and I will show you what my team mate Andreas and I built during Microsoft Global Hackathon (aka Hackweek) 2021:

Microsoft Global Hackathon is an internal Hackathon where Microsoft employees all over the world devote full three work-days to a project of their liking.

Our Project

Let me introduce you to: PlayFab Match History Extension!

This is a proof-of-concept implementation of an extension for PlayFab, which uses a custom PlayStream Event to signal the end of a match on a game server.


Components & Flow

We use the PlayStream to trigger an Azure Function via Azure Storage Queues (instead of HTTP to make it more resilient).

The Azure Function, triggered via the Storage Queue, persists the event data in an Azure Cosmos DB Container. We use the Serverless SKU here, as we try to generate as less cost as possible during development. If you have higher and constant demand, switching to a provisioned RU model (manual or automatic) is recommended for performance.

Another Azure Function App exposes a Web API, which allows querying the data in the CosmosDb. The API exposes an OpenAPI (Swagger) endpoint and is secured using PlayFab authentication, to also demonstrate this integration.

Swagger UI Screenshot

Both Azure Function apps have Application Insights enabled for them to monitor performance, anomalies and usage. Both log to the same Azure Log Analytics Workspace, which enables us to use the Kusto Query Language to analyse the usage of the Functions.

The infrastructure is set-up using Terraform, to provide reproducible infrastructure ready to deploy the above mentioned application components on.

Terraform snippet

We used GitHub Actions to continuously deploy the applications to the provisioned infrastructure on every push and pull request. See our workflow.

There are still a few manual steps to do, like creating an Azure Service Principal and setting up your PlayFab title and the Azure Functions binding within your title. You can check out my post on a detailed walk-through on how to set up Azure Function bindings!

Going Further

While this project is not ready for production use, go ahead and fork the project. Then adapt it to your needs!

Here are some ideas of what you can do with it:

  • Get the amount of matches a player has played/won/lost and a ratio of that
  • Get the top match winners
  • Determine whom a player plays most with
  • Add more meta data and determine the most liked map/weapon etc.
  • Connect the Cosmos DB to PowerBI and use it for visualization!


Let me know on Twitter on what you are building with this or let me know your feedback.

Do feel free to contribute to the project if you have an idea how to make this better usable for others!