question

Daniel Madera avatar image
Daniel Madera asked

How to update build region in cloudscript

I need to modify region build data. Using postman I could call this function "UpdateBuildRegion"

https://{ {TitleId}}.playfabapi.com/multiplayerserver/UpdateBuildRegion?sdk=PostmanCollection-0.203.240202

body { "BuildId": "xxxxx", "BuildRegion": { "Region": "EastUs", "MaxServers": 1, "StandbyServers": 1 } }


Now, I need to do this but by calling a cloud function (UpdateRegionServerDevs)

 handlers.UpdateRegionServerDevs = function(args) {
     var request = {
                     "BuildId": "xxxxx",
                     "BuildRegion": {
                         "Region": "EastUs",
                         "MaxServers": 1,
                         "StandbyServers": 1
                     }
                 };
      server.UpdateBuildRegion(request, (error, result) => {
                     if (result !== null) {                                
                         log.debug("OK ");  
                     } else if (error !== null) {                
                          log.debug("Err " + error);  
                     }
                 });                        
 };

I tried this but it did not work

https://{ {TitleId}}.playfabapi.com/client/ExecuteCloudScript?sdk=PostmanCollection-0.203.240202

body

 {
   "FunctionName": "UpdateRegionServerDevs",
   "FunctionParameter": {
   },
   "RevisionSelection": "Live",
   "GeneratePlayStreamEvent": true
 }

response

 {
     "code": 200,
     "status": "OK",
     "data": {
         "FunctionName": "UpdateRegionServerDevs",
         "Revision": 3,
         "Logs": [],
         "ExecutionTimeSeconds": 0.000421,
         "ProcessorTimeSeconds": 0.0,
         "MemoryConsumedBytes": 5016,
         "APIRequestsIssued": 0,
         "HttpRequestsIssued": 0,
         "Error": {
             "Error": "JavascriptException",
             "Message": "JavascriptException",
             "StackTrace": "TypeError: server.UpdateBuildRegion is not a function\n    at handlers.UpdateRegionServerDevs (AB5E7-main.js:332:13)\n    at Object.invokeFunction (Script:117:33)"
         }
     }
 }
CloudScript
1 comment
10 |1200

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

Daniel Madera avatar image Daniel Madera commented ·

I don't know why this question doesn't have the same text format that I see when I edit it.

7047-image.png

0 Likes 0 ·
image.png (76.7 KiB)
Daniel Madera avatar image
Daniel Madera answered

I noticed this documentation in the PlayFab cloud script

// Cloud Script runs in the PlayFab cloud and has full access to the PlayFab Game Server API // (https://api.playfab.com/Documentation/Server), and it runs in the context of a securely // authenticated player, so you can use it to implement logic for your game that is safe from // client-side exploits. //

And I need to execute a function included into multiplayer server API https://learn.microsoft.com/en-us/rest/api/playfab/multiplayer/multiplayer-server/update-build-regions?view=playfab-rest

Is there any chance to do this?

10 |1200

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

Daniel Madera avatar image
Daniel Madera answered
1 comment
10 |1200

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

Xiao Zha avatar image Xiao Zha commented ·

Glad to hear you found a solution.

0 Likes 0 ·

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.