Adventures with Power Apps: Create a Custom Connector for an API Hosted in an Azure Function Secured with Azure AD

I have an Azure Function that is secured with an identity provider that authenticates against Active Directory.

I configured the identity provider using the app registration I created in a previous article, see Adventures with Power Apps: Create a Custom Connector for an API Hosted in Azure APIM Secured with Azure AD – Matt Ruma.

Now my Azure Function is secured with Active Directory. If I try to run it from Postman or from the Test/Run in the Azure Portal, I receive a 401 status code.

I created two HttpTrigger functions in my Azure Function using the Azure Functions OpenAPI Extension, one called Function, that returns a list of people, and another called Function2, that returns the details of a person.

Prior to enabling the identity provider, I downloaded a copy of the swagger.json for the Azure Function from https://MY_FUNCTION_NAME.azurewebsites.net/api/swagger.json.

Now to create a Custom Connector for this Azure Function in the Power Platform.

I navigated to https://make.powerapps.com.

From the Power Apps menu blade, I selected Dataverse and then selected Custom Connectors.

I then clicked New custom connector and selected Import from OpenAPI file.

I provided a Name and selected a file to Import, then clicked Continue.

I configured the security, using OAuth, just like I did in Adventures with Power Apps: Create a Custom Connector for an API Hosted in Azure APIM Secured with Azure AD – Matt Ruma.

I then clicked Update connector.

I am using Function security in my Azure Function, so I will need to create a new policy to pass the App Key for the function.

From the Definitions tab, I clicked New policy.

Set Template to Set HTTP header.

Set Header name to x-functions-key.

Set Header value to the Azure Function App Key.

I clicked Update connector.

I know want to test my customer connector.

I selected the Test tab and clicked New connection, which prompted me to authenticate to Azure Active Directory.

Once the connection was created, I then clicked on Test Operation.

Everything worked!

Just to recap, in this article I created an Azure Function, secured it with an Azure Active Directory identity provider and created a Customer Connector in Power Platform to access the Azure Function.

As always, please share your thoughts!


Discover more from Matt Ruma

Subscribe to get the latest posts to your email.

Leave a Reply

Your email address will not be published. Required fields are marked *