简体   繁体   English

从Web应用程序访问Azure Management API

[英]Azure Management API access from a web app

Is it possible to gain access to the Azure Management APIs through the client ID and secret for a web app? 是否可以通过Web应用程序的客户端ID和密码访问Azure Management API?

I have a web app through which i want to be able to manage Azure. 我有一个网络应用程序,我希望能够管理Azure。 I want to do this using the credentials of the application itself so that the current user does not have to be an azure administrator. 我想使用应用程序本身的凭据来执行此操作,以便当前用户不必是azure管理员。

I have given the web app the necessary role on my subscriptions and obtained the access token through the client credentials grant flow in AD but i still get an unauthorized. 我已经为我的订阅提供了必要的Web应用程序角色,并通过AD中的客户端凭据授权流程获取了访问令牌,但我仍然未经授权。

This is probably because the azure management API has no permission set other than delegated - the access works fine if i use the authorization code grant flow for the logged in user, but thats not what i want. 这可能是因为azure管理API没有委托以外的权限集 - 如果我为登录用户使用授权代码授权流程,则访问工作正常,但这不是我想要的。

So to reiterate, if, given a web app that has RBAC to a subscription and is able to obtain an access token from AD, is there any way, without an interactive user, that the web app is able to use the management API?? 重申一下,如果给定一个具有RBAC订阅并且能够从AD获取访问令牌的Web应用程序,是否有任何方式,没有交互式用户,Web应用程序能够使用管理API?

Yes, you can obtain a token from AAD for a service principal and use that to manage resources as long as that service principal has all the access you need. 是的,您可以从AAD获取服务主体的令牌,并使用该令牌管理资源,只要该服务主体具有您需要的所有访问权限。

Make sure the token you get has a resource/audience of " https://management.azure.com " and is for the tenantId that the subscription is associated with. 确保您获得的令牌具有“ https://management.azure.com ”的资源/受众,并且适用于与订阅相关联的tenantId。

You can also see this article from Brady Gaster that explains how to use Azure AD applications to manage Azure Services from an external app : http://www.bradygaster.com/post/using-windows-azure-active-directory-to-authenticate-the-management-libraries 您还可以在Brady Gaster中看到这篇文章,其中介绍了如何使用Azure AD应用程序从外部应用程序管理Azure服务: http//www.bradygaster.com/post/using-windows-azure-active-directory-to-验证-的管理,图书馆

EDIT : Azure AD supports Service to Service calls using OAuth 2.0 client credentials: https://msdn.microsoft.com/en-us/library/azure/dn645543.aspx 编辑: Azure AD使用OAuth 2.0客户端凭据支持服务到服务调用: https//msdn.microsoft.com/en-us/library/azure/dn645543.aspx

Hope this helps, 希望这可以帮助,

Julien 朱利安

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM