question

DP avatar image
DP asked

Accessing FunctionParameter from CloudScript in Azure Functions context?

Are there any docs/examples of how to properly forward CloudScript FunctionParameter values to an Azure Function? I'm using NodeJS w/ Azure Functions and wondering how to access those values.

CloudScript
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

·
Rick Chen avatar image
Rick Chen answered

Could you specify what do you mean by accessing function parameter from CloudScript in Azure Functions? Do you mean calling Azure Function inside CloudScript? Or do you mean calling the CloudScript API ExecuteFunction?

If it is former, I would suggest that it is not necessary to call Azure Function inside CloudScript. You could Write a PlayFab CloudScript using Azure Functions.

If it is the latter, the Function parameters from ExecuteFunction API are passed in POST body. Here is an example of using the function parameters: Quickstart: Writing a PlayFab CloudScript using Azure Functions

For NodeJS in Azure Function, you could use req.body.FunctionArgument to retrieve the function parameters from calling ExecuteFunction API, for example:

module.exports = async function (context, req) {
                
context.log('JavaScript HTTP trigger function processed a request.');
const responseMessage = "Hello, "+req.body.FunctionArgument.name;
context.res = {
body: responseMessage
};
}
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.

DP avatar image DP commented ·

Yes its the latter, thank you. I can assume they are transmitted to me in the body, good to know. I didn't see a JS example on that link you sent, only C#. what is the encoding of the POST body? JSON? form encoding?

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.