Forum Discussion
Azure Cost Management API
Does anyone know how to get an access token to access that endpoint and those who are also on the page?
https://docs.microsoft.com/en-us/azure/cost-management/get-started-partners
Yes it is possible, jroberts1010. Azure SDK for .NET (Billing + Consumption)
- drmiruCopper Contributor
Try this:
$azContext = Get-AzContext
$azProfile = [Microsoft.Azure.Commands.Common.Authentication.Abstractions.AzureRmProfileProvider]::Instance.Profile
$profileClient = New-Object -TypeName Microsoft.Azure.Commands.ResourceManager.Common.RMProfileClient -ArgumentList ($azProfile)
$token = $profileClient.AcquireAccessToken($azContext.Subscription.TenantId)
$authHeader = @{
'Content-Type'='application/json'
'Authorization'='Bearer ' + $token.AccessToken
}
$response = Invoke-RestMethod -Uri $url -Method Get -Headers $authHeader
- jroberts1010Copper Contributor
yes, i understand but, i need to call that endpoint on a controller from an application in c#....is that posible?
- hspintoMicrosoft
Yes it is possible, jroberts1010. Azure SDK for .NET (Billing + Consumption)