title: How to authenticate to an Azure Function using function auth or Azure AD service principal
body: <p>I have an Azure function which I'm using to fetch data from Azure AD, but I want to limit who can use the Function as it will be using a HTTP trigger so that I will be able to call the function from a Logic App later down the road.
  So as HTTP triggered Azure Functions have a public endpoint, I want to improve security by setting the authorization level to Function, or even more preferable to use an Azure AD service principal (pre-created).
  Upon making this change though I can make the call by putting in the function into the URL.</p>
  
  <p>Base URL:
  <code>https://something.com/api/function_name</code></p>
  
  <p>URL with token:
  <code>https://something.com/api/function_name?code=token_here</code></p>
  
  <p>However, my function expects some input to be given.
  On an anonymous endpoint you'd extend the base URL like so:
  <code>https://something.com/api/function_name/?parameter=value</code></p>
  
  <p>Where parameter is what the code will expect, and the value being passed into the variable in the code.
  Now I'm new to this HTTP endpoint stuff and passing in values via a URL. I understand this gets passed in as JSON (probably)</p>
  
  <p>But I don't understand how I can do both the function authorization as well as passing in the parameter.
  I've tried:</p>
  
  <pre><code>https://something.com/api/function_name/?parameter=value?code=token_here
  https://something.com/api/function_name?code=token_here/?parameter=value
  </code></pre>
  
  <p>Does anyone know how this is supposed to work?</p>
  
  <p>On the flipside, I could also set the <code>Platform Features -&gt; Authentication / Authorization</code> to an Azure AD service principal. But then how do I change the URL to authenticate using the <code>client_id</code> and <code>client_secret</code> of that service principal?
  I'd actually prefer using this method, because then I could implement lifecycle management on the token and rotate it to keep it even more secure.</p>
  
  <p>I've looked here:
  <a href="https://stackoverflow.com/questions/53438932/azure-function-with-azure-ad-authentication-access-using-javascript">Azure function with Azure AD authentication access using JavaScript</a></p>
  
  <p>And most other topics I found on stackoverflow didn't even get close.</p>
  
  <p>PS: This PS doesn't need an answer, but I would appreciate any thought.
  This thing i am concocting is a workflow combined of a (scheduled)logic app that triggers a <code>Get-Function</code>. Where the <code>Get-Function</code> will somehow need to trigger an <code>Update-Function</code>. And I'm making the <code>Get-Function</code> HTTP triggered so that I will also be able to offer it as an API to make this function usable for automation. (to allow secrets to be rotated via API calls without those people requiring Azure AD permissions)
  The update function would then need to rotate secrets on (specific) applications/service principals.
  The Azure Function is based on v2 and uses Powershell Core as language.</p>