[英]Updating Azure AD Application via C#
I have an already existing Azure AD Application.我有一个已经存在的 Azure AD 应用程序。 I would like to be able to update it via C# code, just like I do via the Azure CLI.
我希望能够通过 C# 代码对其进行更新,就像我通过 Azure CLI 一样。 All I need is to add two new reply URLs to the application.
我只需要向应用程序添加两个新的回复 URL。
With the Azure CLI I use:使用 Azure CLI 我使用:
az ad app update --id <my_app_id> --reply-urls <url_1> <url_2>
How can I get the equivalent but within C# code?如何在 C# 代码中获得等效项? I've found that the Azure SDK does not provide such a functionality, or at least I couldn't find it.
我发现 Azure SDK 没有提供这样的功能,或者至少我找不到。 I have a Service Principal which I want this operation done through.
我有一个服务主体,我希望通过它完成此操作。
Here's one solution I came up with, turns out you can use System.Diagnostics.Process
to invoke CMD.exe via C# and use the cli through there:这是我想出的一个解决方案,原来您可以使用
System.Diagnostics.Process
通过 C# 调用 CMD.exe 并通过那里使用 cli:
string strCmdText;
strCmdText = "/C az login --service-principal -u <client_id> -p <client_secret> --tenant <tenant_id>";
System.Diagnostics.Process.Start("CMD.exe", strCmdText);
System.Diagnostics.Process.Start("CMD.exe", "/C az ad app update --id <app_id> --reply-urls https://testfromcsharp.com/");
and it worked.它奏效了。
You can use this graph api to update your azure ad appliction.您可以使用此图 api来更新您的 azure 广告应用程序。 And pls note that the
application id
used in the request url is the object id of the azure ad application but not the application id.请注意,请求 url 中使用的
application id
是 azure 广告应用的 object id,而不是应用 id。
You can first call Get https://graph.microsoft.com/v1.0/applications/object_id_here
first to get the current web
claim of this app, that should be similar to您可以先调用
Get https://graph.microsoft.com/v1.0/applications/object_id_here
以获取此应用程序的当前web
声明,应该类似于
{
"web": {
"homePageUrl": null,
"logoutUrl": null,
"redirectUris": [
"http://localhost:3000"
],
"implicitGrantSettings": {
"enableAccessTokenIssuance": true,
"enableIdTokenIssuance": true
}
}
}
Then you modify the redirectUris
property with all the urls you wanna set to the application, pls note this update will cover all the original redirect urls.然后你用你想设置给应用程序的所有 url 修改
redirectUris
属性,请注意这个更新将覆盖所有原始重定向 url。 Then copy the json content and call the PATCH
request to update the api.然后复制json内容并调用
PATCH
请求更新api。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.