question

Jonathan Crowe avatar image
Jonathan Crowe asked

Create Build With Custom Container format example

Hey folks, I'm trying to post Create Build With Custom Container via powershell and I can't quite get the format correct. my json I will always return InvalidRequest, ValidationError.

 {
     "code": 400,
     "error": "InvalidRequest",
     "errorCode": 1071,
     "errorDetails": {
         "ValidationError": [
             "Error converting value \"[game_port,8080,TCP]\" to type 'PlayFab.WebAPIModels.Thunderhead.Port[]'. Path 'Ports', line 1, position 128."
         ]
     },
     "errorHash": "bf1ac2289080de30da4acbb68d258c97b6ec5e36bf2742a6a1c96d8d44155b13",
     "errorMessage": "Invalid JSON in request",
     "retryAfterSeconds": null,
     "status": "BadRequest"

Could someone provide me with an example of how to format the request correctly.

Many thanks.

apis
10 |1200

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.

1 Answer

·
Neils Shi avatar image
Neils Shi answered

If you want to create build with custom container via PowerShell, here is an example you can refer to:

 $vmSize = "Standard_D2as_v4"
 $ports = @( @{ Name = 'tcp_port'; Num = 8080; Protocol = 'TCP' }, @{ Name = 'udp_port'; Num = 8081; Protocol = 'UDP' } )
 $regions = @( @{ 'MaxServers' = 1; 'Region' = 'AustraliaEast'; StandbyServers = 1; 'ScheduledStandbySettings' = $NULL } )
 $containerImageReference = @{ ImageName = "MyLinuxContainerImage"; Tag = "0.2" }
    
 $buildResponse = New-PfBuild -BuildName ExampleBuild -ContainerFlavor CustomLinux -ContainerImageReference $containerImageReference -VMSize $vmSize -MultiplayerServerCountPerVM 1 -Ports $ports -RegionConfigurations $regions
    
 # All PlayFabMultiplayerApi cmdlets return objects, so we can pass the returned object to ConvertTo-Json for human readability.
 $buildResponse | ConvertTo-Json -depth 5

For more info, please refer to Deploy builds using PowerShell/API - PlayFab | Microsoft Learn.

10 |1200

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.

Write an Answer

Hint: Notify or tag a user in this post by typing @username.

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.