In my previous article I gave you an overview of Azure Functions and discussed about the benefits of the Azure Functions. With this session I will cover you with necessary steps to create an initial basic functions app.

Getting Started:

Login to Azure Portal, you will see Function Apps section in the left menu. This is where all your Function Apps will be listed, once you login.

imageimage

Let us start by creating a new Function app. Type Functions

image

Select Function App from Web + Mobile category, and Click on Create Button.

Fill In details:

  1. App Name,
  2. Select Subscription
  3. Select Resource Group (new if you want to create new resource group) or select existing
  4. Select Hosting Plan
  5. Specify Storage
  6. Click on Create

imageimage

You will see deployment in progress message.

imageimage

image

Once you explore further selecting the Function App instance you will be able view the URL and left side  menu you will see the options to configure:

  1. Functions
  2. Proxies (Preview Feature)
  3. Slots (Preview Feature)

image

Getting Started – create first Function App

Now since we have new instance ready. Let us create our first Function.

We have to choose by :

1.)  Choose a scenario:

  1. Webhook + API
  2. Time
  3. Data Processing

2.)  Choose a language:

  1. JavaScript
  2. CSharp
  3. FSharp
  4. For PowerShell, Python and Batch processing, you create your own custom function

image

For the demo sake I am creating a Timer Scenario and selected CSharp as the language.

image

I created a simple trigger code  and Click on Save and Run

image

Job has completed within speculated delay we put through on the Thread.Sleep:

image

Code Sample:

[code lang=”csharp”]
using System;
using System.Threading;

public static void Run(TimerInfo myTimer, TraceWriter log)
{
log.Info($”C# Timer trigger function executing at: {DateTime.Now}”);

RunTest(log);

log.Info($”C# Timer trigger function completed at: {DateTime.Now}”);
}

public static void RunTest(TraceWriter log)
{
for(int i=0; i< 100; i++)
{
log.Info($”C# Timer trigger function executing at thread: {i}”);

Thread.Sleep(1000);

log.Info($”C# Timer trigger function completed at thread: {i}”);
}
}
[/code]

Using the Functions –> Integrate section we can configure Input, Output parameters and Schedule Timers, to make it available as a WebAPI methods. You can call this functional logic from another application to invoke as a web API call by passing necessary inputs, to start another functional process.

One example for this scenario would be to invoke a Database record archival  call after completion of an order. This is will be applicable in case we choose the scenario WebHook + API during the creation of your functional logic.

image

That’s all for now for this topic.  I will cover more details about WebHook + API in next series.

Please share your comments and rate this article to help me understand areas of improvement.

Additional Refs:


Discover more from Cloud Distilled ~ Nithin Mohan

Subscribe to get the latest posts sent to your email.

By Nithin Mohan TK

Technology Enthusiast | .NET Specialist | Blogger | Gadget & Hardware Geek

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.