Azure functions are used to isolated small pieces of logic.These functions are triggered when some triggering even happens.
- Azure fucntions is a Serverless computing technology
- Azure functions can be created using C#,Typescript and many different technologies
- Azure functions are based on triggers,events and isolated code.
- Events cause trigger to fire which causes the function to execute.
Some of the events or triggers which cause Function to execute are:
- HTTP Request
- Schedule
- Blob storage
- Queue storage
- Event Grid
- Event Hub
- Service Bus Queue
- Service Bus Topic
Azure functions is a type of App service.Other examples of App Services are Web App and Logic Apps.The benefit of Azure function is that since it is based on serverless architecture so you don’t need to be concerned with the lower level details of the functions such as mananging the OS and middleware.
This makes it easy not only to develop but also to deploy and scale the application.
Following is a basic function which is executed when http trigger is fired
import { AzureFunction, Context, HttpRequest } from “@azure/functions”
const httpTrigger: AzureFunction = async function (context: Context, req: HttpRequest): Promise<void> {
context.log(‘HTTP trigger function processed a request.’);
constname= (req.query.name|| (req.body&&req.body.name));
if (name) {
context.res= {
// status: 200, /* Defaults to 200 */
body: “Hello “+ (req.query.name||req.body.name)
};
}
else {
context.res= {
status: 400,
body: “Please pass a name on the query string or in the request body”
};
}
};
export default httpTrigger;
Leave a Reply