使用Azure管理API进行身份验证 [英] Authentication with Azure Management API

查看:115
本文介绍了使用Azure管理API进行身份验证的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

一段时间以来,我们一直在使用Azure API进行各种操作。例如,这是我们使用的API之一


We have been using Azure API for some time for various operations. For example this is one of the APIs we use https://docs.microsoft.com/en-us/rest/api/servicebus/namespaces/createorupdate and as mentioned in the docs the URL that we send request to is:

management.azure.com

Recently we have had the need to start performing against our Cloud Services via API. I noticed that the URL was different then what we have been using before --

management.core.windows.net

as mentioned here https://docs.microsoft.com/en-us/rest/api/compute/cloudservices/rest-list-cloud-services

Firstly, could someone explain me the differences between those two?

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

Here is the following code I have been using to auth with the first 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;

I tried to simply replace the URL but that did not work. I got the following error:

解决方案

could someone explain me the differences between those two?

Azure Resource Manager provider APIs use https://management.azure.com/, and Azure classic deployment model uses https://management.core.windows.net/

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

You should be able to get the access token if the settings are correct, you can try again.

这篇关于使用Azure管理API进行身份验证的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆