如何以编程方式将应用程序添加到 Azure AD? [英] How to add application to Azure AD programmatically?

查看:34
本文介绍了如何以编程方式将应用程序添加到 Azure AD?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想在 Azure AD 中自动创建我的应用程序并取回 Azure AD 生成的客户端 ID.

I want to automate the creation of my application in Azure AD and get back the client id generated by Azure AD.

是否有 PowerShell commandlet 可以执行此操作?除了管理控制台之外,还有其他方式吗,比如 API 之类的?

Are there PowerShell commandlets to do this? Is there some other means, like an API of doing this besides the management console?

你能给我举个例子吗?

谢谢!

推荐答案

您可以通过多种方式以编程方式在 AAD 中创建应用程序.我将简要介绍两种不同的方法:PowerShell CMDLET 和 Graph API.一般来说,我强烈建议为此使用 Graph API.

There are a number of ways you can create an application in AAD Programatically. I will briefly cover two different ways you can go about doing this: PowerShell CMDLETs and the Graph API. In general, I would strongly reccommend using the Graph API for this.

PowerShell:

有几个不同的模块可以创建 AAD 应用程序/服务主体.如果需要在租户中创建新的应用程序对象,可以使用 Azure PowerShell 进行以下调用:

There are a few different modules running around that have the ability to create AAD Applications/Service Principals. If you need to create a new application object in your tenant, you can use Azure PowerShell to make the following call:

https://msdn.microsoft.com/en-us/library/mt603747.aspx

PS C:> New-AzureRmADApplication -DisplayName "NewApplication" -HomePage "http://www.Contoso.com" -IdentifierUris "http://NewApplication"

如果需要为租户中的应用程序创建服务主体,可以使用 Azure AD PowerShell:

If you need to create a service principal for your application in your tenant you can use Azure AD PowerShell:

https://msdn.microsoft.com/en-us/library/azure/jj151815.aspx

https://msdn.microsoft.com/en-us/library/azure/dn194119.aspx

New-MsolServicePrincipal -ServicePrincipalNames @("MyApp/Contoso.com") -DisplayName "My Application"

图形 API:(推荐)

您还可以通过向我们的 Graph API 发送 POST 来创建应用程序:https://msdn.microsoft.com/Library/Azure/Ad/Graph/api/entity-and-complex-type-reference#ApplicationEntity

You can also create applications by making a POST to our Graph API: https://msdn.microsoft.com/Library/Azure/Ad/Graph/api/entity-and-complex-type-reference#ApplicationEntity

我们提供了一些示例,展示了如何注册和创建应用程序以面向图谱 API,并使用图谱客户端库来帮助您正确调用 API:

We have samples that show how you can register and create an applicatoin to target the Graph API, and use the Graph Client Library to assist you in making the correct calls to the API:

https://github.com/AzureADSamples/WebApp-GraphAPI-DotNet

我希望这会有所帮助!

这篇关于如何以编程方式将应用程序添加到 Azure AD?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆