Azure Function
- Azure Functions provides a serverless computing experience.
- It is a serverless platform
- Execute your code when needed
- Event-driven solution
- Execution of your code is triggered by a specific type of event.
- Pay only for the time spent running your code.
- No worry about configuration or management of the underlying physical and application infrastructure.
- Azure Functions can be triggered by various event types, including HTTP requests.
- Functions scale automatically based on demand
- Functions can be either stateless or stateful.
- Resilience: If one of your functions fails, it does not affect other functions.
- User Case:
- Process file uploads – Run code when a file is uploaded or changed in blob storage
- Build a web API – Implement an endpoint for your web applications using the
- HTTP trigger o Respond to database changes – Run custom logic when a document is created or updated in Cosmos DB
Azure function-Hands on
It’s the UI of Azure Function App, click on create.
Now we will try to create a function app, by selecting the subscription and creating the resource group.
we need to select the runtime stack and version. By default,Linux will be selected for Python.
Now, in the storage session no need to change anything, it should be the default
in the network session also no need to change anything, it should be default.
Now, in the monitoring session also no need to change anything, it should be default.
in deployment session also no need to change anything, if we want to do any continuous deployment then we can enable it or else it should be default.
Now, in the tag session also no need to change anything, it should be default.
Here you can review the details that we have entered and click on Create.
you can see the function app has been created.
Here you can see in the resource grp.
Now, we need to click on the create function which is show below in the fig.
Now, we need to create a function, here in this, we need to select the template.
As I’ll be selecting HTTP Trigger.
Here you can see, that the function has been create
Now, we need to write the code and test it.
So for that click on Code + Test, which is show on the left side.
Here you can see the HttpTrigger1 overview.
,
By default you will get one code
Click on test/run, and you will get like this, we need to select post and you can see in the body session name that Azure has been give. click on run.
Here you can see it has been execute successfully.
If we want to run it in the browser, we can click on the get function URL, and copy past that URL in the browser.
Here you can see in the browser
When we pass the name in the query string we will get this