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

查看:80
本文介绍了如何以编程方式将应用程序添加到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命令集可以执行此操作?除了管理控制台之外,还有其他方法,例如执行此操作的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

我们有一些示例,展示了如何注册和创建针对Graph API的应用程序,并使用Graph Client Library帮助您正确调用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天全站免登陆