Learn the basics of Azure Functions

Tram Ho

Azure Functions is a cloud service, with all the resources and infrastructure available – always up to date to meet the needs of its users. Azure Functions is not a server, but can provide computation, function processing, … We can use it to build web APIs, respond to database changes, handle IoT flows, manage message queues, and more.

Because Azure Functions is a serverless solution, you can write less code, need less infrastructure to maintain, and save money. Instead of worrying about server deployment and maintenance, the cloud infrastructure provides all the resources that are needed to keep your applications up to date.

Supported languages.

  • C #: includes precompiled class libraries and C # script.
  • JavaScript: version 2.x of the Azure Functions runtime is only supported. Requires version 1.7.0 of the Durable Functions extension, or a later version.
  • Python: requires version 2.3.1 of the Durable Functions extension, or a later version.
  • F #: precompiled class libraries and F # script. The F # script only supports version 1.x of the Azure Functions runtime.
  • PowerShell: support for the Durable Functions extension is currently in public preview. Only supported for 3.x version of the Azure Functions runtime runtime of Azure Functions and PowerShell 7.

Basic application models

  • Function chaining: is a series of functions that execute in a specific order, in this model the output of this function is applied to the input of other functions.
  • Fan out / fan in: For this model, perform multiple functions at the same time and wait for all functions to finish.
  • Async HTTP APIs: Asynchronous HTTP API model for solving long-term state coordination problems with external clients.
  • Monitor: This model refers to a flexible process that iterates over a workflow until a specific condition is met.
  • Human interaction: This model allows human interaction on the system, for example a business process, which requires the approval of a manager.
  • Aggregator: A model used to aggregate data that can be from many sources together, and can be distributed in batches or can be distributed over a long period of time. Aggregators may need to take action on event data when the data arrives, and external customers may need to query for aggregate data.

Types and features of Durable Functions

Durable Functions is an extension of Azure Functions, and we can use Durable Functions to coordinate the state of function execution.
There are currently 4 types of Durable functions in Azure Function: activity, orchestrator, entity, and client.

Create Durable Functions using the Azure portal

  • Create function app
    1. In the interface of Azure portal menu or Home page, select Create a resource.
    2. On the New page, select Compute> Function App.
    3. On the Basics page, install the function app information on demand: pay attention to the following contents:
      • Resource Group: Select the resource group that we have created.
      • Function App name: valid characters are from az (not case sensitive) from 0-9 and the character –
    4. Select next: hosting, fill in the necessary content, pay attention to the following contents:
      • Storage account: Account name must be 3 to 24 characters long and contain only numbers and lower case letters. You can also use an existing account, which must meet the requirements for an existing account.
      • Plan: hosting plan determines how resources are allocated to your functions app. In the default Consumption plan, resources are dynamically added as required by your functions.
    5. Select Next: Monitoring and continue to fill in the content as required.
      • Application Insights: By expanding this setting or choosing create, you can either change the app name name or choose a different area in Azure where you want to store your data.
    6. Select Review + create to review the completed content, and configuration options for the application
    7. Why when checking the information, on the Review + create page, choose create to create the app function
    8. Select Notifications in the upper right corner to see successful creation notifications
    9. Select Go to resource to see the content inside the newly created function app, and get the job done.
  • Install Durable functions using npm package (javascript only)
    1. From the function app page, on the left menu of Development Tools, select Advanced Tools.
    2. In Advanced Tools select Go
    3. Go to the Kudu console, select Debug console, and execute CMD.
    4. Here we will see the directory structure, navigate the directory to wwwroot, then upload the package.json file.
    5. After the upload is complete, from the Kudu Remote Execution Console run the command npm install.
    6. So basically we have installed Durable Functions, other libraries needed for development can also use the same way.

This article is mainly referenced from microsoft’s documentation, and is also the first step to learn about learning about Azure functions to use as an alternative to firebase’s cloud function. So there will be many shortcomings, looking forward to receiving everyone’s comments.
Thank you very much!

Reference link: https://docs.microsoft.com/en-us/azure/azure-functions

Share the news now

Source : Viblo