Introduction

-
Azure Function V1 – uses the .net Framework 4.7 and trigger can only be create using Windows
-
Azure Function V2(v2x) – runs using .Net Core 2 and trigger wherever possible
-
Azure Function V3(v3x) – Contains JavaScript and .Net Changes
Create new Azure Function Project


Azure Function Triggered

|
Blob Trigger
|
Blob Trigger function will run when a file is upload or modified in azure Blob Storage
|
|
Event Hub Trigger
|
Event Hub trigger azure function will run when event hub receives the message
|
|
Azure Cosmos DB trigger
|
Azure Cosmos DB trigger will use when document is added or modified in Cosmos DB.
|
|
Http Trigger
|
Http Trigger runs the function when an http request occurs in a web app.
|
|
Queue Trigger
|
Queue trigger occurs when new item added to an azure storage queue.
|
|
Service Bus Queue Trigger
|
Service bus queue trigger will run when new item added in the azure bus queue.
|
|
Service Bus Topic Trigger
|
Service bus topic trigger will run when new message arriving on the azure bus topic.
|
|
Timer Trigger
|
Use this event to run the Azure Function at regular intervals.
|
Azure Function Access rights
-
Anonymous - No authentication is required, and any user can trigger the function.
-
Function - The HTTP request must provide a key that enables the Azure Function runtime to authorize the request.
-
Admin - This is similar to Function but user must specify a key with the HTTP request that triggers the function.

Azure Function project structure



Azure Function Static Class
-
If you need to import namespaces, you can do so as usual, with the using clause.
-
Function Static class Function name [AzureFunction]
-
The static FunctionName attribute marks the method as a function entry point [MSDEVBUILD_Function] and The name must be unique within a project, start with a letter and only contain letters, numbers, _, and -, up to 127 characters in length.
-
Project templates often create a method named Run, but the method name can be any valid C# method name.
-
Recall from the previous unit that the parameters to the Run method are an HttpRequest object containing the details of the request that triggered the function
-
The above function will accept both get and post requests. If the request is GET type, it will get the value from the query string with the key as name and for POST, it will get a value of key name from the request body. Finally, it will respond with a string “Hello <name value>” to the user

Build and Run Azure Function

Test Azure Functions locally



Aman VermaPosted May 12, 2022, 11:17 AM
Thank you very much for explaining Azure function working in detail. It is really helpful for me.