web
You’re offline. This is a read only version of the page.
close
Skip to main content

Notifications

Announcements

Community site session details

Community site session details

Session Id :
Power Platform Community / Forums / Power Pages / Invoke Function App fr...
Power Pages
Unanswered

Invoke Function App from Web Form step

(0) ShareShare
ReportReport
Posted on by 26

 I am trying to invoke a function app that I have from Portal Web Form Step on a button click. What would be the best way to achieve this? And Since this is a public facing web page where the web form is hosted how do you protect your function app from being spammed? Many thanks @v-xida-msft 

Categories:
I have the same question (0)
  • ragavanrajan Profile Picture
    7,044 Most Valuable Professional on at

    Hi @Evangelizt , 

     

     I am assuming it is a Azure function app you are referring to. If so 

     

    1. In your Azure function app make sure you have added CORS details of your powerapps portal URL. 

    To call function app from button click: 

     

    1. you can use ajax call in your custom javascript area  

     

    $(document).ready(function () {
     $("#btnExternalCall").click(function (e) {
     
     var serviceURL = "https://NAME_OF_AZURE_FUNCTION_GOES_HERE.azurewebsites.net/api/HttpTriggerCSharp1";
     
     $.ajax({
     url: serviceURL,
     type: "GET",
     xhrFields: {
     withCredentials: true
     },
     crossDomain: true,
     success: function (data) {
     alert("Success: " + data);
     },
     error: function (ex) {
     alert("Failure getting user token");
     }
     });
     });
    });

     

    To avoid spamming: 

     

    In your Azure function app > you can enable the Authentication / Authorization and configure it to either Azure AD or Microsoft 

     

    ragavanrajan_0-1613512970156.png

     

    Hope it helps. 

    ------------

    If you like this post, give a Thumbs up. Where it solved your request, Mark it as a Solution to enable other users find it.

     

  • Evangelizt Profile Picture
    26 on at

    @ragavanrajanawesome stuff. If we enable Authentication / Authorization and configure it to either Azure AD or Microsoft for Function App, then it also prevents the calls being made from a website where users are not anonymous and sign in is not required. How do we get around this problem and still protect function app?

  • Evangelizt Profile Picture
    26 on at

    @ragavanrajanseems like there is no way around this issue! https://stackoverflow.com/questions/43588012/how-to-restrict-apis-to-run-only-in-the-browser) and https://peteskelly.com/secure-functions-aad-2/ I think function app may not be the best choice then if it can be spammed if we allow anonymous requests. What do you think would be best then for reusable functionality that can be used on a button click on web portals and also on dynamics crm forms?

  • OOlashyn Profile Picture
    3,496 Most Valuable Professional on at

    Hi @Evangelizt ,

    If we are talking about securing azure functions there are a lot of options (see official docs here). I would advise you to look into Azure Api Management - it has things like Ip restriction, cors and different authentication policies settings. We are using it to secure our production azure functions.

  • ragavanrajan Profile Picture
    7,044 Most Valuable Professional on at

    Hi @Evangelizt , 

     

    As per @OOlashyn advise there are various options in Azure. For your scenario if you want to allow unauthorized access you have to compromise on few things allow your users to browse through portal but when it comes to function app or any API call the best way is to enable authorization / authentication. If this is not suitable then you can go for ip address restriction / geo restrictions or CORS. 

    May be I am thinking from the layman point of view- without enabling Authorization - Enable captcha before some one press the button for your trigger. In this way you can avoid spam / bots trying to call many times. 

     

    Hope this give you some thoughts to think about it. 

     

    ------------

    If you like this post, give a Thumbs up. Where it solved your request, Mark it as a Solution to enable other users find it.

     

     

Under review

Thank you for your reply! To ensure a great experience for everyone, your content is awaiting approval by our Community Managers. Please check back later.

Helpful resources

Quick Links

Forum hierarchy changes are complete!

In our never-ending quest to improve we are simplifying the forum hierarchy…

Ajay Kumar Gannamaneni – Community Spotlight

We are honored to recognize Ajay Kumar Gannamaneni as our Community Spotlight for December…

Leaderboard > Power Pages

#1
Jerry-IN Profile Picture

Jerry-IN 71

#2
Fubar Profile Picture

Fubar 62 Super User 2025 Season 2

#3
sannavajjala87 Profile Picture

sannavajjala87 31

Last 30 days Overall leaderboard