Did you find this helpful?

Quickstart for multiplayer servers (API/PowerShell)

This tutorial helps you quickly upload a sample multiplayer server, configure a server build, and create server instances.

On a Windows 10 PC, get the following pre-requisites ready:

Install the PlayFab Multiplayer PowerShell module

Open a Windows PowerShell window and run the following commands:

Install-Module Azure.Storage
Install-Module PlayFabMultiplayer

You can learn more about the modules by running:

Get-Command -Module PlayFabMultiplayer| Get-Help


Enable multiplayer servers for your title

In the PowerShell window, run the following command using your title id and associated developer key:

Get-PFTitleEntityToken -TitleID "mytitleID" -secretkey "mysecretkey"

This command uses the PlayFab C# beta SDK to callGetEntityToken. Now let's enable multiplayer servers for the title:


Upload a game server executable as an asset

We're going to use the managed containers option to create a build. With managed containers your game server build is created by uploading assets that are combined with a Windows container image. For this tutorial upload the folder from the sample servers package you downloaded earlier

Add-PFMultiplayerAsset -FilePath "C:\"

Create a build

Now that the asset is uploaded we can create a build.

$VMSelection = [PlayFab.MultiplayerModels.AzureVMSize]::Standard_D2_v2 

$Ports = New-object PlayFab.MultiplayerModels.Port 
$Ports.Name = "game_port" 
$Ports.Num = 3600 
$Ports.Protocol = [PlayFab.MultiplayerModels.ProtocolType]::TCP

New-PFMultiplayerBuild -BuildName "PowerShellTest" -AssetFileName "" -AssetMountPath "C:\Assets\" -StartMultiplayerServerCommand "C:\Assets\WindowsRunnerCSharp.exe" -MappedPorts $Ports -VMSize $VMSelection

In a few seconds we should see the build through the PowerShell or ListBuildSummaries API:

Get-PFMultiplayerBuild -All

Request a multiplayer server

Now that we've got a build, lets see standing by servers get created:


Once we see some standing by servers, let's request one for gameplay:

$Regions = new-object 'System.Collections.Generic.List[PlayFab.MultiplayerModels.AzureRegion]'

New-PFMultiplayerServer -BuildName "MyBuild" -SessionId "00000000-0000-0000-0000-000000000001" -SessionCookie "test cookie" -PreferredRegions $regions -BuildCerts $null

This is the core of PlayFab multiplayer servers: within 3 seconds of your matchmaking service calling RequestMultiplayerServer PlayFab will allocate a new server. These servers come from continuously re-filled standing-by server pools you configure on a per-region and per-build basis. After gameplay ends the server is recycled.

Configure regional settings

To tune the number of standing-by servers and regional allocation, the portal might be simpler to use than the APIs. In Game Manager you should see a "Multiplayer" tab and your builds listed under Servers 2.0:

Click the title of a build to navigate to it's regional configuration:

From here you can add more regions, modify standing-by targets, and regional maximums.

Did you find this helpful?