使用 Azure 管理进行身份验证 API

Authentication with Azure Management API

我们使用 Azure API 进行各种操作已有一段时间了。例如,这是我们使用 https://docs.microsoft.com/en-us/rest/api/servicebus/namespaces/createorupdate 的 API 之一,如文档中所述,我们向其发送请求的 URL 是:

management.azure.com

最近我们需要通过 API 开始针对我们的云服务执行操作。我注意到 URL 与我们之前使用的不同 --

management.core.windows.net

如此处所述https://docs.microsoft.com/en-us/rest/api/compute/cloudservices/rest-list-cloud-services

首先,有人可以向我解释一下这两者之间的区别吗?

其次,我如何使用 tenant/client/secret 密钥对 management.core.windows.net 进行身份验证?

下面是我用来验证第一个 URL 的代码。

var context = new AuthenticationContext($"https://login.microsoftonline.com/{Constants.AZURE_TENANT_ID}");
var result = context.AcquireTokenAsync(
                        "https://management.azure.com/",
                        new ClientCredential(Constants.AZURE_MANAGEMENT_API_CLIENT, Constants.AZURE_MANAGEMENT_API_SECRET)
                    ).GetAwaiter().GetResult();
return result.AccessToken;

我试图简单地替换 URL 但那没有用。我收到以下错误:

could someone explain me the differences between those two?

Azure 资源管理器提供程序 API 使用 https://management.azure.com/,Azure 经典部署模型使用 https://management.core.windows.net/

how can I authenticate against the management.core.windows.net using tenant/client/secret keys?

如果设置正确,应该可以获取到access token,您可以重试。