This document describes the Azure Functions implemented in the GameSessionManager class, which manages a gaming scoreboard system using various Azure services.
The GameSessionManager class demonstrates a complete gaming scoreboard system that uses the following triggers and bindings.
| Trigger Type | Function | Description |
|---|---|---|
| HttpTrigger | GetPlayerScore |
GET endpoint to retrieve player scores: /api/player/{gameId}/{name}/status |
| HttpTrigger | CreateGameStatus |
POST/PUT endpoint for game status requests: /api/game/session |
| BlobTrigger | ProcessGameFile |
Processes uploaded game files from input container |
| QueueTrigger | HandleGameEvent |
Processes game events from input queue |
| QueueTrigger | ProcessScoreboard |
Processes scoreboard data from trigger queue |
| TimerTrigger | CreateGame |
Runs every minute to generate new game rounds |
| Binding Type | Usage | Description |
|---|---|---|
| BlobOutput | ProcessGameFile |
Outputs processed game status to output container |
| QueueOutput | HandleGameEvent |
Sends processed events to output queue |
| TableInput | ProcessScoreboard |
Reads scoreboard entities by game ID |
| TableOutput | ProcessScoreboard |
Writes winner records to winners table |
Function Name: GetPlayerScore
Trigger Type: HTTP GET
Route: /api/player/{gameId}/{name}/status
Description:
Retrieves the score and status for a specific player in a specific game session.
Parameters:
gameId(int) - The game ID to queryname(string) - The player name to look up
Returns:
- HTTP 200: JSON response with PlayerScoreResponse containing player details and score
- HTTP 400: Bad Request if name parameter is missing or invalid
- HTTP 404: Not Found if game/player combination doesn't exist
Example Response:
{
"Date": "2025-09-25T10:30:45",
"GameId": 1,
"Name": "Leo",
"Score": 87
}Function Name: CreateGameStatus
Trigger Type: HTTP POST/PUT
Route: /api/game/session
Description:
Processes game status requests and returns comprehensive game information including winner determination and all player scores.
Request Body:
{
"GameId": 1
}Returns:
- HTTP 200: JSON response with GameStatusResponse containing game details, winner, and all players
- HTTP 400: Bad Request if GameId is missing or invalid
- HTTP 404: Not Found if game doesn't exist
Example Response:
{
"Date": "2025-09-25T10:30:45",
"GameId": 1,
"Winner": "Paolo",
"Players": [
{ "Name": "Paolo", "Score": 95 },
{ "Name": "Leo", "Score": 87 },
{ "Name": "Mia", "Score": 73 }
]
}Function Name: ProcessGameFile
Trigger Type: Blob Trigger
Input Container: %INPUT_STORAGE_CONTAINER_NAME%
Output Container: %OUTPUT_STORAGE_CONTAINER_NAME%
Description:
Automatically processes uploaded game status files from blob storage, deserializes GameStatusRequest objects, and generates comprehensive GameStatusResponse files in the output container.
Input: Blob containing JSON GameStatusRequest
Output: Blob containing JSON GameStatusResponse with winner and player details
Processing Flow:
- Blob uploaded to input container triggers function
- Deserializes GameStatusRequest from blob content
- Retrieves game data from internal dictionary
- Determines winner (highest score)
- Creates GameStatusResponse blob in output container
Function Name: HandleGameEvent
Trigger Type: Queue Trigger
Input Queue: %INPUT_QUEUE_NAME%
Output Queue: %OUTPUT_QUEUE_NAME%
Description:
Processes game events from the input queue, handles GameStatusRequest messages, and generates GameStatusResponse messages for the output queue.
Input: Queue message containing Base64-encoded JSON GameStatusRequest
Output: JSON GameStatusResponse message sent to output queue
Processing Flow:
- Message arrives in input queue
- Deserializes GameStatusRequest from message body
- Looks up game data in internal dictionary
- Determines winner and creates response
- Sends GameStatusResponse to output queue
Function Name: ProcessScoreboard
Trigger Type: Queue Trigger with Table Input
Input Queue: %TRIGGER_QUEUE_NAME%
Input Table: %INPUT_TABLE_NAME%
Output Table: %OUTPUT_TABLE_NAME%
Description:
Processes scoreboard data to determine winners. Retrieves all scoreboard entries for a game, finds the highest scoring player, and records the winner in the output table.
Input:
- Queue message containing gameId
- Table entities matching the gameId from input table
Output: ScoreboardEntity representing the winner stored in output table
Processing Flow:
- Queue message triggers function with gameId
- Queries input table for all players in that game
- Identifies player with highest score
- Creates winner entity in output table
Function Name: CreateGame
Trigger Type: Timer Trigger
Schedule: Every minute (0 */1 * * * *)
Run On Startup: Yes
Description:
Automated function that generates new game rounds with random player data and initiates the complete gaming workflow. This function orchestrates the entire game pipeline.
Operations Performed:
- Infrastructure Initialization: Ensures all Azure Storage components are created
- Game Data Generation: Creates random scores for all configured players
- Internal Storage: Stores game data in memory dictionary for fast access
- Blob Upload: Creates GameStatusRequest blob in input container
- Queue Messages: Sends messages to input and trigger queues
- Table Entries: Creates scoreboard entries for all players
- Workflow Trigger: Initiates the complete processing pipeline
Configuration Dependencies:
PLAYER_NAMES: Comma-separated list of player namesSTORAGE_ACCOUNT_CONNECTION_STRING: Azure Storage connection string- Various queue/container/table name settings
Function Name: ServiceBusHello
Trigger Type: Service Bus Trigger
Status: Currently commented out in code
Description:
Template function for processing Service Bus messages. When enabled, it would process messages from a Service Bus queue and send responses to an output queue.
Note: This function is commented out in the current implementation but serves as a reference for Service Bus integration.
{
string Name;
int Score;
}{
int GameId;
}{
string Date;
int GameId;
string Winner;
List<PlayerScore> Players;
}{
string Date;
int GameId;
string Name;
int Score;
}{
string PartitionKey;
string RowKey;
int GameId;
string PlayerName;
int Score;
DateTimeOffset Timestamp;
ETag ETag;
}The application requires the following environment variables/application settings:
| Setting | Description | Default Value |
|---|---|---|
STORAGE_ACCOUNT_CONNECTION_STRING |
Azure Storage connection string | Required |
INPUT_QUEUE_NAME |
Input queue name | input |
OUTPUT_QUEUE_NAME |
Output queue name | output |
TRIGGER_QUEUE_NAME |
Trigger queue name | trigger |
INPUT_STORAGE_CONTAINER_NAME |
Input blob container | input |
OUTPUT_STORAGE_CONTAINER_NAME |
Output blob container | output |
INPUT_TABLE_NAME |
Input table name | scoreboards |
OUTPUT_TABLE_NAME |
Output table name | winners |
PLAYER_NAMES |
Comma-separated player names | Alice,Anastasia,Paolo,Leo,Mia |
- Timer triggers CreateGame: Generates game data and initiates workflow
- Blob uploaded: ProcessGameFile processes the blob
- Queue message sent: HandleGameEvent processes the queue message
- Trigger queue message: ProcessScoreboard determines winner
- HTTP endpoints available: GetPlayerScore and CreateGameStatus provide API access
This creates a complete gaming system with multiple trigger types and processing patterns demonstrating various Azure Functions capabilities.