When setting scope for your application permissions, mind the different access scenarios: Image source: https://learn.microsoft.com/en-us/azure/active-directory/develop/permissions-consent-overview For more details on delegated vs app-only access see Permissions and consent. To simplify it though, let us say that if you need a user to click consent to a particular resource, then you should go here in the Azure portal: But in the client app and Backend API scenario describe above, you would rather use app-only permissions, and start from Enterprise Applications, where you set Assignment Required to True . If this option is set to yes, then users and other apps or services must first be assigned this application before being able to access it.
<
inbound
>
base
/>
set-backend-service
id
=
"apim-generated-policy"
backend-id
"provisionierungacco"
validate-jwt
header-name
"Authorization"
failed-validation-httpcode
"401"
failed-validation-error-message
"Unauthorized. Invalid token."
openid-config
url
"https://login.microsoftonline.com/0da700fe-a3a7-4aaa-a43f-48a79eefc326/v2.0/.well-known/openid-configuration"
issuers
issuer
>https://login.microsoftonline.com/0da700fe-a3a7-4aaa-a43f-48a79eefc326/v2.0</
</
required-claims
claim
name
"aud"
match
"any"
value
>7e5ff242-8d3a-46a9-8890-45722c2f3d27</
aud
OPTIONAL. Authorized party - the party to which the ID Token was issued. If present, it MUST contain the OAuth 2.0 Client ID of this party. This Claim is only needed when the ID Token has a single audience value and that audience is different than the authorized party. It MAY be included even when the authorized party is the same as the sole audience. The azp value is a case sensitive string containing a StringOrURI value.
I like to check this claim, because it helps to avoid the required assignment issue. Instead of (or additionally to) granting permissions for your client to your backend app you can check in the JWT who sends the request. If needed, several values can be accepted, e.g. in the scenario where 2 or more apps call your Azure Function:
"azp"
>a1888df2-84c2-4379-8d53-7091dd630ca7</
> <value>f1d55d9b-b116-4f54-bc00-164a51e7e47f</value>
>f1d55d9b-b116-4f54-bc00-164a51e7e47f</
>d5dfkae9-4f54-bc00-8d53-164a5130ca7b</
Every Azure Function needs a storage, where you will find 2 tables: