Click the "Deploy to Azure" button above. You can create new resources or reference existing ones (resource group, gateway, service plan, etc.) Site Name and Gateway must be unique URL hostnames. The deployment script will deploy the following:
- Resource Group (optional)
- Service Plan (if you don't reference exisiting one)
- Gateway (if you don't reference existing one)
- API App (JavaScriptAPI)
- API App Host (this is the site behind the api app that this github code deploys to)
The API app has one action - Execute Script - which returns a single "Result" parameter.
The action has three input parameters:
Input | Description |
---|---|
Script | JavaScript syntax |
Context Object (optional) | Objects to reference in the script. Can pass in multiple objects, but base must be a single Object { .. }. |
{ "object1": { ... }, "object2": "value" }
In script could then reference object1 and object2 - both passed in as a JToken.
###Trigger###
You can use the JavaScript API as a trigger. It takes a single input of "expression" and will trigger the logic app (and pass result) whenever the script returns anything but false
. You set the frequency in which the script runs.
Step | Info |
---|---|
Action | Execute Script |
Script | return message; |
Context Object | {"message": {"Hello": "World"}} |
Output | {"Hello": "World"} |
You can also perform more complex scripts like the following:
####Context Object####
{ "tax": 0.06, "orders": [{"order": "order1", "subtotal": 100}] }
return orders.map(function(obj){obj.total = obj.subtotal * (1 + tax); return obj;});
[ {"order": "order1", "subtotal": 100, "total": 106.0 } ]