Connect to and consume Azure services and third-party services →mediumMultiple ChoiceObjective-mapped
Secure OAuth 2.0 Client Credentials in Azure Logic Apps with Key Vault
You are building an Azure Logic App that needs to call an external HTTP API secured with OAuth 2.0 Client Credentials flow. The client ID and client secret are stored in Azure Key Vault. You need to obtain an access token and include it in the Authorization header of each request. Which combination of actions should you use within the Logic App?
Quick Answer
The correct answer is to use an HTTP action with the OAuth 2.0 authentication type and set the client secret parameter to a secure reference to the Key Vault secret. This works because the Logic App’s built-in HTTP action natively implements the OAuth 2.0 Client Credentials flow, meaning it handles the token endpoint call and automatically injects the access token into the Authorization header. By using a secure reference like `@Microsoft.KeyVault(SecretUri=...)` for the client secret, you keep credentials out of the workflow definition and rely on the Logic Apps runtime to fetch the secret from Key Vault at execution time. On the AZ-204 exam, this scenario tests your understanding of managed identities, Key Vault integration, and the difference between native OAuth support versus custom token management. A common trap is trying to manually call the token endpoint with a separate HTTP action, which adds unnecessary complexity and security risk. Memory tip: “Native OAuth + Key Vault reference = zero custom code for token management.”
⚠ Common exam trap
The trap here is that candidates often overcomplicate the solution by manually implementing token acquisition (Option B) or misapplying managed identity (Option C) or prebuilt connectors (Option D), not realizing that the built-in HTTP action's OAuth 2.0 authentication type directly supports the Client Credentials flow with Key Vault integration.
Answer choices
Why each option matters
Answer the question above first, then reveal the full breakdown to understand why each option is right or wrong.
Correct answer & explanation
✓
Use an HTTP action with the OAuth 2.0 authentication type. Set the client secret parameter to a secure reference to the Key Vault secret.
The HTTP action in Azure Logic Apps natively supports the OAuth 2.0 authentication type, which can directly handle the Client Credentials flow. By setting the client secret parameter to a secure reference (e.g., `@Microsoft.KeyVault(SecretUri=...)`) pointing to the secret stored in Azure Key Vault, you avoid exposing credentials in the workflow definition. The Logic Apps runtime automatically retrieves the secret from Key Vault, obtains an access token from the token endpoint, and includes it in the Authorization header of each request without requiring custom token management.
Answer analysis
Option-by-option breakdown
For each option: why learners choose it and why it is or isn't the right answer here.
- ✓
Use an HTTP action with the OAuth 2.0 authentication type. Set the client secret parameter to a secure reference to the Key Vault secret.
Why this is correct
Logic Apps' built-in OAuth 2.0 authentication for HTTP actions handles token acquisition and renewal. The secret can be securely referenced from Key Vault via a parameter.
- ✗
Use two HTTP actions: first, call the token endpoint with credentials to get a token, then use the token in the second action. Store credentials in a string variable.
Why it's wrong here
Using two HTTP actions is the correct *flow* for OAuth 2.0 Client Credentials, making this option tempting as it outlines the necessary steps. However, storing the client ID and secret directly in a string variable within the Logic App is insecure and contradicts the requirement to retrieve these sensitive credentials from Azure Key Vault. This approach bypasses the secure credential management that Key Vault provides. It would be suitable only if security was not a primary concern or if the credentials were not mandated to be sourced from Key Vault.
- ✗
Use the HTTP action with managed identity authentication.
Why it's wrong here
Managed identity is used to authenticate to Microsoft Entra ID resources, not to third-party APIs that require OAuth 2.0 Client Credentials with a specific client ID and secret.
- ✗
Use the 'Invoke an Microsoft Entra ID protected API' connector with the client credentials grant type.
Why it's wrong here
This connector is designed for APIs protected by Microsoft Entra ID. If the external API is not registered in the same Microsoft Entra ID tenant or does not use Microsoft Entra ID, this connector may not work.
Go deeper
Related to this question
About these practice questions
Courseiva writes every AZ-204 question from scratch — 881 in total, each with an explanation and a wrong-answer breakdown. None are copied from real exams or dumps. Learn why practice questions differ from exam dumps →
Same concept, more angles
4 more ways this is tested on AZ-204
These questions test the same concept from different angles. Work through them to make sure you can recognise it however the exam phrases it.
Variation 1. You are building an Azure Logic App that must call an external API secured with OAuth 2.0 Client Credentials flow. The external API is registered in a different Microsoft Entra ID tenant. You need to obtain an access token and add it to the request headers. Which action and authentication configuration should you use?
medium- A.Use the HTTP action with Managed Identity authentication.
- B.Use the HTTP + Swagger connector to import the API definition.
- ✓ C.Use the HTTP action with Active Directory OAuth authentication, providing the tenant ID, client ID, and client secret.
- D.Use the Azure Key Vault - Get secret action to retrieve a token.
Why C: The HTTP action's Active Directory OAuth authentication type directly supports the OAuth 2.0 Client Credentials flow for cross-tenant scenarios. By providing the tenant ID, client ID, and client secret, the Logic App runtime can obtain an access token from the external tenant's token endpoint and automatically inject it into the Authorization header as a Bearer token. This is the only built-in authentication option in the HTTP action that handles the client credentials grant without custom code.
Variation 2. You are building an Azure Logic App that needs to call an external API secured with OAuth 2.0 client credentials flow. You have registered an application in Microsoft Entra ID with client ID 'myClientId' and client secret stored in Key Vault. Which action should you use to authenticate?
medium- ✓ A.HTTP action with Active Directory OAuth authentication
- B.HTTP action with Managed Identity authentication
- C.Invoke the API through Azure API Management
- D.Use the Microsoft Entra ID OAuth 2.0 connector
Why A: The HTTP action in Azure Logic Apps supports an 'Active Directory OAuth' authentication type that directly implements the OAuth 2.0 client credentials flow. By providing the tenant ID, client ID, and referencing the client secret from Key Vault (via a secure parameter or connection reference), the Logic App can obtain an access token from Microsoft Entra ID and authenticate to the external API without custom code.
Variation 3. You are building an Azure Logic App that must call a third-party REST API secured with OAuth 2.0 Client Credentials flow. The client ID and client secret are stored in Azure Key Vault. You need to securely obtain an access token and include it in requests to the API. Which approach should you use in the Logic App?
medium- A.Use the HTTP action with 'Active Directory OAuth' authentication and hardcode the client secret in the connection parameters.
- B.Create an Azure API connection (custom connector) with the OAuth 2.0 settings and store the secret in the connector's definition.
- ✓ C.Enable a system-assigned managed identity for the Logic App, grant it access to Key Vault, use the 'Get secret' action to retrieve the client secret into a variable, then use the HTTP action with 'Active Directory OAuth' authentication referencing that variable for the secret.
- D.Store the client secret in an Azure App Service application setting and reference it in the Logic App via a connector.
Why C: It securely retrieves the client secret from Azure Key Vault at runtime using a managed identity, avoiding any hardcoded secrets. The Logic App's system-assigned managed identity is granted access to Key Vault, then the 'Get secret' action fetches the secret into a variable, which is passed to the HTTP action's 'Active Directory OAuth' authentication. This approach follows the principle of least privilege and eliminates secret exposure in connection definitions or source code.
Variation 4. You are building an Azure Logic App that calls an external REST API secured with the OAuth 2.0 client credentials flow. You have registered an app in Microsoft Entra ID with client ID and client secret stored in Azure Key Vault. The Logic App uses a system-assigned managed identity with Get permission on the secret. Which action should you use in the Logic App designer to authenticate to the API?
medium- ✓ A.HTTP action with 'Active Directory OAuth' authentication type, referencing the client ID and client secret
- B.HTTP action with 'Managed Identity' authentication type
- C.Invoke an API with OAuth predefined connector
- D.HTTP action with 'Basic' authentication and pass the secret as password
Why A: The OAuth 2.0 client credentials flow requires a client ID and client secret to obtain an access token from Microsoft Entra ID. The HTTP action's 'Active Directory OAuth' authentication type directly supports this flow, allowing you to reference the client ID and the client secret stored in Azure Key Vault. The Logic App's system-assigned managed identity has Get permission on the secret, enabling it to retrieve the secret at runtime without exposing it in the workflow definition.
JA
Written by Johnson Ajibi, MSc IT Security
Senior Network & Security Engineer · founder of Courseiva
This AZ-204 practice question is part of Courseiva's free Microsoft certification practice question bank. Courseiva provides original exam-style practice questions with explanations, topic-based practice, mock exams, readiness tracking, and study analytics to help learners prepare for the AZ-204 exam.