我使用下面的代码,试图在Azure中的Active Directory编程方式注册的应用程序:如何使用流畅API创建Azure AD应用程序?
var application = azure.ActiveDirectoryApplications.Define(applicationName)
.WithSignOnUrl(url)
.WithIdentifierUrl(url)
.WithAvailableToOtherTenants(false)
.DefinePasswordCredential(id)
.WithPasswordValue(secret)
.Attach()
.Create();
凡azure
是Microsoft.Azure.Management.Fluent.Azure
一个实例。
当我运行上述操作来创建Azure Active Directory应用程序时,将引发Microsoft.Azure.Management.Fluent.Azure
异常,并显示消息Operation returned an invalid status code 'Forbidden'
。其他Azure资源(如资源组和应用服务)的创建工作得很好。
看着异常的详细信息,我可以看到的请求作出了以下端点:
https://graph.windows.net/{myTenantId}/applications?api-version=1.6
以下是在响应正文:
{"odata.error":{"code":"Authorization_RequestDenied","message":{"lang":"en","value":"Insufficient privileges to complete the operation."}}}
由于机构说“没有足够的权限来完成操作”,它似乎是一个简单的权限问题,但我已授予Microsoft.Azure.ActiveDirectory API的以下权限(以全局管理员身份登录时)是正在运行的代码的应用程序:
- 访问目录作为登录用户
- 读写的目录数据
难道这些权限还不够吗?我错过了什么?正如我所说的,使用流畅的API创建其他资源工作得很好。
非常感谢您在构建您所示的IAzure客户端时能够正常工作。以前,我只在应用程序中使用clientId/clientSecret(在Portal中使用手动授予的权限),这也许是问题所在。 – tremolo