Introduction to Azure Function App

Azure function allows us to run functions in cloud. Azure function enables us to develop serverless applications on Microsoft Azure. Using Azure Function app, we can write the code without thinking about any application or infrastructure to run it. Azure functions can be event driven, compute on demand or can also be like upload and trigger pre-compiled executables. It has logging capabilities that can be used for troubleshooting and monitoring purpose.

By making changes in Azure Storage Blob containers, changes to Azure Queues, messages from Service Bus, and HTTP triggers azure functions can be triggered. Interaction with other data sources and services are possible with its function bindings. This enables developer to know very little about any underlying services they are interacting with. Azure function runtime is portable which allows us to run functions in Azure or in any other coluds. Azure funtion provides following templates:

BlobTrigger – Azure Storage blob is processsed when it is added to a container.

EventHubTrigger – Responds to Azure Event Hub’s events.

Generic webhook – Webhook HTTP requests are processed from any service.

GitHub webhook – Responds to GitHub repository’s events.

HTTPTrigger – An HTTP request, triggers the execution of code.

QueueTrigger – Responds on receiveing message from an Azure Storage queue.

ServiceBusQueueTrigger – Allows to connect Azure function code to other Azure services or on-premises services by listening to message queues.

ServiceBusTopicTrigger – Allows to connect Azure function code to other Azure services or on-premises services by subscribing to topics.

TimerTrigger – Allows to execute batch tasks or cleanup tasks on predefined schedule.

Azure functions can be developed using languages such as C#, F#, Python, etc. Here we will look in on the steps to create Azure Function App.

Log in to Azure management portal using Azure subscription. Select Compute -> Function App


On clicking on Function App, below Function App blade will be displayed in which we have to provide all required details.


Hosting plan is Consumption Plan here in which Azure provides all computational resources that are required to run Azure function. There is also App Service Plan, which can be used when we are already using App Service for other applications then same plan can be used at no additional cost. Storage account for Azure function will be created automatically. Storage account will be used to store runtime data, Logs and Codebases of Azure Function App.

On clicking on ‘Create’ it will be validated and deployed.


 

After it gets deployed, Function app will be created successfully as shown below:


Click on the Function App created, it will take to Function app home screen where Azure functions can be created. Here select Timer and C# as language and click on “Create this function”.

 


It will create TimerTriggerCSharp1 App Function as with tabs Develop, Integrate, Manage and Monitor tabs as below. Develop tab allows us to edit the code and to view the logging information.


In Develop tab, we will be having below code. On running this we would be able to see the log information with Date Time.


We can customize above code as per our requirement. Below, I have added 1 second delay and printed messages which are getting reflected in logs.


Similarly we can create HTTP Trigger. Click on the Quick Start and select “Webhook + API”. Select C# as language and click on “Create the function”.

 


Once the function is created and ran, we will be having below screen. Here it accepts Input from user and displays output in right side pane.


Here, we can get function URL and pass the parameter from browser. Click on “Get Function URL” in top right side if Develop area.


Copy this URL and paste it in your browser and hit enter. You will be able to see the below screen asking to pass a name on the query.


Now at the end of URL add &name=CSharp and hit enter. You will be able to see the output as below.


Click on Integrate tab, this would give us details on Triggers, Inputs and Outputs type. Here we could see the Trigger and Output is of HTTP type.


Click New Input/ New Output, this would give us the list of options available as below.


Click on Manage Tab, here we can Enable/Disable function state and also delete Azure function app created.


 

Click on Monitor tab, here we could see Success counts, Error counts and other run details as below.


Click on New Function and we could see list of languages and list of templates available on which Azure App function can be created.


Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s