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

标签 azure rest active-directory azure-authentication

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

management.azure.com

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

management.core.windows.net

正如这里提到的https://learn.microsoft.com/en-us/rest/api/compute/cloudservices/rest-list-cloud-services

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

其次,如何使用租户/客户端/ key 对 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,但没有成功。我收到以下错误:

enter image description here

最佳答案

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?

如果设置正确,您应该能够获取访问 token ,您可以重试。

enter image description here

关于azure - 使用 Azure 管理 API 进行身份验证,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/57796861/

相关文章:

Android客户端-服务器通信格式

java - 如何验证kerberos token ?

Powershell - 如何将 laSTLogon 转换为天数

python - 无法在 python 中创建 REST 服务

c# - 切换 MVC 用户登录方法 : Forms + AD Account

windows - Windows azure 上的 Drush(或同等产品)用于 drupal 自动化?

azure - azure 上的 webjob 的 Log4net 日志文件为空

azure - 从 Azure 向手机号码发送消息

python - 从 'BlobServiceClient' 导入 'azure.storage.blob' 时出错

java - @RolesAllowed 无法通过 Jersey 解决