Site icon Microsoft 365 for IT Pros

Calculating the cost of Entra ID Premium Backup

Calculating the Cost for Microsoft 365 Backup for Entra Premium.
Advertisements

How Much Will it Cost to Protect Entra ID Objects (the Premium Way)

In last week’s article about the Microsoft 365 Backup for Entra Premium solution, I listed the ten types of objects captured for Entra backups and noted that Microsoft charges on a per-protected object basis at $0.025 monthly. That all seems pretty clear, until you start looking into the details to try and figure out how the charges a specific Entra tenant might accrue.

Microsoft doesn’t disclose the exact method used to count protected objects, so all we can do is create the best possible count based on current knowledge. All the object types are supported by Graph APIs, so a mixture of Graph requests and Microsoft Graph PowerShell SDK cmdlets will do the job. I prefer using SDK cmdlets whenever possible because I don’t need to deal with issues like pagination and the resulting code is simpler and clearer. However, as we’ll see, sometimes a Graph API request is the right answer.

Scripting the Numbers

I built a script to do the calculations. You can download the code from the Microsoft 365 for IT Pros GitHub repository. The flow is very simple:

Figure 1 shows the output for my tenant.

Figure 1: Calculating the monthly costs for Microsoft 365 Backup for Entra Premium

There might be some danger of double counting agent identities and blueprints because these objects are based on users, applications, and service principals. Their count might already be included with those objects, but we’ll have to see how Microsoft handles the situation. For now, the code looks for agent identities under service principals. It’s easy to amend the script if and when Microsoft clarifies the issue.

Each tenant has a single organization object. Backups include the object, but the code doesn’t count it.

Treat the computation as an estimate. The actual amount charged for backups can be confirmed after a month’s usage by examining the cost analysis data available in the Azure management portal.

The estimated costs for my tenant are modest, but this is for a very small tenant. What’s interesting is that the largest cost per object type is for service principals, many of which are created for Microsoft first-party applications. Cynics might consider this to be a case of Microsoft creating revenue for itself. I take a more sanguine view and believe that the folks who created the charging strategy simply didn’t realize how many Microsoft service principals exist.

In any case, while the charge to protect Microsoft service principals might irritate small tenants, it will be a rounding error for larger tenants who are charged to backup hundreds of thousands of objects.

Counting Graph Objects

Our code needs to count Graph objects and uses a variety of methods. The simplest way to get a count is to retrieve the objects into an array and then use the array’s count property:

$Count = (Get-MgUser -All).count

This approach works for most of the protected object types but can be very slow when the need exists to retrieve thousands of objects, like groups. In this situation, it’s best to use the feature designed for the purpose, the Graph $count query option:

$Headers = @{ConsistencyLevel = "eventual"}
$Uri = "https://graph.microsoft.com/v1.0/groups?`$count=true"
$Count = (Invoke-MgGraphRequest -Method GET -Uri $Uri -Headers $Headers).'@odata.count'

$count can be used with other Graph query options like $filter to return a precise count of the objects matching specific criteria, such as users belonging to a department. Using $count is much quicker than fetching all the objects, even if retrieval is limited to a single property.

Using the Measure-Command cmdlet, we can see the difference.

# Fetch all groups and retrieve their count
Measure-command {$Count = (Get-MgGroup -All -Property Id).count}

Milliseconds      : 630
Ticks             : 6306630
TotalSeconds      : 0.630663
TotalMilliseconds : 630.663

# Do the same using a Graph $count query
Measure-command {$Uri = "https://graph.microsoft.com/v1.0/groups?`$count=true"
$Count = (Invoke-MgGraphRequest -Method GET -Uri $Uri -Headers $Headers).'@odata.count'}

Milliseconds      : 261
Ticks             : 2615015
TotalSeconds      : 0.2615015
TotalMilliseconds : 261.5015

The tenant has just over 400 groups, which isn’t a lot. Even so, the $count query completes in about 261 milliseconds compared with 631 milliseconds when the objects are retrieved, roughly 2.4 times faster. The advantage becomes more important as the size of the collection increases because the $count query avoids transferring and processing every object.

Perhaps because users need to be counted so often, the Microsoft Graph PowerShell SDK includes the Get-MgUserCount cmdlet to return a count of users:

$Count = Get-MgUserCount -ConsistencyLevel Eventual

Not every Graph collection supports $count. The only example encountered among the set of protected object types is OAuth2 delegated permission grants. In this situation, a script must fetch the collection, follow any pagination links returned by Graph, and count the objects itself.

$Uri = "https://graph.microsoft.com/v1.0/oauth2PermissionGrants"
$Count = 0

Do {
    $Result = Invoke-MgGraphRequest -Method GET -Uri $Uri
    $Count += $Result.value.Count
    $Uri = $Result.'@odata.nextLink'
} While ($Uri)

The code paginates using the nextlink URL if more than one page of matching objects are available. The ConsistencyLevel header isn’t needed because all this code does is count the objects returned in each page. JSON Batching can improve performance when the need exists to fetch many objects with API requests but doesn’t eliminate the need to paginate. In any case, figuring out these counts is a one-time operation, so optimization for speed isn’t particularly important.

No Entra Counts

Microsoft probably stores the actual counts somewhere in Entra ID that tenants currently cannot access. It would be nice if this data was exposed in Microsoft 365 Backup reports. In the meantime, all we can go on are estimated values derived from the Graph with PowerShell.

And anyone who has ever overseen a building project knows how close estimates can be to the final bill.


The nice thing about generative AI tools is that they can generate information based on what’s gone before. The bad thing about generative AI tools is that they can’t create new thinking or insights about how technology works (or doesn’t). When we write the Microsoft 365 for IT Pros eBooks, we depend on hundreds of years of real-world experience, knowledge, and intuition to analyze and explain how Microsoft 365 really works. If you understand the basic principles about Entra ID, Exchange Online, SharePoint Online, Teams, the Microsoft Graph, and more, you’ll be able to figure out the value of new features as Microsoft adds them to the platform. All for less than ten cups of black coffee.

Exit mobile version