I am building a multi tenant application and it has to provision few azure resources(resource group, even hub, storage hub etc) in customer(say target) tenant during a account setup process .
I followed the azure doc to register an app . I can see the service principal created in target tenant under "Enterprise Applications" and this app has delegated type "azure service management API" permission .
Question:
I wanted to write an function app in source tenant(which is my tenant) in PYTHON which can fetch subscriptions/provision resources in target account . I tried azure.identity.ClientSecretCredential
in function something like example to fetch list of subscriptions , it retuned Zero subscriptions . I think ClientSecretCredential doesn't fit for delegated type permission, until i add explicit role-assignment to the service principal , it wont have authorization . post says the same .
Is it must to use AuthorizationCodeCredential
, but it requires auth_code
which needs user interaction . So, need to develop a web page which prompts for user consent and redirect the auth_code to this function using this function as redirect URI ?
Is there any other way ? Any code reference would help .
Also, what is difference between MSAL
and azure.identity
package classes . Any documentation on this regard , when to use which API, I have seen various examples using either of them .
azure.identity.ClientSecretCredential
. What is the issue now? Why do you have to useAuthorizationCodeCredential
? – Allen WuClientSecretCredential
. Basically I want to automate the customer account setup process like creating some azure resources etc . – PintuUsernamePasswordCredential
to include the user token and delegated permission to list the information you want. But in this case the user also need to has access to the subscriptions/provision resources in target account. In another word, you also need to assign the corresponding RBAC role to the user (Corresponding to the service principal ofClientSecretCredential
). Besides, UsernamePasswordCredential is not recommended by Microsoft. – Allen Wu