Skip to main content
cancel
Showing results for 
Search instead for 
Did you mean: 

Don't miss out! 2025 Microsoft Fabric Community Conference, March 31 - April 2, Las Vegas, Nevada. Use code MSCUST for a $150 discount. Prices go up February 11th. Register now.

Reply
dgwilson
Resolver III
Resolver III

AzureCostManagement - authentication

As a "Partner" my organisation has hundreds of accounts that we support/transact for in Azure. [I might have these terms wrong].

 

I want to connect using the AzureCostManagement connector to download the UsageDetails and BalanceSummary.

I already have the list of "Accounts", that's got 354 rows in it.

The M code below is working and does return the details expected (balance summary in this case). And yes - the columns need to be expanded... I've removed that code for easier reading.

 

The challenge here is that that for EACH account I need to authenticate with the same details in every call. Which is why the current code limits the number of rows to three for testing. This is not a sustainable solution if I need to authenticate hundreds of times.

 

Is this a connector issue, or can I get the authentication details retained/reused.

 

Settings:Privacy in the report is set to "Ignore the Privacy Levels ..."

When I look at the report Data Source settings, I do see Azure Cost Management there ONCE and it's Privacy is set to Organizational.

 

let
GetBalanceSummary = (accountName as text, sourceTable as table) as table =>
let
summary = AzureCostManagement.Tables("Enrollment Number", accountName, CostManagement_Months, [startDate=null, endDate=null]),
balanceSummary = summary{[Key="balancesummary"]}[Data]
in
balanceSummary,

Source = Accounts,
activeExtendedAccounts = Table.SelectRows(Source, each [AccountStatus] = "Active" or [AccountStatus] = "Extended"),
firstTwoActiveExtendedAccounts = Table.FirstN(activeExtendedAccounts, 3), // Limit rows for testing
downloadedReports = Table.AddColumn(firstTwoActiveExtendedAccounts, "BalanceSummary", each GetBalanceSummary([Name], activeExtendedAccounts))
in
downloadedReports

 

A good way to kick off 2024. M & Authentication!  🙂

2 REPLIES 2
v-xinruzhu-msft
Community Support
Community Support

Hi @dgwilson 

You can refer to the follwing link about the authentication.  it describe to use to get the authentication by api

Handling authentication for Power Query connectors - Power Query | Microsoft Learn

 

Best Regards!

Yolo Zhu

If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

Hi @v-xinruzhu-msft 

Thank you for the link to the Power Query Authentication documentation. That's really good to know and could be really useful.

I can't determine how to integrate this with the existing M code and in particular the AzureCostManagement connector. 

I would guess that I need to capture the authentication details that the connector is/has used, and then pass those details to each subsequent call. If that's a function of the AzureCostManagement connector then I'd need to see an example or some documentation on the connector that says how this works.

https://learn.microsoft.com/en-us/power-query/connectors/azure-cost-management 

The connector documentation does cover authentication a little bit. And perhaps the issue is with the way I'm making the function call?

 

The Azure Cost Management connector uses OAuth 2.0 for authentication with Azure and identifies users who 
are going to use the connector. Tokens generated in this process are valid for a specific period. Power BI
preserves the token for the next login. OAuth 2.0, is a standard for the process that goes on behind the
scenes to ensure the secure handling of these permissions.

Helpful resources

Announcements
Las Vegas 2025

Join us at the Microsoft Fabric Community Conference

March 31 - April 2, 2025, in Las Vegas, Nevada. Use code MSCUST for a $150 discount!

Jan25PBI_Carousel

Power BI Monthly Update - January 2025

Check out the January 2025 Power BI update to learn about new features in Reporting, Modeling, and Data Connectivity.

Jan NL Carousel

Fabric Community Update - January 2025

Find out what's new and trending in the Fabric community.

Top Solution Authors