Best way to secure Azure Function

Copper Contributor

So far, I am able to create azure functions that are accessible anonymously. However I'd like to secure those functions so that they only run from a specific Microsoft Flow. I am reading the docs and watching videos and am kinda lost on how to secure azure functions. What I did was I went to my function app, to Authentication / Authorization, and set the "App Service Authentication" to "On". I chose Log in with Azure Active Directory, and choose Advanced. In the client ID, I pasted the client ID that's added in app registrations. However I left the "issuer url" and "Allowed Token Audiences" empty as the docs aren't really clear on what these values should be. However when trying to execute the Azure function this way, am getting "id_token" is not enabled for your app. So I went to my app registration, and clicked on "Token configuration" from the left menu, I clicked on "Add optional claim" and chose ID and checked all the claims, and hit Add. But that didn't solve the issue. Is there a clear documentation of what should be done exactly? A lot of talking in the docs about theories and how authentication works but nothing practical to actually teach people to secure their functions step by step. 

1 Reply

@bri992 so this documentation should help you hopefully https://docs.microsoft.com/en-us/azure/app-service/configure-authentication-provider-aad . 

I followed the doc and was working as expected on a function app .

 

 

Anyway , more generally speaking , you could also put in place access restrictions .

Go on network blade , then scroll down and you will find access restrictions , within it you can specify the subnets and/or source ip ranges that you want to allow/deny to run your functions.