Finally, I found some extra minutes to be able to write and after spending all my available free time over the last few weeks, mainly in researching but also in creating several ones… I’m happy to say that a major version, 360 new shapes – that is the double of the previous version, of Microsoft Integration Stencils Pack for Visio 2016/2013 is now available for you to download.

With these new additions, this package now contains an astounding total of 721 shapes (symbols/icons) that will help you visually represent Integration architectures (On-premise, Cloud or Hybrid scenarios) and solutions diagrams in Visio 2016/2013. It will provide symbols/icons to visually represent features, systems, processes and architectures that use BizTalk Server, Microsoft Azure and related technologies.

  • BizTalk Server
  • Microsoft Azure
    • BizTalk Services
    • Azure App Service (API Apps, Web Apps, Mobile Apps, PowerApps and Logic Apps)
    • Microsoft Flow
    • Event Hubs
    • Service Bus
    • API Management, IoT and Docker
    • Machine Learning, Stream Analytics, Data Factory, Data Pipelines
    • and so on
  • PowerBI
  • PowerShell
  • And many more…

With so many new shapes, I decide to divide the package in 4 files to be easier to maintain and find the right shapes:

  • Microsoft Integration Stencils v2.0 (416 shapes)
  • MIS Apps and Systems Logo Stencils (60 shapes)
  • MIS IoT Devices Stencils (123 shapes)
  • MIS Support Stencils (122 shapes)
BizTalk Server

Requested by several community member I added two special shapes:

  • The infamous T-Rex
  • and “The Chicken Way”

MIS-Stencils-Pack-BizTalk-Server

BizTalk Services

MIS-Stencils-Pack-BizTalk-Services

Azure App Service, Microsoft Flow and API Management

MIS-Stencils-Pack-App-Services

Azure

MIS-Stencils-Pack-Azure

Infrastructure

MIS-Stencils-Pack-Infraestructure

PowerBI, PowerShell and Service Fabric

MIS-Stencils-Pack-PowerBI

IoT

MIS-Stencils-Pack-IoT

and many more:

MIS-Stencils-Pack-More

That you can use and resize without losing quality.

Again, I didn’t create all of this shapes, maybe half of them, the other half was the work of gathering all the available resources and combine them together, for example, if you’re looking for more or official Azure Visio stencils, then you can find them here: Microsoft Azure, Cloud and Enterprise Symbol / Icon Set – Visio stencil, PowerPoint, PNG.

There are still many points that could be improved as well as adding new stencils but I hope you like the final result.

You can download Microsoft Integration Stencils Pack for Visio 2016/2013 from:

Microsoft Integration Stencils Pack for Visio 2016/2013 (6,4 MB)
Microsoft | TechNet Gallery

Bigger and better this is what to expect in this fourth conference that will take place in London. I think we can say with great certainty that this will be the biggest integration conference in the world that will happen this year! (of course related to Microsoft technologies, I don’t want to compare with other integration technologies)

Integration-2016-banner

This will be a three-day event purely focused to the Microsoft Integration stack, so we invite you all to join us in London, England. The event will take place at ExCeL London Exhibition Center and once again is being organized by BizTalk360 in conjunction with Microsoft. Please visit this link for more detail about the event and for registration information.

We will have:

  • This is not anymore a BizTalk related event this is now an Integration event covering a broad set of technologies that will appeal to integration focused professionals:
    • BizTalk Server and its expected new release BizTalk Server 2016
    • Azure App Service – API Apps and Logic Apps – PowerApps and Microsoft flows
    • Azure Service Bus (Event Hubs and Messaging)
    • And other topics like Internet of Things (IoT), Azure API Management, Azure Stream Analytics and Power BI or even Open Source technologies
  • 27 speakers (16 Integration MVP and 11 Microsoft program managers) and 27 sessions
    • The first half of the sessions and speakers are represented by Microsoft product group and the second half from Microsoft Integration MVP’s
  • There will be a paid Live Stream option for those who are not able to attend locally to this event see more about this option here.

This will also be an amazing opportunity to Network, Connect, and Reconnect with Colleagues. Meet some of the people you have been following on Twitter and blogs and network with them and others who are interested in the same things you are. To hang out with the smartest people you know – and I’m not talking about the speakers or Microsoft! I’m talking about you guys! – last reports mention that more than 370 attendees from over 150 companies across 25+ countries are going to attend the event, so imagine the experience that all of us have combined!

So my advice is: Don’t be afraid or shy, don’t wait for people come to you, instead, take your chances, engage the people you want to meet by easily saying "Hi my name is… ". This experience can be a great morale booster for you, lifelong friendships and connections have evolved from such conferences – I’m speaking for personal experience!

Integration-2016-engage-networking

And me to facilitate this approach or initiative to engage people – I will take near to 50 BizTalk cool gifts to distribute among the attendees that probably will ask questions in my session or who engage me during the event to have a simple conversation – doesn’t need to be about BizTalk or technologies it can be a simple introduction or normal conversation Smile.

Integration-2016-gifts

I’m also thrilled to be once again (fourth time) a speaker in this amazing event that I help to construct among with the other BizTalkCrew members (Nino Crudele, Steej-Jan Wiggers, Tord G. Nordahl and Saravana Kumar).

Integration-2016-im-speaking

I liked my session last year and the feedback that I received and based on the time that I have to present (30 min session) I decided that my topic would be one again about tips and tricks for developers and admins: “A new set of BizTalk Server Tips and Tricks”

Session Abstract

It’s critical to use good tools and techniques to maintain, support and produce new working solutions as quickly as possible. In this session, Sandro will introduce you to a new set of useful BizTalk Server Tips and Tricks, acquired by years of experience in the field.

The session will cover the expectations for all the roles: architects, managers, developers, and administrators. Topics include BizTalk migration strategy, content-based routing techniques, Mapping, BizTalk administration tips, extending BizTalk out-of-the-box capabilities and many more.

Integration-2016-sandro-session

I hope that, like me, you find it an interesting topic! See you there!

And remember, this annual conference has become a must-attend event for those interested in integration, so check more details about this event here.

Exciting news… Version 1.9.0.0 of BizTalk Mapper Extensions UtilityPack for BizTalk Server 2013 R2 and 2013 is now available!

Here’s the change-log for this release:

  • Ten new functoids:
    • Advance Logical AND Functoid
    • Advance Equal Functoid
    • Advance Greater Than Functoid
    • Advance Greater Than or Equal To Functoid
    • Advance Less Than Functoid
    • Advance Less Than or Equal To Functoid
    • Advance Not Equal Functoid
    • Advance Logical NOT Functoid
    • Advance Logical OR Functoid
    • If-Then-Else Functoid
  • Updates on the deployment scripts
What’s new in this version?

Although BizTalk Server provides many functoids to support a range of diverse operations when working with conditional mapping, we are limited to the number of existing operations or otherwise have to use custom XSLT.

This new library – Logical Functoids – includes a suit of functoids to perform a variety of logical operations, often controlling whether a particular element or attribute is created in an output instance message. Most of the Logical Functoids are a replica of the existent Logical Functoids that came out-of-the-box with BizTalk Server with the advantage that these will allow you to connect with others Custom String Functoids. They are fully compatible with existing functoids and don’t produce any more additional code.

biztalk-mapper-extensions-utilitypack-2013-r2-v1-9

See also the reason I decide to create this library here: Why is so hard to make a simple If-Then-Else Functoid? … well, not anymore!

Advance Logical AND Functoid

Use the Advance Logical AND functoid to return the logical AND of input parameters. It determines whether all of the specified input parameters are true.

Parameters

This functoid requires a minimum of two input parameters and a maximum of one hundred:

  • Parameter 1: A value that can be evaluated as either True or False.
  • Parameters 2 – 100: Values that can be evaluated as either True or False.

Returns the logical AND of parameters. True if all of the specified input parameters evaluate to True; False otherwise.

01-Advance-Logical-AND-Functoid

Advance Equal Functoid

Use the Advance Equal functoid to return the value “true” if the first input parameter is equal to the second input parameter. It tests whether the two input parameters are equal.

Parameters

This functoid requires two input parameters:

  • Parameter 1: A value to be tested for equality with the parameter 2.
  • Parameter 2: A value to be tested for equality with the parameter 1.

Returns “True” if the values of the two input parameters are equal; “False” otherwise.

02-Advance-Equal-Functoid

Advance Greater Than Functoid

Use the Advance Greater Than functoid to return the value “true” if the first input parameter is greater than the second input parameter. It tests whether the first input parameter is greater than the second input parameter.

Parameters

This functoid requires two input parameters:

  • Parameter 1: A value to be tested to determine whether it is greater than parameter 2.
  • Parameter 2: A value to be tested to determine whether it is greater than parameter 1.

Returns “True” if the value of the first input parameter is greater than the value of the second input parameter; “False” otherwise.

03-Advance-Greater-Than-Functoid

Advance Greater Than or Equal To Functoid

Use the Advance Greater Than or Equal To functoid to return the value “true” if the first input parameter is greater than or equal to the second input parameter. It tests whether the first input parameter is greater than or equal to the second input parameter.

Parameters

This functoid requires two input parameters:

  • Parameter 1: A value to be tested to determine whether it is greater than or equal to parameter 2.
  • Parameter 2: A value to be tested to determine whether it is greater than or equal to parameter 1.

Returns “True” if the value of the first input parameter is greater than or equal to the value of the second input parameter; “False” otherwise.

04-Advance-Greater-Than-or-Equal-To-Functoid

Advance Less Than Functoid

Use the Advance Less Than functoid to return the value “true” if the first input parameter is less than the second input parameter. It tests whether the first input parameter is less than the second input parameter.

Parameters

This functoid requires two input parameters:

  • Parameter 1: A value to be tested to determine whether it is less than parameter 2.
  • Parameter 2: A value to be tested to determine whether it is less than parameter 1.

Returns “True” if the value of the first input parameter is less than the value of the second input parameter; “False” otherwise.

05-Advance-Less-Than-Functoid

Advance Less Than or Equal To Functoid

Use the Advance Less Than or Equal To functoid to return the value “true” if the first input parameter is less than or equal to the second input parameter. It tests whether the first input parameter is less than or equal to the second input parameter.

Parameters

This functoid requires two input parameters:

  • Parameter 1: A value to be tested to determine whether it is less than or equal to parameter 2.
  • Parameter 2: A value to be tested to determine whether it is less than or equal to parameter 1.

Returns “True” if the value of the first input parameter is less than or equal to the value of the second input parameter; “False” otherwise.

06-Advance-Less-Than-or-Equal-To-Functoid

Advance Not Equal Functoid

Use the Advance Not Equal functoid to return the value “true” if the first input parameter is not equal to the second input parameter. It tests whether the two input parameters are not equal.

Parameters

This functoid requires two input parameters:

  • Parameter 1: A value to be tested for inequality with parameter 2.
  • Parameter 2: A value to be tested for inequality with parameter 1.

Returns “True” if the values of the two input parameters are not equal; “False” otherwise.

07-Advance-Not-Equal-Functoid

Advance Logical NOT Functoid

Use the Advance Logical NOT functoid to return the logical inversion of the input parameter. Use to logically negate the value of the Boolean input parameter.

Parameters

This functoid requires one input parameter only:

  • Parameter 1: A value that can be evaluated as either True or False.

Returns “True” if the specified input parameter evaluates to False; “False” otherwise.

08-Advance-Logical-NOT-Functoid

Advance Logical OR Functoid

Use the Advance Logical OR functoid to return the logical OR of input parameters. The input parameters have to be Boolean or numeric. It determines whether any of the specified input parameters are true.

Parameters

This functoid requires a minimum of two input parameters and a maximum of one hundred:

  • Parameter 1: A value that can be evaluated as either True or False.
  • Parameters 2 – 100: Values that can be evaluated as either True or False.

Returns “True” if any of the specified input parameters evaluate to True; “False” otherwise.

09-Advance-Logical-OR-Functoid

If-Then-Else Functoid

Use the If-Then-Else Functoid to return a value from one of two input parameters based on a condition. If the condition (first input) is True, then the value of the second input parameter is returned, otherwise the Third input is returned.

Parameters

This functoid requires three input parameters:

  • Boolean representing the result of a previous condition
  • The value to be returned if the condition is True.
  • The value to be returned if the condition is False.

If the condition is True, then the value of the second input parameter is returned, otherwise the Third input is returned.

10-If-Then-Else-Functoid

You can found and download Source Code, Application Binaries and Documentation in CodePlex BizTalk Mapper Extensions UtilityPack home page:

BizTalk Mapper Extensions UtilityPack
CodePlex

 

or from MSDN Code Gallery:

BizTalk Mapper Extensions UtilityPack for BizTalk Server 2013 R2 (685.6 KB)
Microsoft | MSDN Code Gallery

If you are following Logic Apps since its beginning, you must love the new Logic Apps Designer! That is a little closer to his on premise brother (BizTalk Orchestration Designer). I am saying this because now, finally, the new designer uses a top-down approach instead of a left-right approach that existed in the previous version of Logic Apps.

01-Logic-Apps-Designer-left-right-approach

Besides this big improvement in the Visual Flow (top-down approach instead of a left-right approach), the designer is being constantly improved with a several new capabilities such as:

  • Managed Connectors, search capabilities within the designer
    • Adding API Apps to a logic app is now more intuitive
  • We now also have the ability to collapse and expand the tiles/shapes
  • We have a first class experience with the HTTP + Swagger connector within the designer
  • If-else conditions within the designer itself. No need to open up the code view to look into the conditions box.
  • Call nested Logic Apps within the designer
  • And many more, the list go on and on!

02-Logic-Apps-Designer-top-down-approach

In this post we will provide some tips and tricks in working within the new Logic Apps Designer, in terms of actions that we can make on it, and describe some of its behavior

Adding actions (tiles or shapes) …

Adding actions in the middle of the existing flow is not allowed, at least for now. We are only able to add actions on the bottom of our Logic App flow or at the bottom of each condition branches.

To add an action or condition in the Logic App flow: we need to click on the plus sign, and then choose “Add a condition” or “Add an action

09-Logic-Apps-Designer-add-action-or-condition

To add an action inside condition branches, we need to click in “Add an action” button that is present on the top right corner of the condition branch

10-Logic-Apps-Designer-add-action-condition

  • We can add several actions inside a branch;
  • Nested conditions, at least for now, are not allowed;
  • And we can only add actions on the “If no, do nothing” branch, if we have at least one action in the “If yes” branch;

Deleting actions (tiles or shapes) …

If we take in consideration the flow in the picture above, you will notice 4 actions will have “…” (three dots) option in the tile. This means that we can take an action on them, in this case the “Delete” option:

03-Logic-Apps-Designer-Delete-option-action

However, in this sample the other two tiles/shapes available, “Search tweet” and “Condition” doesn’t have this option and we cannot easily delete this action or step.

The reason is because:

  • Their outputs are being used by other actions
    • In this case the “Search tweet” output is being used as input on the “Condition”, “Create File” and “Send approval email”
  • or they contain child action
    • The “Condition” tile as one “child” action in each branch;

04-Logic-Apps-Designer-Cannot-Delete-action

If we remove the “Search tweet” output being used as input on the “Condition”, “Create File” and “Send approval email” or remove these actions, we will now be able to delete the “Search tweet” action

05-Logic-Apps-Designer-Cannot-Delete-action-fixed

Moving actions (tiles or shapes) …

Noticed that you make a mistake and forgot to add an action between previous ones! Well, adding actions in the middle of the existing flow is not allowed, at least for now. However, we have the possibility to add and action in the end and drag and drop to another position inside your flow (arranging/modifying shape dispositions) … within certain conditions…

Again, if we take in consideration the Logic App that we are working above. We have several shapes, “Condition”, “Create file” and “Send approval email” that is consuming the output of a previous action, the “Search tweet

06-Logic-Apps-Designer-movind-Dependecies

If we try to move the “Condition” shape on top of the “Search tweet” shape:

11-Logic-Apps-Designer-moving-condition

We can’t move because it depends on the “Search tweet” action. However, if we try to do the same for the “Dynamic CRM Online – Create a new record”, that is still to be configured, i.e., it doesn’t have any dependency from previous ones

07-Logic-Apps-Designer-movind-no-Dependecies

We will then be able to drag and drop to any place of our flow

08-Logic-Apps-Designer-movind-no-Dependecies-1

08-Logic-Apps-Designer-movind-no-Dependecies-2

The only exception is that you cannot put on top of the trigger, in this case, the “Recurrence” shape.

In summary, you can move shapes only to:

  • Underneath the Logic Apps trigger;
  • Underneath their dependencies;
Moving actions inside conditions

Yes, we can move actions into the conditions branches, between them or remove them from within the conditions branches… again, within certain conditions regarding mainly the “If yes” branch:

  • If we have only one action inside the “If yes” branch
    • We cannot remove this action to outside the “If yes” branch, if the “If no” branch contains any action;
    • We need to delete or remove the shapes inside the “If no” branch to be able to move/remove the action inside the “If yes”;

The reason that this happens is because, the design doesn’t allow you to add action in the “If no” branch until you have an action inside the “If yes” branch

  • If we have several actions inside the “If yes” branch
    • We cannot remove the first action to outside the “If yes” branch, if the “If no” branch contains any action;
    • We need to delete or remove the shapes inside the “If no” branch to be able to remove the action inside the “If yes”;
    • Or we need to move the first action to another position inside the “If yes” branch and then move it to another position inside your flow (outside the “If yes”);

The reason that this happens is because, the first action inside the “If yes” is the “trigger” that allows you add actions in the “If no” branch… so it will be deep tied to the “If yes” branch and the design will not allow it to be moved

  • If we don’t have any action inside the “If yes” branch
    • We cannot move or add an action to the “If no, do nothing” branch;
    • We need to first add an action in the “If yes” branch;

The reason that this happens is because we need to have at least one action inside the If yes” branch to be able to add or move actions to the “If no, do nothing” branch – this is a default behavior of the design. The first action inside the “If yes” is the “trigger” that allows you add or move actions in the “If no, do nothing” branch.

Following my latest posts where I talked about the new “The ability to call nested Logic Apps directly from Logic Apps Designer”. Let’s look how a nested Logic App can help us overcome the current Logic Apps limitation regarding to for each operation, in special, the ability to add more than one action inside the loop;

Using/Implementing Looping inside Logic Apps

If you are used to work with BizTalk Server, we have certain shapes and behaviors inside BizTalk Orchestrations that we would love to have in Logic Apps, at a first glimpse, we may be surprised the lack of features/shapes to perform certain operations…however, that doesn’t mean that they are missing, most of the times we still can do those things… but in a different manner, so we may need to look the “problem” from another angle.

Looping is one of those things!

We don’t have any Looping shape, action or operation that we can use in the Logic App Designer, similar to what we have with Conditions.

01-Logic-Apps-Conditions-shape

In the previous designer (v1) we had an option in the connectors, “Repeat over the list“, that allowed us to iterate over an array of items and run an action for each item in that list.

The current design doesn’t have any more this option, but again that doesn’t mean that you can’t. In this new Logic App version or designer, if it detects that the input from the previous action or trigger it’s an array, and if you try to use this input in a subsequent action, it will, almost every time, automatically put you on a for each operation. Which means that you are running this action for each item in that list.

Let’s look, and use, the basic scenario that we are using in the last posts, were:

  • The Logic Apps is trigger by a new tweet containing the hashtag we are listening;
  • And then create a file;

For now, let’s ignore the dynamic creation of the file name using Azure Functions. So we have this basic Logic App

02-Logic-Apps-Looping-no-loop-Basic-flow

Because each tweet will generate a new execution of this Logic App, the trigger input will be a simple single message and not an array. If we switch to code view we will see that the Create file action will only be executed once and it’s not inside of any loop operation.

03-Logic-Apps-Looping-no-loop-Basic-flow-code-view

So let’s make some changes!

We will use a similar scenario, but this time we want that our Logic App:

  • To be triggered every hour;
  • Retrieve the last 20 tweets with the hashtag #LogicApp
  • And then create a file for each tweet in our Dropbox

For that we will create a new Logic App called “LoopingInsideLogicApps

  • Add a “Recurrence” trigger, and set the:
    • Frequency” property to “Hour
    • And the “Interval” property to “1

04-Logic-Apps-Looping-Reccurence-Trigger

  • Select the plus sign, and then choose “Add an action
  • From the search box select “Show Microsoft managed APIs”, type “twitter” and select the “Twitter – Search tweet” action
    • Set the “Query text” property with “#LogicApps” hashtag
    • You can expand the action to see all the properties if you click “” in the lower left corner
    • And see and define the number of result you want to return

05-Logic-Apps-Looping-Search-For-Tweets

  • Select the plus sign, and then choose “Add an action
  • From the search box select “Show Microsoft managed APIs”, type “Dropbox” and select the “Dropbox – Create file” action
    • Set the “Folder path” property, let’s say the root by typing: /
    • On the “File name” property, set the parameter “Tweet id” from the output of “Search tweet” action as input, following by the string “.txt”
    • On the “File Content” property, set the parameter “Tweet text” from the output of “Search tweet” action as input

06-Logic-Apps-Looping-For-each-Tweets-Create-File

If we “Save” our Logic Apps we will notice that 20 new files will be created in our Dropbox without us having defined any parameter or configuration inside the actions that would tell it to iterate over a list/array.

07-Logic-Apps-Looping-For-each-Tweets-Create-File-dropbox

This happened, because the designer “was smart” to understand that in input from the “Search Tweet” action is an array and automatically told the “Create file” action to work inside a for each so that it could iterate over all the items in the array.

Trying to add several actions inside a for each

Let’s say now that we want to call our Azure Function to generate the file name and create the file name in our Dropbox with it.

At first glance, we might say that:

  • After the “Twitter – Search tweet” action, we need to call our Azure Function: “CreateFileName”, because it doesn’t need inputs we set the input as an empty JSON message
  • And reconfigure the “Dropbox – Create file” action in order that the “File name” property is set with the “Filename” parameter from the output of “CreateFileName” function as input

08-Logic-Apps-Looping-For-each-Tweets-several-actions

If we once again, “Save” our Logic Apps and this time, execute it manually to for it to run. You will notice that:

  • The CreateFileName function is successfully executed;
  • But the Create file action failed. If you see the output, you will notice that the first file was created successfully but the following one’s got the following error:

File ‘/NewTweet_6785b86d-4dda-4119-968f-c189416f22bc.txt’ already exists. Use the Update operation to update an existing file.

09-Logic-Apps-Looping-For-each-Tweets-several-actions-create-dropbox-files-error

Maintaining in the run history, but selecting the “CreateFileName” action to see what was the output of the function we will notice that it was a simple output

   
{    
    "statusCode": 200,    
    "headers": {    
        "pragma": "no-cache",    
        "cache-Control": "no-cache",    
        "date": "Wed, 20 Apr 2016 15:01:18 GMT",    
        "set-Cookie": "ARRAffinity=9b8e91fd330bc5b8e4bdd3e129b0412d5daca54f6c2ff8a25f773cd80fad03aa;Path=/;Domain=functionssandromsdn.azurewebsites.net",    
        "server": "Microsoft-IIS/8.0",    
        "x-AspNet-Version": "4.0.30319",    
        "x-Powered-By": "ASP.NET"    
    },    
    "body": {    
        "FileName": "NewTweet_6785b86d-4dda-4119-968f-c189416f22bc.txt"    
    }    
}    

If we go back to our Logic App designer and switch to “Code View” we will notice why this happened. By setting the input of our function with and empty JSON message were are not telling to the Logic App to iterate over the output array from the “Search Tweet” action and call the function to generate a different file name for each item.

Instead if we analyze the code we will see that the “CreateFileName” function is only call one time, and we will send to the connector Dropbox this same value to all the tweets

10-Logic-Apps-Looping-For-each-Tweets-several-actions-create-dropbox-files-error-why

Trying to add several actions inside a for each (second shoot)

Ok, that didn’t work well. So what if we try to force the call to the Azure Function to be inside the for each statement?

Let’s them make some changes to our Logic App flow:

  • First, delete the “File Name” property from the “Dropbox – Create file” action
    • Leave it empty
  • Second, let’s send a dummy JSON message to our Azure Function, forcing this action to iterate over the “Search tweet” output array of items by setting the following JSON message:
   
{ "dummy": ['Tweet text'] }    

11-Logic-Apps-Looping-CreateFileName-Dummy-Msg

If we switch to “Code view” you will notice that now this action is under a for each:

   
"foreach": "@body('Search_tweet')"    

12-Logic-Apps-Looping-CreateFileName-Dummy-Msg-code

The problem of this approach is that

  • CreateFileName” action
  • And “Dropbox – Create file” action

Are in two different for each statements and if we try to use both in the same action, for example trying to set the “Body” parameter from the output “CreateFileName” function we will receive the following error:

13-Logic-Apps-Looping-CreateFileName-Design-error

Basic workaround to solve this problem

So, one of the workaround that you have is to modify your Azure Function, or create a new one to be able to receive one parameter:

  • the twitter message

and return two parameters:

  • The filename generated
  • And the twitter message that was passed as an input

For example:

   
module.exports = function (context, data) {    
        
  var Tweet = data.Tweet;    
  var d = new Date().getTime();    
  var uuid = 'xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx'.replace(/[xy]/g, function(c) {    
        var r = (d + Math.random()*16)%16 | 0;    
        d = Math.floor(d/16);    
        return (c=='x' ? r : (r&0x3|0x8)).toString(16);    
  });    
        
  // Response of the function to be used later.    
  context.res = {    
    body: {    
      Msg: Tweet.text,    
      FileName: 'TweetMsg_' + uuid + ".txt"    
    }    
  };    
  context.done();            
};    

If we are using this strategy, we then need to configure the input of the function as:

   
{ "Text": ['Tweet text'] }    

14-Logic-Apps-Looping-CreateFileName-with-input-Msg

This will iterate over the list of tweets and will create another list containing all the information that we need to send to the Dropbox connector.

We then need to change all the parameters of the “Dropbox – Create file” action and instead of configuring with values from the “Search tweet” action that will force it to iterate, we will bind it to the output provide by the Azure function output

15-Logic-Apps-Looping-Dropbox-with-CreateFileName-values

This will tell to this action to iterate over the function output array to create all the files in Dropbox.

16-Logic-Apps-Looping-Dropbox-with-CreateFileName-values-code

Once again, if we “Save” our Logic App and run it, we will see that now everything will work fine.

However, in this basic workaround we are not adding several actions to a for each statement, instead we are avoiding, going around it and duplicate the content in another list/array… but it’s there another way?

How to add several actions inside a for each

Indeed, there is a better way to accomplish that, and the solution is to call another Logic App (at least while we do not have this functionality in the design).

Still remember our Logic App that we create in my previous posts called “AddFileToDropbox” that:

  • Its trigger manually, which means through a HTTP post, allowing to be invoked by other Logic Apps
  • Then it will call an Azure Function to dynamically generate a filename;
  • Create a Dropbox file
  • The filename it’s provide by the Azure Function;
  • And the content of the message it’s passed in the HTTP request that triggers this Logic App.
  • And finally return an HTTP response based on the status of the file creation

We will reuse this “child” Logic App in this demo now.

So what we need to do now is delete the last two action from our current Logic App:

  • “Dropbox – Create file” action
  • And call “CreateFileName” function action

And then call our “child” Logic App “AddFileToDropbox”. To accomplish that we need:

  • Select the plus sign, and then choose “Add an action
  • When you select “Add an Action”, the search box will be presented were all the available actions. But now, on the search box you can select the option: “Show Logic Apps in the same region
    • And then select “AddFileToDropbox
    • On the “Text” property we need to set the parameter “Tweet text” from the output of “Search tweet” action as input

17-Logic-Apps-Looping-Call-Logic-app-to-add-multiple-actions

If we now “Save” our Logic App and run it manually, we instantly see that:

  • the “Search tweet” action was successfully executed
  • and the “AddFileToDropbox” action is being executed

18-Logic-Apps-Looping-Call-Logic-app-to-add-multiple-actions-executions

We can go to our “child” Logic App to see its runs (the historic) and you probably see that some of them are already finish and others are still running

19-Logic-Apps-Looping-Call-Logic-app-to-add-multiple-actions-executions-child

Once all the child runs caused by the action of the parent are finished, the parent Logic App will receive the knowledge and will terminate successfully also (if all the runs finish successfully)

How is the behavior of calling a nested Logic App inside a foreach statement?

You may ask yourself how that works, it will execute on iteration one by one, in other words, in other words, will it call the child Logic App synchronously and wait for it to finish returning the response to call another one? Or it will be asynchronous?

Well in BizTalk terms it would be like using a Parallel Actions shape, were all the actions will be executed concurrently but independently but the parent Logic App processing does not continue until all have completed. The parent Logic App in this case will receive an array containing all the responses of the child executions.

In my last blog posts I talked about the new “The ability to call nested Logic Apps directly from Logic Apps Designer” and I mentioned that this great feature, not only allow us to create reusable pieces, but that will allow us to overcome some of the current Logic Apps limitations:

  • The ability to add more than one action inside the condition branch’s (this is actually a false statement);
  • or the ability to add more than one action inside the loop;

In this post we will address the first option, we will leave the second one for a dedicated post. Once again, in my previous post we created a Logic App called “AddFileToDropbox” that:

  • Its trigger manually, which means through a HTTP post, allowing to be invoked by other Logic Apps
  • Then it will call an Azure Function to dynamically generate a filename;
  • Create a Dropbox file
    • The filename it’s provide by the Azure Function;
    • And the content of the message it’s passed in the HTTP request that triggers this Logic App.
  • And finally return an HTTP response based on the status of the file creation

We will reuse this “child” Logic App in our demos here.

Our “basic” demo scenario

The important thing here is to demonstrate the concept itself, not whether this is a real case or not, so we will use connectors that are simple to test.

Let’s say that we want to listen to #LogicApps twitter hashtag, and:

  • If the tweet was made by someone other than me (@sandro_asp) then:
    • We need to call an Azure Function to dynamically generate a filename;
    • Create a Dropbox file
      • The filename it’s provide by the Azure Function;
      • And the content of the message will be the actual tweet text message.
  • If it’s a tweet made by me, let’s say I want to send it in an email to… my manager (just to annoy him Smile)

Creating a Logic App with conditions inside

Let’s create a Logic App call “ConditionsInsideLogicApp” (you can see the basic steps in my previous posts)

  • Add a “Twitter – When a new tweet appears” trigger, to look for a new tweet containing the hashtag “#LogicApps

01-Logic-Apps-Conditions-Add-Tweet-Appear

  • Select the plus sign, and then choose “Add a condition

02-Logic-Apps-Conditions-Add-a-condition

Note: if by any chance, you verify that the conditions branches, “if yes” and “if no, do nothing“, are not side by side as would be expected, but instead they are in sequence, one under the other:

03-Logic-Apps-Conditions-note

do not be alarmed, there is nothing wrong in your editor. It just means that your monitor does not have enough resolution, you are using a large zoom or your browser window is too small for render the conditions side by side. If you switch for a different monitor or zoom out, you will see that they will be rendered side-by-side:

04-Logic-Apps-Conditions-side-by-side

  • Now that we have the condition action we need to configure in following manner:
    • In the “Object name” property we need to set the parameter “Tweet by” from the output of “When a new tweet appears” trigger
    • In the “Relationship” property we need to choose the option “is not equal to
    • And finally on the “Value” property we need to statically set the value “@sandro_asp

05-Logic-Apps-Conditions-Tweet-condition-configuration

Note: If we look to our “If yes” branch we will see that we only have the ability to “Add an action” with means that we cannot create, at least for now, nested conditions (you probably can if you call another Logic App)

06-Logic-Apps-Conditions-add-action-if-branch

  • If we go to our “If yes” branch and “Add an action”
    • From the search box select “Show Azure Functions in my subscription” and select the Azure Function: “CreateFileName” and set the “Input payload object” as an empty JSON message:
   
{ }

07-Logic-Apps-Conditions-add-action-if-First-action

Based on your user experience in the Logic App designer, you may think that you cannot add more actions inside the “If yes” branch because you don’t have the plus sign underneath the Call Azure Function action. Well, you are wrong!

You actually can add several actions (conditions are not allowed) inside the same branch, by clicking once again the “Add an action” on the top right corner.

08-Logic-Apps-Conditions-add-action-if-second-action

  • From the search box, type “Dropbox” and select the “Dropbox – Create file” action
    • Set the Folder path, let’s say the root by typing: /
    • Click on the Filename and set the parameter “Body” from the output of “CreateFileName” function as input
    • Switch to code view to edit Create file inputs to have the expected values
   
@{body('CreateFileName')['FileName']}    
    • And then click on “File content” text box, and set the parameter “Text” from the output of “When an HTTP request is received” as input
  • On the “If no, do nothing” branch, click “Add an action
    • From the search box select “Show Microsoft managed APIs” type “email” and select the “Office 365 Outlook – Send Email” action
      • On the “Subject” property, statically set as “Tweet related to Logic Apps
      • On the “Body” property set the parameter “Tweet text” from the output of “When a new tweet appears” trigger
      • On the “To” property, set the email of your manager Smile

09-Logic-Apps-Conditions-add-action-if-no-email-action

At the end your Logic App will have a condition with:

  • Two actions in the “If yes” branch
  • And one action in the “if no” branch

13-Full-Logic-App-conditions

Save” your logic app and wait to a tweet to appear, we will see that a new file was added in your Dropbox or an email as sent to your manager

Second option

Because we already created a Logic App that makes the necessary steps for the condition “If yes“:

  • Generate a file name
  • And create a file in dropbox

We instead of having several action, creating and repeating the same steps over an over again, we can call the “AddFileToDropbox” to do the same steps for us.

10-Logic-Apps-Conditions-add-action-if-call-Logic-App

Advantages of this approach:

  • We are reusing “code”
  • We can add “nested” conditions

Disadvantages:

  • ·We loose a little the run action history because we then have the action “AddFileToDropbox” but we cannot easily go to the child run and correlate the existing runs.

11-Logic-Apps-Conditions-runs-action-history

12-Logic-Apps-Conditions-runs-action-history-2

Microsoft Integration Product team announced this month on their monthly webcast (that you can see it here) some of the new features that are now available in Logic Apps like:

  • “Run” any trigger now
  • HTTP Webhook in Designer
  • SQL Azure Connector now supports Store Procedures
  • Azure Functions Integration and a few other features

In my last blog posts I talked about the new “Azure Functions Integration” (here and here). One of the features that they announced that it would soon be available was “Call nested workflow in Designer”, and the good news is that it is now available to us “to play”.

This is a great feature that will allow us to:

  • Create reusable pieces
  • Overcome some Logic Apps limitations, and what I mean by that is for example:
    • The ability to add more than one action inside the condition branch’s (this is actually a false statement);
    • or the ability to add more than one action inside the loop;

Call nested workflows, or Logic Apps, from another Logic App is actually not a new feature. We could previous achieve this as you can see in this post: Using Nested Azure Logic Apps … or Invoking Flows from another Logic App. However, it was not a “first class” experience and we were forced to implement some workarounds to be able to achieve this goal…. Not anymore! Now it way more simple and with a good user experience in the designer!

Creating the child Logic App

The first thing that you need to know is that, if you want to create a Logic App that you can call through another Logic App:

  • The trigger of that Logic App needs to be “Manual – When an HTTP request is received
  • And it should finish with an “Response” action

If we don’t add the “Response” action in our child Logic App what will happen is:

  • The parent will call the child workflow
  • The child workflow will be executed
  • But the parent workflow will fail with the following error:

To wait on nested workflow ‘{Child Logic App Name}’, it must contain a response action.

01-Logic-Apps-father-workflow-fails-without-child-response

Let’s create a simple scenario to demonstrate how we can call nested Logic Apps directly from Logic Apps Designer. In this sample we want to create a child Logic App that:

  • It’s trigger manually, which means through a HTTP post;
    • In this case, let’s consider the following JSON message
   
{    
   "Request": {    
      "text": "text that we want to put in file content"     
   }    
}    
  • Then it will call an Azure Function to dynamically generate a filename;
  • Create a Dropbox file
    • The filename it’s provide by the Azure Function;
    • And the content of the message it’s passed in the HTTP request that triggers this Logic App.
  • And finally return an HTTP response based on the status of the file creation;

To accomplish that we need:

  • On the Azure Portal click on “Logic Apps” option and click “Add” to create a new Logic App.
  • In the “Create logic app” panel we need to give it:
    • A “Name”, for example “AddFileToDropbox
    • Select the desired “Subscription” (if you have more than one)
    • Select the desired “Resource Group” or create a new one
    • And finally define the “App Service Plan” by choosing an existing plan or add a new one
  • Click “Create” for the deployment process to start.

We have to wait a few seconds for the deployment process to finish, once it’s finished we will be notified in the notification area. You can check for more Logic Apps create process details here.

If we select, from the Logic Apps list, the Logic App created above to open de Logic Apps Designer, we then need to:

  • From “Show Microsoft management APIs” option search box, click on the “Manual – When an HTTP request is received” trigger

02-Logic-Apps-Add-Manual-HTTP-Request-Trigger

  • Now, we need to give to the HTTP trigger the JSON message schema that will be send, so that we can easily create steps.
    • Unfortunately, for now is still not possible to configure the schema directly from the designer

03-Logic-Apps-Manual-HTTP-Request-Cannot-add-schema

    • While Product team is improving this feature, for now we need to switch to “Code view” and configure the schema on the “triggers” –> “manual” –> “inputs” –> “schema” property, that for now it’s an empty schema

04-Logic-Apps-Manual-HTTP-Request-set-schema-code-view

    • To generate the JSON schema we can use the JSONSchema.net online tool to easily do that task for us.
    • We just need to past our JSON message sample provide above and click “Generate Schema

05-Logic-Apps-JSON-Schema-Generator

    • We then need to copy the JSON Schema from the website and paste it to on our Logic App code view schema property

06-Logic-Apps-Manual-HTTP-Request-set-schema-code-view-fixed

  • Now that we have set our trigger, let’s move to the next step of our Logic App.
  • Select the plus sign, and then choose “Add an action

00-plus-action

  • When you select “Add an Action”, again the search box will be presented were all the connectors with their available actions are listed. But now, on the search box you can select the option: “Show Azure Functions in my subscription

06-Logic-Apps-Add-Action-Azure-Function

  • From the search box select “Show Azure Functions in my subscription” let’s select (if you already have it) or create a new WebHook Node function call: “CreateFileName
   
module.exports = function (context, data) {    
        
  var Tweet = data.Tweet;    
  var d = new Date().getTime();    
  var uuid = 'xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx'.replace(/[xy]/g, function(c) {    
        var r = (d + Math.random()*16)%16 | 0;    
        d = Math.floor(d/16);    
        return (c=='x' ? r : (r&0x3|0x8)).toString(16);    
  });    
        
  // Response of the function to be used later.    
  context.res = {       
    body: {    
      FileName: 'NewTweet_' + uuid + ".txt"    
    }            
  };    
    • This function doesn’t need any input, so we will set the “Input payload object” as an empty JSON message:
   
{}    

07-Logic-Apps-Call-Azure-Function-CreateFileName

  • Once again, select the plus sign, and then choose “Add an action
  • From the search box, type “Dropbox” and select the “Dropbox – Create file” action

08-Logic-Apps-Add-action-Dropbox-Create-file

    • Set the Folder path, let’s say the root by typing: /
      • Note: That you can also use the “…” button to navigate to your Dropbox folders
    • Click on the Filename and set the parameter “Body” from the output of “CreateFileName” function as input
      • You don’t need to do this step, but the reason why I do it’s because I am a little lazy and I want the designer do half of the work for me
    • And then click on “File content” text box, and set the parameter “Text” from the output of “When an HTTP request is received” as input

09-Logic-Apps-Add-action-Dropbox-Create-file-configured

    • On the top of the Logic Apps Designer click in “Code view” option, for us to fix the “File Name” input parameter
    • Then we need to edit Create file inputs to have the expected values
      • Change the “inputs” –> “queries” –> “name” property to:
   
@{body('CreateFileName')['FileName']}    

10-Logic-Apps-Add-action-Dropbox-Create-file-configured-fixed

  • Now if we change to the Logic Apps Designer, by clicking “Designer” option, we will notice that the designer already renders this property and set the expected parameter.
  • Once again, select the plus sign, and then choose “Add an action
  • From the search box, type “Response” and select the “Response” action
    • Set the “Status Code” with the value “200
    • And set the “Body” as “The file created was ” and the filename parameter from the output of “CreateFileName” function as input

11-Logic-Apps-Add-Response

  • Save your Logic App and we are now ready to use/call this workflow from other Logic Apps.

Creating the parent Logic App

If we now create another Logic App – the parent – let’s call it “CallNestedLogicAppDemo”.

  • Add a “Twitter – When a new tweet appears” trigger, to look for a new tweet containing the hashtag “#LogicApps
  • Select the plus sign, and then choose “Add an action
  • When you select “Add an Action”, the search box will be presented were all the available actions. But now, on the search box you can select the option: “Show Logic Apps in the same region

12-Logic-Apps-Show-Logic-Apps-in-the-same-region

  • This will show you all the available Logic Apps that you can call from your current Logic App

13-Logic-Apps-Show-Logic-Apps-in-the-same-region-list

    • Let’s select the “AddFileToDropbox” that we create earlier
  • When you select the Logic App that you want to call, the designer will render the action containing the schema inputs that we need to pass to the nested Logic App
    • In our case, the “Text”.

14-Logic-Apps-Show-AddFileToDropbox

How cool is that! Yeh!

  • Don’t change the “Trigger name” this should be set as: “Manual”
    • Why? Because this is the default trigger type from your previous child Logic App.
  • And the “Text” property we need to set the parameter “Tweet text” from the output of “When a new tweet appears

15-Logic-Apps-Show-AddFileToDropbox-configured

Once again, “Save” your logic app and wait to a tweet to appear, we will see that a new file was added in your Dropbox:

16-Logic-Apps-Show-file-being-added-to-dropbox

You can also check the runs of the Logic App to see if it runs successfully or if an error occurred and what, how long it took to run, inputs and outputs, among others

17-Logic-Apps-Show-logic-app-runs

Unfortunately, here we don’t have a similar functionality that we have on BizTalk Orchestration Debugger, the ability to “View Called orchestration”. It would be great to have here a similar one “View Called workflow runs”. I add this request on User voice and if you like it you can go there and vote.

If you want to achieve this, you need to go to the child Logic app and see it’s runs, and check if all steps are proper executed.

17-Logic-Apps-Show-child-logic-app-runs

You now can reuse this “AddFileToDropbox” in several Logic Apps that you have or will create in the future.

The parent will always execute successfully because you always returning status 200 from your child Logic App!

Well, yes indeed my last step is returning a status 200 for the parent Logic App, but this will only happen if all previous steps of the flow will be executed successfully, otherwise an error status will be received.

To put this scenario in test, I changed the “Dropbox – Create file” action in my “AddFileToDropbox” Logic App to always create a file with the name “Demo1.txt”. I then waited to appear two different tweets. The result:

  • The first execution was executed successfully
  • And the subsequent executions failed

18-Logic-Apps-Show-logic-app-runs-failed

With the following error:

   
{    
    "statusCode": 502,    
    "headers": {},    
    "body": {    
        "error": {    
            "code": "NoResponse",    
            "message": "The server did not received a response from an upstream server. Request tracking id '08587405217965861441'."    
        }    
    }    
}    

If we check the child execution, we will see that the Logic App is failing in the “Dropbox – File Create” action and the “Response” action will be aborted

19-Logic-Apps-Show-child-logic-app-runs-failed

In one of my last posts I explain how to call an Azure Function to create a basic dynamic Hello World Logic App, but it was a simple introduction to Azure Functions Integration inside Logic Apps. However, there are many other scenarios that wasn’t address in the post like:

  • How can you pass inputs to an Azure Function?
  • How to deal with “complex” outputs from the Azure Function?
  • What types of Azure Functions are supported?
  • and so on.

In this post we will try to deepen some of these topics and provide you some tips and tricks for to get you started using Azure Functions on your Logic Apps

What types of Azure Functions are supported?

Azure Functions provides you a variety of templates options to create a functions, from BlobTrigger (C# and Node), Empty (C# and Node), EventHubTrigger (C# and Node), HttpTrigger (C# and Node)… to Generic WebHook (C# and Node)

01-Azure-Functions-Choose-a-template

Despite all this varied offer, at the moment (everything on Azure can evolve and change rapidly), the only supported Azure Functions that you can call inside your Logic Apps are:

  • WebHook Node JS Functions
  • Or WebHook C# Functions

02-Azure-Functions-supported-types-on-Logic-Apps

How can we pass inputs to an Azure Function and access to the output?

After a while is very simple to understand what is need to do to send inputs to an Azure Function, however, access to the response output, or outputs, and use them in subsequent connectors… can bring some challenges.

Let’s create some basic samples in order to try to demystify some of these challenges, and for these samples we will be using WebHook Node JS Functions.

An important thing you need to be aware is that, within Logic Apps, you need to always send a valid JSON message as input to a Webbook Function.

Sending empty inputs to an Azure Function

So for example if your Function doesn’t really need to have any input, you will still need to send a valid JSON message, but because any value that we spend is unnecessary, the trick here is to send an empty JSON message:

  • “{}” – without double quotes

03-Azure-Functions-sending-an-emptu-msg

If we don’t do this and leave the Input Payload Object empty or “” the Logic App will fail with the following error:

“The WebHook request must contain an entity body formatted as JSON.”

Sending inputs to an Azure Function

To send inputs to the Azure Function we need to, for example, manually create our JSON message as on the “Input payload object” property inside the Configure Function Inputs panel. Let’s look to an example:

  • I add a “Twitter – When a new tweet appears” trigger in my Logic App, that looks for a new tweet containing the hashtag “#LogicApps”
    • In my case I will use “#nodejs” for the sake of speed, since they are constantly emerging tweets with this hashtag

03-a-Azure-Functions-Tweet-Appears-query

And I want to send the “Tweeted by” and “Tweet text” as inputs for my Azure Functions, let’s ignore for now what the function does, but the function needs to receive the following JSON format.

   
{    
  "Tweet": {    
    "by": "New York",    
    "text": "21 2nd Street"    
  }    
}    

To accomplish this on the “INPUT PAYLOAD OBJECT” property I need, for example (that depends on the code of the function), to:

  • On the text property, type: {“Tweet”: {“by”:
    • Here I’m starting to create my JSON message
  • Next I need to select the “Tweeted by” output from my twitter trigger, you can see all the elements of previous steps that you can use on the bottom of the window of this action.

04-Azure-Functions-add-first-element

  • After that we need to continue to create the remainder of the message by typing:
    • ,”text”:
  • Select the “Tweeted text” output from the twitter trigger and finally type the rest of the JSON message:
    • }}

The end result will look like this:

05-Azure-Functions-add-second-element

Retrieving the output of an Azure function

Now that we now you to send inputs to our Azure Function, let’s see how can use their output in subsequent connectors.

Following input sample provide above:

  
{  
  "Tweet": {  
    "by": "New York",  
    "text": "21 2nd Street"  
  }  
}  

Let’s say that we have the following Azure Function:

   
module.exports = function (context, data) {    
        
  var Tweet = data.Tweet;    
  
  var d = new Date().getTime();    
  var uuid = 'xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx'.replace(/[xy]/g, function(c) {    
        var r = (d + Math.random()*16)%16 | 0;    
        d = Math.floor(d/16);    
        return (c=='x' ? r : (r&0x3|0x8)).toString(16);    
  });    
        
  // Response of the function to be used later.    
  context.res = {       
    body: {          
      Msg: 'Sandro you have a new tweet msg: ' + Tweet.text,    
      FileName: 'TweetMsg_' + uuid + ".txt"         
    }         
  };    
                
  context.done();    
};     

That returns the following output (in result of the input provided earlier):

   
{    
  "Msg": "Sandro you have a new tweet msg: This is #LogicApps demo msg",    
  "FileName": "TweetMsg_315381a5-847f-4962-9f1f-4fb65a958753.txt"    
}    

And we want to create a Dropbox file containing only the value of the output parameter “Msg” and the name of the file should be the value of the output parameter “Filename”.

But for now let’s set the filename statically as “Demo1.txt”

If we add a “Dropbox – Create file” connector to our Logic App

06-Azure-Functions-add-Dropbox-Create-file

  • Set the Folder path, let’s say the root by typing: /
    • Note: That you can also use the “…” button to navigate to your Dropbox folders
  • Click on the Filename and type: Demo1.txt
  • And then click on “File content” text box, we will notice that the output parameters of the Azure Function are in design “Body” and “Status code”.
    • Let’s select “Body” as the content of the file we want to create.

07-Azure-Functions-Dropbox-Create-file-Demo1

If we save and execute the Logic App, when a new tweet is found, we will see a new file in our Dropbox, however, the content of the file will be the entire JSON message that is returned by the function

08-Azure-Functions-Dropbox-Demo1-Content

We can also receive the following error on the following Logic App executions, we will deal with it shortly:

“body”: {
“status”: 409,
“message”: “File ‘/Demo1.txt’ already exists. Use the Update operation to update an existing file.”,
“source”: “127.0.0.1”
}

So how I can access to the output parameters and using them on the Dropbox connector properties?

The trick here is:

  • at design time, set the function output parameter “Body” both in the “FILE NAME” and “FILE CONTENT” properties of the Dropbox connector (or any other connector)
    • You don’t need to do this step, but the reason why I do it’s because I am a little lazy and I want the designer do half of the work for me

09-Azure-Functions-Dropbox-Create-File-Default-configuration

  • And then on the top of the Logic Apps Designer click in “Code view” option, for us to edit this values in “Code View” mode

11-Azure-Functions-Logic-Apps-Designer-Code-View

  • Then we need to edit Create file inputs to have the expected values

12-Azure-Functions-Logic-Apps-Designer-Code-View-properties

    • Change the “inputs” –> “queries” –> “name” property to: @{body(‘TwitterPassDataToFunction’)[‘FileName’]
    • And the “inputs” –> ”body” to: @{body(‘TwitterPassDataToFunction’)[‘Msg’]

13-Azure-Functions-Logic-Apps-Designer-Code-View-properties-fixed

Now if we change to the Logic Apps Designer, by clicking “Designer” option, we will notice that the designer already renders these properties to set the expected parameters. Parameters that are not there out-of-the-box

14-Azure-Functions-Logic-Apps-Designer-properties-fixed

If we once again save and execute the Logic App, when a new tweet is found, we will see a new file in our Dropbox with the expect file name:

19-Azure-Functions-Dropbox-Files-Created

And if we check the content of the file(s), we will also see that the file has the expected content:

16-Azure-Functions-Dropbox-Files-Expected-Content

I hope that next version will have a better experience to deal with the Azure Functions outputs to have, by default, a first class experience.

Azure Function returning only one parameter

The previous sample returns two parameters, now if we want to return only one parameter, creating a concept of “a string variable” that you can use in subsequent connectors. We can make small changes to our Azure Function to have a first class experience without the need to switch to “Code View” to change the inputs of the connector.

Using the same sample, let’s assume that:

  • Our function only returns the message that we want to put in the context of our file
  • we want the file name to have the “Tweet id” as the filename, instead of the previous “Filename” that will no longer exist
  • The file context will be provided by the output of the Azure Function

If we create a new Azure Function from the Logic App Designer it will suggest the following code, that of course we can change:

   
module.exports = function (context, data) {    
        
  var Tweet = data.Tweet;    
        
  // Response of the function to be used later.    
  context.res = {    
            
    body: {    
                
      greeting: 'Hello ' + Tweet + '!'    
                
    }    
                
  };    
           
  context.done();    
          
};    

If we use this template approach and change the code to have, for example:

   
body: {     
      Msg: 'Sandro you have a new tweet msg: ' + Tweet.text          
    }    

We will face the same problem as the previous sample, and we would have to access to “Code View” and manually change/set the parameters of the subsequent connectors.

But in this case we can implement a different approach to have a better user experience in the Logic Apps Designer. Instead of following the suggested approach we can implement the following code:

   
module.exports = function (context, data) {
  
  var Tweet = data.Tweet;      
  // Response of the function to be used later.    
  context.res = {      
   body: 'Sandro you have a new tweet msg: ' + Tweet.text   
  };    
       
  context.done();       
};    

If we try to execute this function through the Azure Portal, we will notice that the output is no longer a JSON message:

   
{    
  "Msg": "Sandro you have a new tweet msg: This is #LogicApps demo msg",    
  "FileName": "TweetMsg_83557388-97c4-4503-a3cd-7be145f31d42.txt"    
}    

But instead is now a string:

   
Sandro you have a new tweet msg: 21 2nd Street    

17-Azure-Functions-test

If we now go back to our logic app that we created earlier and:

  • Set the “Dropbox – Create file” filename property with the Twitter output parameter “Tweet id” and add a file extension by typing “.txt”
  • And the file content with the Azure Function output parameters: “Body”

18-Azure-Functions-Dropbox-reconfigured

If we, once again, save and execute the Logic App, when a new tweet is found, we will see a new file(s) in our Dropbox are created with the expected file name:

19-Azure-Functions-Dropbox-Files-Created

And if we, once again, check the content of the file(s), we will also see that the file has the expected content:

20-Azure-Functions-Dropbox-Files-Expected-Content

Having this way, a better user experience inside the Logic Apps Designer. However, this approach only works if the output is a single value (int, string, double).

This post is for the BizTalk Server and Microsoft Azure Portuguese Community, will be held on April 216, 2015 – between 9:00 AM – 6:00 PM the Global Azure Bootcamp 2016 – Lisboa at Microsoft Portugal in Lisbon.

In April of 2013 the first Global Windows Azure Bootcamp has held in more than 90 locations around the globe. One year later the numbers have risen to 136 locations, and again last year the trend continued setting a record of 182 locations! this year it is expected a new record (189 events worldwide)!

Global-Azure-Bootcamp-2016–Lisboa

O Global Azure Bootcamp (#GlobalAzure) está de regresso a Lisboa no próximo dia 16 de Abril para a edição de 2016!

No maior evento de Azure do planeta, a comunidade vai ter a oportunidade de experimentar as últimas novidades da plataforma e entrar em contacto com os maiores especialistas portugueses na plataforma.

Junta-te a nós a partir das 9h00 para um dia repleto de coisas interessantes para fazer/assistir:

  • Sessões técnicas
  • Global Science Lab
  • Intro & Advanced Labs
  • Architecture Design Lab/Kata

Traz o teu portátil e aproveita para experimentar alguns dos desafios que temos para ti!

Além das sessões técnicas teremos vários labs à disposição dos participantes. Existirão labs mais introdutórios para quem quer ganhar conhecimentos e labs mais avançados para quem pretende aprofundar o know-how em Azure.

Sobre a minha sessão…

The "Apps" World: Logic, API & Power” – A minha sessão será uma introdução as novas funcionalidades de integração existentes no Azure, nomeadamente: Logic Apps, API Apps e Power Apps. Como podemos começar a utilizar estas novas funcionalidades que ainda se encontram em preview, o que à de novo em Logic Apps (por exemplo o novo Logic App Designer) e o que são as PowerApps e onde as podemos usar.

Logic-Apps-and-Power-Apps

A Agenda…

09:00: Registration Open;

09:30: Introduction to the Windows Azure Global Bootcamp
          Virgílio Esteves, Vítor Faria Tomaz, Luís Calado e João Pedro Martins

10:00: Azure API Management
         
Luis Calado

10:45: Networking / Coffee Break;

11:15: The "Apps" World: Logic, API & Power
         
Sandro Pereira

12:00: Azure Service Fabric: Micro-services done right
         
João Pedro Martins

12:45: Lunch;

13:45: Azure Container Service: "Containers, Containers, Containers"
         
Virgilio Esteves

14:30: Intelligent Applications with Microsoft Cognitive Services
         
Rui Quintino

15:15: Networking / Coffee Break;

15:45: Azure Resource Manager
         
Vítor Faria Tomaz

16:30: Architecture Design Lab/Kata Presentations

17:15: Azure IoT (sessão NetPonto)
         
André Melancia

18:00: Closure
          Virgílio Esteves, Vítor Faria Tomaz, Luís Calado e João Pedro Martins


Data Evento
: 16 Abril 2016 – 09:00H

Local do Evento: Microsoft Portugal | Rua do Fogo de Santelmo Lote 2.07.02 | Lisboa 1990-110 | Portugal

Saiba mais sobre o evento na página do Global Azure Bootcamp 2016 – Lisboa

O evento é gratuito! De que está à espera? Reserve já o seu lugar aqui e participe!

Estamos a sua espera!

00-Logic-Apps

Microsoft Integration Product team announced yesterday on their monthly webcast (that you can see it here) some of the new features that are now available in Logic Apps like:

  • “Run” any trigger now
  • HTTP Webhook in Designer
  • SQL Azure Connector now supports Store Procedures
  • Azure Functions Integration and a few other features

In this my first blog post about Logic Apps I will talk about this last feature the new “Azure Functions Integration”.

At Build it was a new feature announced in Azure call “Azure Functions” which basic allows you to run small snippets of code out in the cloud. You can learn more about it here: https://azure.microsoft.com/en-us/services/functions/. So let’s explore this new feature and see how can we use it inside our Logic Apps.

Get started with Azure Functions

To get start using Azure Functions, currently in Preview, you can access to https://functions.azure.com/ and you just need to fill:

  • Your Azure Subscription from the combobox
  • Give a Name to the Function App
  • And select your desired Region

01-Get-Start-with-Azure-Functions

  • And then click “Create + Get started” button.

This will create your Function App and will redirect you to your azure portal subscription.

02-Azure-Portal-Azure-Functions

Let’s leave this windows open for now, because we will create our function through the Logic App design, and get to your Azure Portal subscription.

Create your Hello World Logic App

For this exercise I intend to create a very basic Logic App that will run once a day, be with me this is a simple Hello World, but instead of writing a static message “Hello world” I want to provide a more dynamic behavior and find out the day of the week that this Logic App is being executed and write “Hello World! this is #LogicApps and I hope you have a great Friday” … or Saturday, Sunday, Monday, …

For that I will call an Azure Function to get the day of the week and then post on my twitter this twitter post Smile.

To accomplish that we need:

  • On the Azure Portal click on “Logic Apps” option and click “Add” to create a new Logic App.

03-Azure-Portal-Logic-Apps

    • If is not present you can find it by clicking “+ New” –> “Web + Mobile” –> “Logic App

04-Azure-Portal-Logic-Apps

Note: I will create everything from the scratch, including creating a:

  • Free App Service Plan: represents a set of features and capacity that you can share across multiple apps in Azure App Service, including Web Apps, Mobile Apps, Logic Apps or API Apps. These plans support different pricing tiers (Free, Shared, Basic, Standard and Premium) where each tier has its own capabilities and capacity.
  • and Resource group: are logical containers that allow you to group individual resources such as virtual machines, storage accounts, websites and databases so they can be managed together.
  • In the “Create logic app” panel we need to give it:
    • A “Name”, for example “MyDynamicHelloWorldLApp”
    • And select the desired “Subscription” (if you have more than one)

05-Azure-Portal-Create-Logic-App

    • Set a “Resource Group” or create a new one by selecting “+ New” option and give a resource group name in the “New resource group name” text field

06-Azure-Portal-Create-Logic-App-Add-Resource-Group

    • And finally define the “App Service Plan” by choosing an existing plan or add a new one by
      • clicking “App Service Plan” –> “Create New” and then we need to:

07-Azure-Portal-Create-Logic-App-Create-App-Service-Plan

      • set a “App Service Plan” name, for example “MyFreeLogicAppServicePlan”
      • select your desired Location
      • and then click “Price tier” –> “View All” –> “F1 Free

08-Azure-Portal-Create-Logic-App-Create-App-Service-Plan-free

      • Click “Select” and in then “OK
    • Finally, on the “Create Logic app” panel click “Create” for the deployment process to start.

We have to wait a few seconds for the deployment process to finish, once finished we will be notified in the notification area.

09-Azure-Portal-Logic-App-Deploy-success

Now, if we refresh the Logic Apps page, we will now see and have access to the new Logic App we were building.

10-Azure-Portal-Logic-Apps-list

Note: if we click on “” you can pin this Logic App to your dashboard.

To edit and create the logic flow of you Logic App, you just need to click on the Logic App name to open the Logic Apps Designer.

11-Azure-Portal-Logic-Apps-Designer-Empty

To accomplish the goal that we described in the beginning of this post we need to:

  • When your access to the Logic Apps Designer a search box is presented were you can search for available connectors or triggers (API) management by Microsoft (default option) or inside your subscription. From “Show Microsoft management APIs” option, click on the “Recurrence” trigger

12-Azure-Portal-Logic-Apps-Designer-Add-recurrence-trigger

    • That will enable our Logic App to run periodically based on frequency and interval, in this case:
      • Frequency: “Day”
      • Interval: “1”

13-Azure-Portal-Logic-Apps-Designer-Add-recurrence-trigger-conf

Note: Recurrence trigger do not have anything in the inputs object the common properties for all triggers are sufficient to define a basic recurring trigger.

  • Select the plus sign, and then choose “Add an action

14-Azure-Portal-Logic-Apps-Designer-plus

  • When you select “Add an Action”, again the search box will be presented were all the connectors with their available actions are listed. But now, on the search box you can also select the option: “Show Azure Functions in my subscription

15-Azure-Portal-Logic-Apps-Designer-Show-Azure-Functions

    • This will present all the Azure Functions that you can use inside your Logic App;
    • And also the availability to create new WebHook Node JS Functions
  • From the search box select “Show Azure Functions in my subscription” and then “Create New Function”.

16-Azure-Portal-Logic-Apps-Designer-Create-New-Azure-Functions

    • On the “Configure Function Inputs”, and because with don’t have or need to send any input (in this case), you can type an empty JSON message: “{}” and click “Next

17-Azure-Portal-Logic-Apps-Designer-Configure-Azure-Functions-input

    • On the “Function Authoring
      • Set the “Function name” as “GetHelloWorldTwitterMsg”
      • And past the following code in the “Code” text box
module.exports = function (context, data) {
        
    var d = new Date();
    var weekday = new Array(7);
    weekday[0]=  "Sunday";
    weekday[1] = "Monday";
    weekday[2] = "Tuesday";
    weekday[3] = "Wednesday";
    weekday[4] = "Thursday";
    weekday[5] = "Friday";
    weekday[6] = "Saturday";

    var n = weekday[d.getDay()];
        
  // Response of the function to be used later.
  context.res = {
            
    body: 'Hello World! this is #LogicApps and I hope you have a great ' + n
                
  };
                
  context.done();
                
};
    • Click “Create

18-Azure-Portal-Logic-Apps-Designer-Configure-Azure-Functions-Function-Authoring

  • Once again, select the plus sign, and then choose “Add an action” option
  • From the search box, type “Twitter” and select the “Twitter – Post a new tweet” action

19-Azure-Portal-Logic-Apps-Designer-Add-Twitter-Action

    • The first step is to sign in to twitter and authorize Azure AppService Logic Apps to use your account

20-Azure-Portal-Logic-Apps-Designer-Add-Twitter-sin-in

21-Azure-Portal-Logic-Apps-Designer-Add-Twitter-Autorize

      • After you authorize the Logic App to use your account you can now configure the text to be posted in your twitter account
    • On “Post a new tweet”, click on “TWEET TEXT” text box and the outputs from the “GetHelloWorldTwitterMsg” function will be presented
      • Select “Body” output to be the tweet text to be posted on your twitter

22-Azure-Portal-Logic-Apps-Designer-Twitter-Post-a-new-tweet

  • Finally, you can select “Save”, on the Logic Apps Designer menu, to make your logic app live.

If you now check your twitter account, we will see a new tweet:

24-new-tweet

Manager and Testing your Azure Functions

If you access to your Azure Function app page that we had accessed at the beginning of this post, and refresh it, you will see the new Function that we have created inside our Logic App

25-new-function-inside-Function-app-page

Here we are also able to “debug” and try the function code to check if everything is ok.

26-test-azure-function

A special thanks to my colleague André Silva, who got curious about what I was doing and spend a little of his time with me and helped me with the Javascript code.