I am trying to get the usage and rate card information from Microsoft Azure using a java application and I came to understand that I can use the Management certificate to authenticate for making calls to Microsoft Azure.
I got the Management Certificate from the .publishsettings file I got from here
However, in AuthenticationContext
, I don't see any method that utilizes this certificate to get the access token required for making usage and rate API calls.
I tried referring to this answer, but I don't see any clients available for usage and rate card and the answer refers to ManagementClient, which isn't the one for my usecase. I referred to this blog as well, which makes a reference to ClientAssertionCertificate
, which I don't see in the java library for adal.
NB: I am able to make REST API calls to Azure for getting usage and rate card information using the username, password & client ID based authentication mechanism, but I wanted to make use of this management certificate mechanism since the users of my application may not trust this application with their credentials and this certificate based mechanism seems more easier to use from a user-point of view.
Simple answer is you can't use a management certificate to consume Billing API. Billing API are essentially part of newer APIs that make use of Azure AD tokens.
Management certificate can only be used for
Service Management APIs
.As Gaurav said, We just only can call Usage & Rate Card API using Azure Active Directory for authentication. You can use AuthenticationContext to acquire the the
access_token
as following code. You need provideclient ID
andClient Secret
(key
).It seems that we can't use Management certificate mechanism to call Usage & Rate Card API. Because these calling user or the service principal is a member of the
Owner, Contributor or Reader role
in the Azure AD tenant for the requested subscription (see this document). I recommend you refer to this document about how to authenticate Azure Resource Management.