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.
Let me introduce you to: PlayFab Match History Extension!
Components & Flow
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.
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.
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!
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!