Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Authentication with Azure Management API

We have been using Azure API for some time for various operations. For example this is one of the APIs we use https://learn.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://learn.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:

enter image description here

like image 231
scorpion5211 Avatar asked Mar 31 '26 01:03

scorpion5211


1 Answers

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.

enter image description here

like image 193
Tony Ju Avatar answered Apr 02 '26 21:04

Tony Ju