Using Azure Resource Graph returned Sku name to call Pricing API

Stanislav Fotev 100 Reputation points
2024-10-09T12:44:14.59+00:00

I am querying the resource graph to get all disks. For a disk I get the returned sku (in my case Standard_LRS) and region . I am then using this sku name and region to query the price sheet api. My goal is to get the cost for this type of disks, but the price sheet api return a lot of results. Which sku should I use to determine a price for the disk.

The calculator estimates a cost of 1.54$ for a S4 HDD in Germany West Central.
Can I make the same estimation using the price sheet api and the information from the resource graph api?

Additionally, can I use the azure calculator via an api call ?

Azure Cost Management
Azure Cost Management
A Microsoft offering that enables tracking of cloud usage and expenditures for Azure and other cloud providers.
3,577 questions
0 comments No comments
{count} votes

2 answers

Sort by: Most helpful
  1. SadiqhAhmed-MSFT 49,326 Reputation points Microsoft Employee Moderator
    2024-10-22T20:44:35.5366667+00:00

    @Stanislav Fotev Greetings!

    To determine the cost for a specific disk type using the Price Sheet API, you'll need to use multiple filters/combination of those to get the unique value for the correct SKU. This section in the doc https://learn.microsoft.com/en-us/rest/api/cost-management/retail-prices/azure-retail-prices#api-filters mentions multiple filter parameters.

    Here's how you can do it:

    Use the endpoint https://prices.azure.com/api/retail/prices?api-version=2023-01-01-preview

    Add query parameters to filter by the SKU and region. For example:

    https://prices.azure.com/api/retail/prices?api-version=2023-01-01-preview&$filter=serviceName eq 'Storage' and skuName eq 'Standard_LRS' and regionName eq 'Germany West Central'
    
    

    The API will return a JSON response with the pricing details for the specified SKU and region.

    You can compare the API response with the Azure Pricing Calculator to ensure the estimated cost matches2. For example, if the calculator estimates $1.54 for a S4 HDD in Germany West Central, you should see a similar price in the API response.

    Regarding your question about using the Azure calculator via an API call, unfortunately, there isn't a direct API call to the Azure Pricing Calculator. However, you can use the Price Sheet API to programmatically retrieve pricing information and build your own cost estimation tool.

    Hope this helps. Please post a reply if you need further assistance.

    0 comments No comments

  2. Hirdesh Baghel 45 Reputation points
    2024-12-12T06:59:09.5733333+00:00

    Hi
    I am working on a powershell script to find out the existing disk cost price per month. I am trying to use Azure Pricing API
    To get the price I need Location, SKUName, ProductType
    User's image

    -DiskSku "E20 LRS" -currencyCode "USD" -region "eastus"

    Hoever to get the Existing disk info I am using Get-AzDisk cmdlet and I am getting these info

    User's image

    But skuName I am not getting.

    Need info on from where can we fetch that?

    Kindly help

    0 comments No comments

Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.