Thank your for posting your query on Microsoft Q&A. Error 401 could be caused due to permissions issue. Kindly validate the following:
- Granting the Application access to manage resources in your Azure Subscription
Firstly, specify a Role which grants the appropriate permissions needed for the Service Principal (for example,
Contributor
will grant Read/Write on all resources in the Subscription). There's more information about the built in roles available here. Secondly, search for and select the name of the Service Principal created in Azure Active Directory to assign it this role - then press Save. - If required by API, your SPN application must have API permissions to manage the application.
- Multi-tenant cross tenant applications can be declared as such at the app registration, but in the code you would have to provide a tenanted authority.
Please do let me know if you have any queries in the comments section.
Thanks,
Akshay Kaushik
Please "Accept the answer" (Yes/No), and share your feedback if the suggestion works as per your business need. This will help us and others in the community as well.