Friday, 5 July 2019

azure function


https://docs.microsoft.com/en-us/azure/azure-functions/functions-create-first-azure-function

https://docs.microsoft.com/en-us/azure/azure-functions/functions-create-scheduled-function


https://docs.microsoft.com/en-us/azure/azure-functions/functions-bindings-cosmosdb-v2

https://docs.microsoft.com/en-us/azure/azure-functions/functions-create-function-app-portal

examples:

https://azure.microsoft.com/en-us/resources/samples/?service=functions&sort=0

best practise -- function
https://docs.microsoft.com/en-us/azure/azure-functions/functions-best-practices

js guide:
https://docs.microsoft.com/en-us/azure/azure-functions/functions-reference-node

create a function with ide:
https://docs.microsoft.com/en-us/azure/azure-functions/functions-create-first-function-vs-code
you also can directly create a function on azure portal (web)

azure function.

Trigger ,  you can use timer, or http or cosmos as a trigger, which means what will call your code(the function).

Timer, it is a corn job.

Http,  it will generate a url, if you access the url it will call your code.  -- this could be used as an api.


cosmos.  you will need to link your Function to a collection, then once insert or update done on your table, then your function will be called.  but i found it doesn't work with new created db..........


Input, Functions can have multi inputs.

cosmos,  you can link your input to a cosmos collection (you can give an collection id, you can also give a sql). once your code is called,  Azure will run your sql to give you data or give you the whole collect, or give you the collection with the given id.

e.g. below is my function with timer tigger, and i have created an Input to connect to one of my cosmos collection:

module.exports = async function (context, myTimer, input) {
var timeStamp = new Date().toISOString();
if (myTimer.IsPastDue)
{
context.log('JavaScript is running late!');
}
context.log('_------------------JavaScript timer trigger function ran!', timeStamp);

context.log('input:')
context.log( input); // here will print the collection data

context.done();
};

No comments:

Post a comment