Skip to main content
Economy v2 is now Generally Available. For support and feedback, go to the PlayFab Forum.
Economy v1 (Legacy) had a built-in Drop Tables feature that let you define weighted random item distributions directly in Game Manager. Economy v2 doesn’t include drop tables as a native feature, but you can implement the same behavior—and with more flexibility—using Azure Functions combined with the ExecuteInventoryOperations API. This tutorial shows you how to build a complete randomized loot system that:
  • Defines loot tables with weighted item pools in Title Data.
  • Uses an Azure Function to roll random items from a loot table.
  • Atomically subtracts a container token and grants the randomly selected items in a single call.

How it works

  1. Define loot tables in Title Data: Store your drop table configurations (item IDs, weights, quantities) as JSON in Title Data so you can update them without redeploying code.
  2. Represent containers as virtual currency: Use the same container token pattern as fixed-contents containers: a virtual currency that acts as an unopened loot box.
  3. Call an Azure Function to open the container: The function reads the loot table, runs weighted random selection, then calls ExecuteInventoryOperations to atomically subtract 1 container token and add the randomly selected items.

Prerequisites

Step 1: Define loot tables in Title Data

Store your loot table definitions in Title Data so designers can update drop rates without code changes.

Example loot table structure

Create a Title Data key called LootTables with a JSON value:
Each loot table includes the following properties:

Setting Title Data

Game Manager

  1. Go to Content > Title Data.
  2. Create a key called LootTables.
  3. Paste your JSON loot table configuration as the value.
  4. Select Save.

API

Use SetTitleData:

Step 2: Create the Azure Function

Create an Azure Function that your game client calls when a player wants to open a container. The function:
  1. Verifies the player has at least one container token.
  2. Reads the loot table from Title Data.
  3. Runs weighted random selection.
  4. Calls ExecuteInventoryOperations to atomically subtract the token and grant the rewards.

Data models

Weighted random selection

Full Azure Function

The GetContainerCurrencyId helper function maps a loot table name to its corresponding container currency ID. You can store this mapping in Title Data alongside the loot tables, or use a naming convention.

Step 3: Grant container tokens to players

Grant container tokens to players through gameplay, store purchases, or rewards. Use the same approach described in Containers with fixed contents.

Step 4: Call the function from your game client

When the player wants to open a container, call the Azure Function by using ExecuteFunction:
The response contains the randomly selected rewards:

Loot table design patterns

Rarity tiers

The classic rarity system with exponentially decreasing weights:
Drop probabilities:
  • Common: ~90.0%
  • Uncommon: ~9.0%
  • Rare: ~0.9%
  • Legendary: ~0.09%

Multi-roll with mixed rewards

A supply crate that gives three random items from a mixed pool:

Guaranteed + random (pity system)

For a “guaranteed rare or better every 10 opens” pattern, track the player’s open count in Display Properties or Player Data, and override the random selection in the Azure Function when the threshold is reached.

Nested drop tables

A loot table can reference another loot table by ID. Your Azure Function resolves the reference recursively:
The function checks if an ItemId starts with TABLE: and, if so, rolls on the referenced table instead of granting the item directly.

Security considerations

  • Always run loot logic server-side in an Azure Function. Never trust the client to determine which items were rolled. This approach prevents manipulation.
  • Use IdempotencyId on the ExecuteInventoryOperations call to prevent duplicate grants if the function is retried. For more information, see Idempotent transactions and retries.
  • Validate container ownership by checking the player’s inventory before subtracting. The Subtract operation in ExecuteInventoryOperations fails if the player doesn’t have enough tokens, which rolls back the entire batch.
  • Log all rolls for auditing. The function’s return value and PlayStream events provide a trail of what each player received.

See also

Last modified on August 10, 2026