Reputation: 2042
I am trying to get the access token for the Azure function app. I have enabled managed identity for the function App (system assigned)
, but while fetching the token using the Azure.Identity
nuget package
var tokenCredential = new DefaultAzureCredential();
var accessToken = await tokenCredential.GetTokenAsync(
new TokenRequestContext(scopes: new string[] { "https://xxx.azure-api.net/" + "/.default" }) { }
);
I am getting the below error.
The resource principal named 'app-name.azure-api.net' was not found in the tenant "tenant-name"
but when I run az cli
to check the subscription details, the subscription indeed part of the tenant only.
Upvotes: 5
Views: 28987
Reputation: 937
Unfortunately, the error message is not really helpful. But adding a scope to the app registration solved the problem for me:
api_access
as this was where this error occurred.In my case I then got an API URI (like api://client-id/scope_name) which I used in my Angular app. Error message was gone.
Also, make sure that in the Enterprise Application you have created, under Manage => Properties, "Assignment required" and "Visible to users" is turned on.
Upvotes: 3
Reputation: 2042
Here is what I have finally done.
Upvotes: 3
Reputation: 716
You need to register the application in azure ad and enable the access token. Once that is done the you need to provide RBAC access to your xxx.azurewebsites.net
Follow this article for the step by step documentation Microsoft Document Reference
Upvotes: 0