cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
mmattar Post Patron
Post Patron

Azure Functions

Hello,

 

I have an app that has a good amount of business logic and its becoming very messy to open up blank screens to create controls to be looked at that other screens will look at for rules. Is thier a way i can write my code in one defined place, i seen the use of Azure functions can someone explain that and will it help ? thanks

1 ACCEPTED SOLUTION

Accepted Solutions
Dual Super User
Dual Super User

Re: Azure Functions

No, not directly.  You can pass content to the function and receive results back that can then be displayed in the forms.  But the function itself runs external to PowerApps, so think of it like a black box.



-------------------------------------------------------------------------
If I have answered your question, please mark your post as Solved.
If you like my response, please give it a Thumbs Up.

View solution in original post

13 REPLIES 13
Dual Super User
Dual Super User

Re: Azure Functions

Think of Azure Functions like webservices that you can call to calculate some data.  They are a definate option for offloading business logic.  The one downside to be aware of is that calling them requires the use of Send an HTTPS request which is a premium feature so it may require additional licensing if your license is just the one that comes with Office 365.



-------------------------------------------------------------------------
If I have answered your question, please mark your post as Solved.
If you like my response, please give it a Thumbs Up.
mmattar Post Patron
Post Patron

Re: Azure Functions

ok, so for example. I have a record in a SQL Table that contains a couple columns as date/time types. Would i be able to use Azure functions to create some business logic that says "hey this time cannot overlap that, and or if this time is the same as that add 15 seconds", just a high level overview of what id like to accomplish

 

Dual Super User
Dual Super User

Re: Azure Functions

Yes, you could do that.  Here's a Blog post on how to use Azure functions in PowerApps.

https://powerapps.microsoft.com/en-us/blog/using-azure-functions-in-powerapps/



-------------------------------------------------------------------------
If I have answered your question, please mark your post as Solved.
If you like my response, please give it a Thumbs Up.
mmattar Post Patron
Post Patron

Re: Azure Functions

with azure functions i will be able to interact with forms and controls within the canvas app ?

Dual Super User
Dual Super User

Re: Azure Functions

No, not directly.  You can pass content to the function and receive results back that can then be displayed in the forms.  But the function itself runs external to PowerApps, so think of it like a black box.



-------------------------------------------------------------------------
If I have answered your question, please mark your post as Solved.
If you like my response, please give it a Thumbs Up.

View solution in original post

mogulman Skilled Sharer
Skilled Sharer

Re: Azure Functions

I use Azure Functions (AF) to process a complicated business process.  It involves tracking of numerous documents and approvals/execution.   Overall there are 120+ possible steps.  I have one main table in Azure SQL DB that tracks progress in the flow.  When one step completes the AF sends out an email for the next step.  When a user completes a task they reply "Done" in the email.  The AF reads the email every 5 minutes looking for "Done" emails and if it finds one marks step complete, runs process again looking for next step.  I don't use HTTP so no special licensing.  This allows me keep PowerApp as simple as possible.  All complicated steps are in AF.  For example calculating Business Days is very complicated since I have to account for bank holidays.  Doing this in C# is easy.  This is an example of a step in AF:

 

                    if (!(bool)r["MLFpSent"] && !td.ContainsKey("MLFpSent") &&
                       (((int)r["DBLSource"] != ld["DBLSource,Not Applicable"] && (bool)r["DBLBuyerExecuted"] &&
                       (bool)r["DBLSellerExecuted"]) || 
                       ((int)r["DBLSource"] == ld["DBLSource,Not Applicable"] && dd["MLFDeadline"] >= CalcDate(today, "BD|-1", hd))))
                    {
                        CreateTask("MLFpSent", id, r, out taskId, ld, emd, dd, hd, TESTFLOW, runCnt, loopCnt, ref eMsg);
                        SendEmail(taskId, id, ss1, TESTFLOW, ref eMsg);
                        cnt++;
                    }
mmattar Post Patron
Post Patron

Re: Azure Functions

Would you mind showing me how i can utilize AF with no HTTP requests due to licensing. I want to be able to code my business logic out of the PowerApp, how may i go about setting this up ? 

Dual Super User
Dual Super User

Re: Azure Functions

What he is describing is an Azure Function that just runs in the background processing the data that the PowerApp uses.  There is no way to invoke an Azure Function from a Powerapp other than using HTTPs.  I don't think his scenario matches what you are trying to do.



-------------------------------------------------------------------------
If I have answered your question, please mark your post as Solved.
If you like my response, please give it a Thumbs Up.
mogulman Skilled Sharer
Skilled Sharer

Re: Azure Functions

@Pstork1You are correct process runs async to PowerApps.  Originally I used HTTP to trigger flow from PA but when you made licensing change I modified business process so it wasn't required.  I still use HTTP from Visual Studio to test AZ. 

 

        [FunctionName("TradeFA")]
        public static async Task<IActionResult> Run([HttpTrigger(AuthorizationLevel.Function, "get", "post", Route = null)]HttpRequest req, ILogger log)

Helpful resources

Announcements
MBAS Gallery 2020

MBAS Gallery 2020

Watch Microsoft Business Applications Summit sessions on-demand.

firstImage

New Ranks and Rank Icons released on April 21!

The time has come: We are finally able to share more details on the brand-new ranks coming to the Power Apps Community!

Power Platform 2020 release wave 1 plan

Power Platform 2020 release wave 1 plan

Features releasing from April 2020 through September 2020

Top Solution Authors
Top Kudoed Authors
Users online (6,535)