title: Multiple Authentication policies in Azure APIM
body: <p>I have two scenarios where in first client will call the APIM with bearer token and other one is Function App will call our APIM with Managed identity. I have the code which will validate the jwt. but I want to know how can I skip the other one if either one is available(e.g I want to skip the jwt validation if its get called with managed Identity). From <a href="https://docs.microsoft.com/en-us/azure/api-management/api-management-authentication-policies#ManagedIdentity" rel="nofollow noreferrer">examples</a> I can see I can do a choose and when but not sure what will be the headers for the managed identity. Here is what I am thinking I should be updating.</p>
  <pre><code>&lt;choose&gt;
      &lt;when condition=&quot;@(context.Request.Headers.GetValueOrDefault(&quot;Authorization&quot;,&quot;&quot;) != &quot;&quot;)&quot;&gt;
           &lt;validate-jwt header-name=&quot;Authorization&quot; failed-validation-httpcode=&quot;401&quot; failed-validation-error-message=&quot;Invalid or Expired token&quot; require-expiration-time=&quot;true&quot; require-signed-tokens=&quot;true&quot;&gt;
              &lt;openid-config url=&quot;.well-known/openid-configuration&quot; /&gt;
              &lt;audiences&gt;
                  &lt;audience&gt;audience&lt;/audience&gt;
              &lt;/audiences&gt;
              &lt;issuers&gt;
                  &lt;issuer&gt;issuer&lt;/issuer&gt;
              &lt;/issuers&gt;
          &lt;/validate-jwt&gt;
      &lt;/when&gt;
  &lt;when condition=&quot;to validate managed identity&quot;&gt;
  &lt;authentication-managed-identity resource=&quot;resource&quot; client-id=&quot;clientid of user-assigned identity&quot; output-token-variable-name=&quot;token-variable&quot; ignore-error=&quot;true|false&quot;/&gt;
  &lt;/when&gt;
  &lt;/choose&gt;
  </code></pre>