AKS icon indicating copy to clipboard operation
AKS copied to clipboard

AKS Cost Analysis - API access for users

Open kajetanm-dnv opened this issue 1 year ago • 8 comments

Today it is possible to obtain data from the AKS Cost Analysis add-on only through the Azure Portal or downloaded CSV files.

Using az CLI credentials to create an API call throws an error: {"error":{"code":"401","message":"Request blocked. Your request to this resource has been denied. Please access this resource from the Cost Analysis blade on the Azure Portal."}}

To automate add-on usage and obtain data from tables, it should be possible to provide users with access to use API.

kajetanm-dnv avatar Jul 17 '24 08:07 kajetanm-dnv

We also need access to the API.

eikeatb avatar Aug 26 '24 08:08 eikeatb

I asked this as well to MSFT Support, here's the response we got:

I understand that you are encountering an error when attempting to query the Azure AKS Cost API, specifically the following message:

{'error':{'code':'401','message':'Request blocked. Your request to this resource has been denied. Please access this resource from the Cost Analysis blade on the Azure Portal.'}}

This issue arises because direct API access to cost data for AKS is currently restricted, and Azure recommends viewing cost data via the Cost Analysis blade in the Azure Portal. Unfortunately, querying cost data at the namespace level via API is not natively supported at this time, which I understand is important for your tracking and reporting needs.

As per if there's an ETA for release:

At this time, there is no confirmed ETA from Microsoft regarding when native support for querying AKS costs at the namespace level via API will be available. However, the Azure Product Group is actively working on improving cost management capabilities for AKS, including more granular reporting.

Forcebyte avatar Oct 02 '24 01:10 Forcebyte

I have tested with api-version=2023-04-01-preview , it works good with my access token but i get below error while using service principal which has same rights as me.

{ "error": { "code": "401", "message": "Request blocked. Your request to this resource has been denied. Please access this resource from the Cost Analysis blade on the Azure Portal." } } Image

venkatest avatar Oct 08 '24 07:10 venkatest

I have openend a ticket in ms community : https://learn.microsoft.com/en-us/answers/questions/2099742/not-able-to-get-cluster-and-namespace-cost-using-m?comment=question

venkatest avatar Oct 30 '24 09:10 venkatest

+1 that this would be a very welcome feature!

pltzr avatar Mar 13 '25 20:03 pltzr

why is this not available? 🤦

digitalbanana avatar Jul 11 '25 10:07 digitalbanana

can you please prioritize this ticket

ykiran2023 avatar Aug 24 '25 23:08 ykiran2023

@aritraghosh Could you consider this feature to add on AKS roadmap?

slawekww avatar Sep 11 '25 11:09 slawekww

@aritraghosh Could you consider this feature to add on AKS roadmap?

I see related task regarding automated exporting and api access on roadmap: https://github.com/Azure/AKS/issues/4336

kajetanm-dnv avatar Sep 11 '25 11:09 kajetanm-dnv