Reader small image

You're reading from  Robust Cloud Integration with Azure

Product typeBook
Published inMar 2017
Reading LevelIntermediate
PublisherPackt
ISBN-139781786465573
Edition1st Edition
Languages
Tools
Right arrow
Authors (6):
Ashish Bhambhani
Ashish Bhambhani
author image
Ashish Bhambhani

Ashish Bhambhani is an Integration Sr. Premier Field Engineer working for Microsoft. He lives in the Seattle region. He has been working in the integration space for more than a decade. In his current role he helps Microsofts enterprise customers by architecting, designing, building, and maintaining their integration solutions. Recently, he has been able to roll out Azure technologies enterprise-wide for his clients and replace their legacy solutions. He is a content creator and master trainer for some of a Microsofts training that is delivered to clients worldwide. Additionally, he was part of the team that wrote the BizTalk performance whitepaper for msdn.com
Read more about Ashish Bhambhani

Abhishek Kumar
Abhishek Kumar
author image
Abhishek Kumar

Abhishek Kumar works with New Zealand Trade and Enterprise as an integration and data specialist. He is a Microsoft Azure MVP with deep expertise in software development and design. He is a co-author of Robust Cloud Integration and a seasoned contributor to Microsoft blogs, forums, and events. As a technological evangelist, he is specialized in cloud-based technologies such as Azure Functions, Microsoft Graph, Logic Apps, Web API, and Cosmos DB, along with various Software-as-a-Service (SaaS) such as Salesforce, Office 365, and ServiceNow. As a technology advocate, he promotes loosely coupled solution design along with event-based programming.
Read more about Abhishek Kumar

James Corbould
James Corbould
author image
James Corbould

James Corbould has been working in the IT sector since 2003, developing and supporting applications in New Zealand and the United Kingdom. Since 2010, James has been working in the software integration field, designing and building integration solutions using Microsoft technologies such as BizTalk, SQL Server, WCF, .NET, and now Azure, for a wide range of different customers. Recently, he has been working in the health insurance sector and in the building supplies sector.James currently works for Datacom Systems as a consultant and team lead.
Read more about James Corbould

Mahindra Morar
Mahindra Morar
author image
Mahindra Morar

Mahindra Morar has been working in the IT sector from 1997, developing Windows and website enterprise applications. In 2009, he has been focusing primarily on integrating systems as a principle integration consultant. Having come from an electronics engineering background, he is able to use this knowledge to design solutions that integrate between wetware, software and hardware.
Read more about Mahindra Morar

Martin Abbott
Martin Abbott
author image
Martin Abbott

Martin Abbott is a Microsoft Azure MVP living in Perth, Western Australia. He started his career developing subroutines for commercial computational fluid dynamics software, eventually moving on to more mainstream development and systems integration. He has been working with BizTalk Server since the early days of the product, has spent a lot of time with WCF, but more recently has moved in to providing his customers with integration solutions spanning both on-premises and cloud workloads.
Read more about Martin Abbott

View More author details
Right arrow

Chapter 7. Azure Functions in Logic Apps

Azure Functions were introduced during Microsoft Build 2016 as a means to provide a serverless computing environment that could scale as needed and provide a pay-as-you-go service. Serverless computing is a means of providing computing power and resources for solutions without the need to be concerned about the underlying infrastructure.

They provide a mechanism that allows developers and solution architects to react to events and process usually small amounts of functionality before either passing back a response or creating another event.

Given this, Azure Functions provide a mechanism to deliver a truly event-driven architecture, including the ability to chain and fan out events to multiple sources.

In the previous chapters, we have spoken about how Logic Apps and the App Service model within Microsoft Azure provide a good basis to build solutions that follow microservices architectural principles.

One of the key requirements for a microservices architecture...

The basics of Azure Functions


Azure Functions are essentially a managed service for WebJobs SDK that provide similar functionality but in a fully serverless environment.

WebJobs provide a means to run background tasks in the context of a Web App, Mobile App, or API App. With them, you can upload a script such as PowerShell or a command file and have them run on a schedule (https://azure.microsoft.com/en-us/documentation/articles/websites-webjobs-resources/).

At the very basic level, Azure Functions can be thought to be defined by:

Events + Code + Data = Function App 

The key part of a Function App is the initial trigger that starts the process of running the code contained within a function. This trigger can be in the form of an input event, such as a message being written to a queue, or a timed event. A function can have a number of outputs that send data and information to a range of endpoints.

A Function App represents a unit of computing, and it can contain a number of functions, each...

Building Azure Functions


Azure Functions are created in the main Azure portal in a Resource Group in the same way as other resources.

When creating a Function App, the App Service plan needs to be selected. This can be either Classic, which allows the creation of a new App Service Plan or reuse of an old one, or Consumption based to use pay-as-you-go and on demand processing.

The Function App takes a few minutes to be created, but once created, functions can be added to perform the tasks required.

The Function App has a number of settings that can be used to configure it once it has been created.

The settings page provides options for setting a daily usage quota for the Function App, accessing development resources including app settings such as connection strings, setting up Continuous Integration, configuring Authentication/Authorization and cross-origin resource sharing and providing a link to a URL that contains the Swagger API definition for a Function App that contains HTTP triggers...

Using functions with Logic Apps


Up to this point, we have been discussing how to create and use functions within a Function App for general use cases when serverless computation is required or when we wish to create an event-driven solution.

Functions can also be called directly from a Logic App. While it is possible to use the event-driven nature of functions to create a highly decoupled and scalable solution, using functions directly called within a Logic App provides a mechanism to add simple business logic that cannot be achieved through the standard functionality available within Logic Apps.

This introduces the Logic Apps equivalent of lambda expressions, which are essentially anonymous functions that are invoked only when required (https://msdn.microsoft.com/en-us/library/bb397687.aspx).

Calling functions directly

How to create a Logic App has been discussed previously, so for the purpose of this scenario, we will assume that one has already been created using the Blank Logic App template...

Other considerations


Deploying your Function App

Function Apps are stored using a basic file structure, as shown previously. Given this, they can be deployed through mechanisms that support a file structure in a similar way to Web Apps, including the use of continuous integration and continuous deployment.

Deployment options are available in the App Service settings.

Deployment credentials allows the setting of the username and password for deployment via FTP or Git. The FTP endpoint for the Function App can be found in Properties of the App Service.

Deployment options provides access in order to set up deployment from a number of sources.

For example, to set up Github as the deployment source, we would choose GitHub from the list. For most of the sources, we need to authorize access to the specific account. Once this has been provided, the source can be configured.

If Visual Studio Team Services is chosen as the deployment, it is not necessary to authorize access if the instance of Visual...

Summary


In this chapter, we showed the capabilities of Azure Functions. We discussed the basics and structure of Function Apps.

We gave some examples of functions, how they can be used to trigger events, and how they can be integrated with each other to create a chain of events that can also fan out.

Azure Functions can be used directly within Logic Apps and can act as anonymous units of code in a similar way to lambda expressions. Functions within Logic Apps can be used to provide business logic and can additionally be used to trigger other events during the execution of the Logic App.

We created a sample scenario to check the information in an invoice as an example of how to call a function within a Logic App.

Finally, we showed other important parts of Azure Functions that can be used to deploy, monitor, and scale them, and how to disable and delete them.

Azure Functions are a good platform service to use if you need scale on demand and serverless computing power. They are a good solution...

lock icon
The rest of the chapter is locked
You have been reading a chapter from
Robust Cloud Integration with Azure
Published in: Mar 2017Publisher: PacktISBN-13: 9781786465573
Register for a free Packt account to unlock a world of extra content!
A free Packt account unlocks extra newsletters, articles, discounted offers, and much more. Start advancing your knowledge today.
undefined
Unlock this book and the full library FREE for 7 days
Get unlimited access to 7000+ expert-authored eBooks and videos courses covering every tech area you can think of
Renews at ₹800/month. Cancel anytime

Authors (6)

author image
Ashish Bhambhani

Ashish Bhambhani is an Integration Sr. Premier Field Engineer working for Microsoft. He lives in the Seattle region. He has been working in the integration space for more than a decade. In his current role he helps Microsofts enterprise customers by architecting, designing, building, and maintaining their integration solutions. Recently, he has been able to roll out Azure technologies enterprise-wide for his clients and replace their legacy solutions. He is a content creator and master trainer for some of a Microsofts training that is delivered to clients worldwide. Additionally, he was part of the team that wrote the BizTalk performance whitepaper for msdn.com
Read more about Ashish Bhambhani

author image
Abhishek Kumar

Abhishek Kumar works with New Zealand Trade and Enterprise as an integration and data specialist. He is a Microsoft Azure MVP with deep expertise in software development and design. He is a co-author of Robust Cloud Integration and a seasoned contributor to Microsoft blogs, forums, and events. As a technological evangelist, he is specialized in cloud-based technologies such as Azure Functions, Microsoft Graph, Logic Apps, Web API, and Cosmos DB, along with various Software-as-a-Service (SaaS) such as Salesforce, Office 365, and ServiceNow. As a technology advocate, he promotes loosely coupled solution design along with event-based programming.
Read more about Abhishek Kumar

author image
James Corbould

James Corbould has been working in the IT sector since 2003, developing and supporting applications in New Zealand and the United Kingdom. Since 2010, James has been working in the software integration field, designing and building integration solutions using Microsoft technologies such as BizTalk, SQL Server, WCF, .NET, and now Azure, for a wide range of different customers. Recently, he has been working in the health insurance sector and in the building supplies sector.James currently works for Datacom Systems as a consultant and team lead.
Read more about James Corbould

author image
Mahindra Morar

Mahindra Morar has been working in the IT sector from 1997, developing Windows and website enterprise applications. In 2009, he has been focusing primarily on integrating systems as a principle integration consultant. Having come from an electronics engineering background, he is able to use this knowledge to design solutions that integrate between wetware, software and hardware.
Read more about Mahindra Morar

author image
Martin Abbott

Martin Abbott is a Microsoft Azure MVP living in Perth, Western Australia. He started his career developing subroutines for commercial computational fluid dynamics software, eventually moving on to more mainstream development and systems integration. He has been working with BizTalk Server since the early days of the product, has spent a lot of time with WCF, but more recently has moved in to providing his customers with integration solutions spanning both on-premises and cloud workloads.
Read more about Martin Abbott