Introduction

During a recent project, I created a Logic Apps Custom Connector secured with an API key. The API key, using the parameter name “Authorization,” could not be updated via a policy, unlike in a Custom Connector within Power Automate.

Policies in Logic Apps are used to modify the behavior of actions and triggers through configuration, allowing developers to apply one or more predefined templates to customize their workflows.

Problem

In a Logic Apps Custom Connector, policies cannot be used to modify the headers of an action. When attempting to add an “Authorization” header to an action, the following error occurs:

‘Authorization’ header is not allowed. Use ‘API Key’ authentication type in the Security tab to set this header.

This limitation prevents direct updates to the API key using standard policy configurations.

Solution

How can an API key be updated with an “Authorization” header dynamically during a Logic Apps execution? In the following sections, we will explore a viable approach to overcoming this limitation.

Step 1: Create a New Logic App

  1. Open Azure Portal and navigate to Logic Apps.
  2. Click + Add to create a new Logic App.
  3. Select the Consumption or Standard plan, then click Create.

Step 2: Add an HTTP Action

  1. Open the Logic App Designer and add a Recurrence Trigger to schedule periodic updates.
  2. Add an HTTP Action and configure it as follows:
    • Method: PUT
    • URI: https://management.azure.com/subscriptions/{subscription-id}/resourceGroups/{resource-group}/providers/Microsoft.Web/connections/{connection-name}?api-version=2016-06-01
    • Body:
      { "properties": { "parameterValues": { "api_key": "{new-access-token}" } } }

Step 3: Authenticate with Managed Identity

  1. Assign a Managed Identity to the Logic App.
  2. Grant it Contributor or API Connection Owner role in Azure IAM.
  3. Modify the HTTP Action to use Managed Identity Authentication instead of manually passing tokens.

Automating API Connection updates in Azure Logic Apps enhances security and reduces manual intervention. By leveraging Logic Apps with Azure Resource Manager APIs, you can seamlessly refresh authentication tokens and maintain workflow reliability.

0 CommentsClose Comments

Leave a comment

Newsletter Subscribe

Get the Latest Posts & Articles in Your Email

We Promise Not to Send Spam:)