The usual meaning: Function A must call Function B securely, and Function B should accept calls only from Function A's managed identity. Step 1 — Enable managed identity on Function A In the portal: Function A, then Identity, then turn on the system-assigned identity (or attach a user-assigned identity). Note its Object (principal) ID. Step 2 — Protect Function B with Microsoft Entra ID - Enable App Service Authentication ("Easy Auth") on Function B with the Microsoft identity provider, which creates an app registration, or validate JWTs in code. - In Function B's app registration, set an Application ID URI (for example api://func-b) and define an app role such as Orders.Invoke with "Applications" as allowed member types. Step 3 — Grant Function A's identity the app role Managed identities cannot be assigned app roles through the normal portal UI; use Microsoft Graph (PowerShell or the az rest command): New-MgServicePrincipalAppRoleAssignment -ServicePrincipalId <funcA-principal-id> ` -PrincipalId <funcA-principal-id> -ResourceId <funcB-service-principal-id> -AppRoleId <role-id> Step 4 — Call Function B from Function A with a token var credential = new DefaultAzureCredential(); var token = await credential.GetTokenAsync(new TokenRequestContext(["api://func-b/.default"]), ct); http.DefaultRequestHeaders.Authorization = new AuthenticationHeaderValue("Bearer", token.Token); var response = await http.PostAsJsonAsync("https://func-b.azurewebsites.net/api/process", payload, ct); Step 5 — Validate in Function B Easy Auth rejects calls without a valid token for its audience. Additionally check that the token's roles claim contains Orders.Invoke (or that the caller's appid/azp matches Function A), because any identity in the tenant can obtain a token unless "assignment required" is enabled on Function B's enterprise application — turning that on is recommended. Alternatives - If B is triggered by a queue rather than HTTP: give Function A's identity the Service Bus Data Sender role and Function B the Data Receiver role, and communicate through the queue — often a cleaner decoupled design. - Network restrictions (private endpoints or access restrictions) add defence in depth. - Function keys work but are shared secrets; identity-based access is preferred.
Ravindra Wadile · · 0 likes