Search This Blog

2021-04-19

My Azure Study Note - 08 - Azure Function

What is Azure Function

Azure Functions is a serverless solution that allows you to write less code, maintain less infrastructure, and save on costs. Instead of worrying about deploying and maintaining servers, the cloud infrastructure provides all the up-to-date resources needed to keep your applications running.

What is Trigger and Binding in azure ?

Triggers are what cause a function to run. A trigger defines how a function is invoked and a function must have exactly one trigger. Triggers have associated data, which is often provided as the payload of the function.

Binding to a function is a way of declaratively connecting another resource to the function; bindings may be connected as input bindings, output bindings, or both. Data from bindings is provided to the function as parameters.

You can mix and match different bindings to suit your needs. Bindings are optional and a function might have one or multiple input and/or output bindings.

Triggers and bindings let you avoid hardcoding access to other services. Your function receives data (for example, the content of a queue message) in function parameters. You send data (for example, to create a queue message) by using the return value of the function.

Example- A scheduled job reads Blob Storage contents and creates a new Cosmos DB document.

Trigger = Timer

Input binding = Blob Storage

Output binding = Cosmos DB

Sample Function



What is Cold Start ?

Cold start is a term used to describe the phenomenon that applications which haven’t been used take longer to start up.


What is Durable Function

Durable Functions is an extension of Azure Functions and Azure WebJobs that lets you write stateful functions in a serverless environment. The extension manages state, checkpoints, and restarts for you.

Run Azure Function Locally

  • Install the Core Tools and dependencies.
  • Download the VS Code Extension - Azure Functions
  • Download Postman
  • In the terminal run the command- dotnet restore
  • Initialize and run the code in VS Studio with the extension


  • Test the code from Postman

Run Azure Function in Azure

Run Bash command to create storage account

az storage account create --name readitfuncstorage --location westeurope --resource-group readit-app-rg --sku Standard_LRS

Create azure function
az functionapp create --name readitfunctionapp --storage-account readitfunctionstorage --consumption-plan-location westeurope --resource-group readit-app-rg --functions-version 3

Same command with alternative func name and storage account
az functionapp create --name readitfunctionapp2 --storage-account readitfuncstorage2 --consumption-plan-location westeurope --resource-group readit-app-rg --functions-version 3

In Azure, Search the function app in all resources

Deploy the function app in VS Code

Check in the azure portal for those new functions

Click on any function and go to Code+Test. The output will be printed in the log.


Click the GET Function URL and copy the URL to Postman

Clear the console window in Azure

Test the function from Postman and check the log once again

Console Log in azure





No comments: