This post will focus on integrating Microsoft Azure PlayFab GSDK with Unreal Engine.
In the previous post, we compiled UE from source, which is a pre-requisite to this step. So if you haven’t done that yet, check the post here:
How to download and compile Unreal Engine 5 from source (unreal-mmo-dev.com)
Useful links:
- Playfab dashboard
- GSDK plugin source in GitHub
- Documentation on getting started with GSDK + Unreal Engine
Uploaded video on build/deploy of dedicated server on Playfab!
hope you find it useful!
Compatible project
To get started, you may want to test out end-to-end flow with a default project just to make sure everything is working as expected.
Default projects from Unreal Engine are fully replicated by default and they can be used to test the deploy process.
If you have a Blueprint project, you will need to add a C++ file. You will need to create a C++ Game Instance class anyway, so perhaps you’d like to do that now.
You can add a C++ file by clicking Tools -> New C++ Class...

Create a Game Instance class by searching for it.

You can call it as you like, I called mine PlayFabGameInstance – if yours is the same, it may make the C+P easier.

After creating this class, your project will be a C++ project and you can continue with next steps.
Adding PlayFab GSDK
Follow the instructions from here: GSDK Project Setup – PlayFab | Microsoft Learn
You can find the PlayFab GSDK code here: PlayFab/gsdk: Game Server SDK for PlayFab Multiplayer Servers (github.com)
If you followed the video, you will see at the time of recording there was an issue with latest version. The git commit that I used was: ecf17ac10a7e9a1b89d34a1491c56f47fc82c69e
I would suggest you first clone and test the latest version of the GSDK but in order to checkout a different version, simply find it in git commit history: Commits · PlayFab/gsdk (github.com)
and type in CLI: git checkout <git_commit>
Ok now that you have the GSDK downloaded, add it to your project Plugins folder. You will need to create this folder as it will not be there by default.



Game Instance Header code
Here’s the Game Instance header code.
// Fill out your copyright notice in the Description page of Project Settings.
#pragma once
#include "CoreMinimal.h"
#include "Engine/GameInstance.h"
#include "PlayFabGameInstance.generated.h"
/**
*
*/
DECLARE_LOG_CATEGORY_EXTERN(LogPlayFabGSDKGameInstance, Log, All);
UCLASS()
class GSDK_DEMO_API UPlayFabGameInstance : public UGameInstance
{
GENERATED_BODY()
public:
virtual void Init() override;
virtual void OnStart() override;
protected:
UFUNCTION()
void OnGSDKShutdown();
UFUNCTION()
bool OnGSDKHealthCheck();
UFUNCTION()
void OnGSDKServerActive();
UFUNCTION()
void OnGSDKReadyForPlayers();
};
Game Instance C++ Code
// Fill out your copyright notice in the Description page of Project Settings.
#include "PlayFabGameInstance.h"
#include "PlayfabGSDK.h"
#include "GSDKUtils.h"
DEFINE_LOG_CATEGORY(LogPlayFabGSDKGameInstance);
void UPlayFabGameInstance::Init()
{
if (IsDedicatedServerInstance() == true)
{
FOnGSDKShutdown_Dyn OnGsdkShutdown;
OnGsdkShutdown.BindDynamic(this, &UPlayFabGameInstance::OnGSDKShutdown);
FOnGSDKHealthCheck_Dyn OnGsdkHealthCheck;
OnGsdkHealthCheck.BindDynamic(this, &UPlayFabGameInstance::OnGSDKHealthCheck);
FOnGSDKServerActive_Dyn OnGSDKServerActive;
OnGSDKServerActive.BindDynamic(this, &UPlayFabGameInstance::OnGSDKServerActive);
FOnGSDKReadyForPlayers_Dyn OnGSDKReadyForPlayers;
OnGSDKReadyForPlayers.BindDynamic(this, &UPlayFabGameInstance::OnGSDKReadyForPlayers);
UGSDKUtils::RegisterGSDKShutdownDelegate(OnGsdkShutdown);
UGSDKUtils::RegisterGSDKHealthCheckDelegate(OnGsdkHealthCheck);
UGSDKUtils::RegisterGSDKServerActiveDelegate(OnGSDKServerActive);
UGSDKUtils::RegisterGSDKReadyForPlayers(OnGSDKReadyForPlayers);
}
#if UE_SERVER
UGSDKUtils::SetDefaultServerHostPort();
#endif
}
void UPlayFabGameInstance::OnStart()
{
UE_LOG(LogPlayFabGSDKGameInstance, Warning, TEXT("Reached onStart!"));
UGSDKUtils::ReadyForPlayers();
}
void UPlayFabGameInstance::OnGSDKShutdown()
{
UE_LOG(LogPlayFabGSDKGameInstance, Warning, TEXT("Shutdown!"));
FPlatformMisc::RequestExit(false);
}
bool UPlayFabGameInstance::OnGSDKHealthCheck()
{
// Uncomment the next line if you want your server to log something at every heartbeat for sanity check.
/* UE_LOG(LogPlayFabGSDKGameInstance, Warning, TEXT("Healthy!")); */
return true;
}
void UPlayFabGameInstance::OnGSDKServerActive()
{
/**
* Server is transitioning to an active state.
* Optional: Add in the implementation any code that is needed for the game server when
* this transition occurs.
*/
UE_LOG(LogPlayFabGSDKGameInstance, Warning, TEXT("Active!"));
}
void UPlayFabGameInstance::OnGSDKReadyForPlayers()
{
/**
* Server is transitioning to a StandBy state. Game initialization is complete and the game
* is ready to accept players.
* Optional: Add in the implementation any code that is needed for the game server before
* initialization completes.
*/
UE_LOG(LogPlayFabGSDKGameInstance, Warning, TEXT("Finished Initialization - Moving to StandBy!"));
}
Building the project
Make sure you followed the other steps of project setup and added the PlayFab GSDK to
Update {ProjectName}.Build.cs file to add “PlayFabGSDK” into the PublicDependencyModuleNames.AddRange(); list as follows
GSDK Project Setup – PlayFab | Microsoft LearnPublicDependencyModuleNames.AddRange(new string[] { "Core", "CoreUObject", "Engine", "InputCore", "HeadMountedDisplay", "PlayFabGSDK" });
And created the Server Target file ({ProjectName}Server.Target.cs
)
You’re now ready to build the project by following the guide here: Building your Unreal Example Project – PlayFab | Microsoft Learn
You may want to Generate Project Files just to make sure everything is refreshed, then open up the Visual Studio project file and build the project with target of:
- Development Editor
- Development Server

Packaging the project
After the build with Visual Studio, you will be able to package the project while inside the Development Editor.

Build Target with only your project name will create the Client application. The build target containing Server is the server build.
I would suggest making the Development Client + Server, and you can test the development server locally.
When deploying to Playfab, you will want to package the Shipping Server – so build that too.
Deployment of server
You’re now ready to follow the steps here: GSDK Project Testing and Debugging – PlayFab | Microsoft Learn
You will also need to download the MPS from Github as a pre-requisite: PlayFab/MpsSamples: Samples that show how to use PlayFab’s Gameserver SDK for Multiplayer Servers (github.com)
Furthermore, you will need to register for an account with Playfab: https://developer.playfab.com/en-us/login
First, you will want to ZIP up your Shipping Server packaged build.

Next, login to Playfab and go to Multiplayer section.

Now, provide some properties to your build.
Bear in mind there are free core hours available, so it should not cost you if you don’t have it switched on for too long.

Your start command can be evaluated based on the path – so double check yours.

Now just finish the other settings:
- Regions: set to whichever is closer and set to 1 if you want it to be enabled after build
- Network: name should be gameport and leave as UDP
- click Add Build

Getting IP and Port information of your game
In order to connect your client to the server, you will need the IP and PORT to access it.
For those, we will use the MPS Sample but you will need to get some details first.
First, Title ID. You can get this in 2 places, when you first login to Playfab, you will be shown the title ID:

Or click Title Settings which we will need to go to anyway

Under API Features, you will find Title ID.

Next, you will need the Secret Key.

Under the Title Settings go to Secret Keys and create New Secret Key.
Obviously don’t share it with people, but mine is a test one that you can see is expired, so it’s ok.
The last bit of info you need is the Build ID which you can find on the Multiplayer tab.

You can also find it when you click on the build

So with those 3 pieces of information, we can get the IP and PORT of the server.
- Title ID
- API key
- Build ID
Using the MPS sample
Download the MPS sample app and open it:

Run it when it opens

When it opens, enter the requested details and Request Multiplayer Server.
Note that you will need to wait until your build is fully deployed before this will work.


The IP will change every time there’s a new deploy, the port should always really be 30000.
Connecting client to server
This part should now be easy. You have the IP and port from the MPS sample and all you need to do is link it to your client.
These steps are documented here: Connect to Cloud-Hosted Unreal Server – PlayFab | Microsoft Learn
Make a RunCloud.bat file with the content like so:

GSDK_Demo.exe <IP_ADDRESS>:<PORT> -log -windowed
Now simply double click the RunCloud.bat file and its done!
