【问题标题】:Creating resource groups in Azure with c#使用 c# 在 Azure 中创建资源组
【发布时间】:2020-09-30 13:00:55
【问题描述】:

https://docs.microsoft.com/en-us/rest/api/resources/resourcegroups/createorupdate

此调用的身份验证是 Azure Active Directory OAuth2 Flow,但是我无法使用模拟,它将作为函数运行。

要调用图形 api,我会设置这样的东西。

var nvc = new List<KeyValuePair<string, string>>();
nvc.Add(new KeyValuePair<string, string>("client_id", Config.ServicePrincipalId));
nvc.Add(new KeyValuePair<string, string>("scope", "https://graph.microsoft.com/.default"));
nvc.Add(new KeyValuePair<string, string>("client_secret", Config.ServicePrincipalKey));
nvc.Add(new KeyValuePair<string, string>("grant_type", "client_credentials"));

知道我的这个调用的作用域是什么,或者我可以在哪里找到在 Azure 中创建一堆不同事物的作用域的一个很好的参考?

TIA

【问题讨论】:

    标签: c# azure azure-resource-group azure-rest-api


    【解决方案1】:

    首先,你不能用 Graph API 管理 Azure 资源,所以你不需要它。而且您绝对正确地引用了 Azure 资源管理器 Rest API,只需使用客户端凭据 OAuth 流(而不是使用用户模拟)来获取访问令牌,然后您可以使用该令牌调用 API。像这样的:

    Azure Resource Manager API

    或者你可以使用 SDK,这里是 C# 示例:

    Resource Manager SDK

    【讨论】:

    • 这正是我所需要的。非常感谢。
    猜你喜欢
    • 1970-01-01
    • 2020-11-18
    • 2019-01-26
    • 2022-07-24
    • 2021-11-07
    • 1970-01-01
    • 1970-01-01
    • 2018-11-24
    • 2017-12-04
    相关资源
    最近更新 更多