Azure billing API : Resource RateCard & Resource Usage - azure

I need to monitor our Azure spending for each of our client environments (one subscription, multiple resource group). In my research, I’ve found 2 API that I can use :
Resource RateCard
(https://msdn.microsoft.com/fr-fr/library/azure/mt219005)
Resource Usage (https://msdn.microsoft.com/fr-fr/library/azure/mt219003)
For the first one, I can obtain the price of each azure resource, it’s really interesting. But I cannot find a way to know what resource is related to a resource group.
I need at least the name of the resource. Is-it liked with the “MeterId” information ?
In the second one, I can obtain the usage of all azure resource. It’s perfect ! But how can I convert the resource usage in price ?
In the new azure portal (portal.azure.com), there is a section in a resource group : the billing part.
It is exactly the information that I’d like to obtain, using your API. Is it a way ?

For your first question, the RateCard API returns the list of the resources available at an Azure offer level (Pay-as-you-go, MSDN,…) and this is not specific to a customer’s subscription, so what you would get back here is the list of ALL the resources that are available for billing under an offer, along with resource metadata and prices, and this won’t have details like resource group that are specific to a customer’s subscription. One more point to note is that the resource metadata fields like Meter Name, Meter Category, Meter SubCategory can give customers a better understanding of what resource they are consuming, but this doesn’t include the instance-specific details resourceURI or resource tags.
As for the second question on the Usage API, this API returns aggregated, unrated Usage. The expectation is for the customer to get the aggregated usage data from the Usage API, then get the public rates from the RateCard API for the customer’s offer, and then do the operation of combining usage with the rate details to come up with a rated estimate.
The steps would look like this:
1) Call Usage API with specific time period and AzureSubID
2) Get the OfferID from the Azure Account Portal (go to account.windowsazure.com, select the subscription that you are interested in, bottom right corner has all the sub details including the 'OfferID' (e.g. MS-AZR-0063P)
3) Query the RateCard API with the OfferID, country, region, currency to get list of all resources available to be sold on that offer along with the associated rates, included quantity, discount etc
4) The common field across these two response would be the MeterID. You would get the usage responses with a unique MeterID which you can use to look up the RAteCard API (also called MeterID in RateCard) to get the exact rates that are applicable for this sub.
We are looking into another improvement to make Azure Usage API queryable by a billing cycle so customers don’t have to query by a date range, and they can just opt to query for a particular billing cycle’s usage data to get an exact snapshot of what they were charged that period, but we don't have a timeline on that yet.

Related

How to count the number of storage accounts having specific tag in Azure Policy?

I want to create an Azure Policy for storage accounts. During the creation of a storage account, it will count the number of storage accounts in the subscription which has a specific tag (like env:dev). If the number of this count exceeds 10, It should deny the creation of that storage account.
How I can count the number of storage account which has certain tag inside an Azure Policy declaration?
That is not something you can do using Azure Policy.
Even though the approach seems valid, the count operator is meant to be used with [*] aliases - see official documentation. One could think of scanning Microsoft.Subscription aliases, but running the command az provider show --namespace Microsoft.Subscription --expand "resourceTypes/aliases" --query "resourceTypes[].aliases[].name", what you get as an output is so far not extensive :
[
"Microsoft.Subscription/SubscriptionDefinitions/subscriptionId",
"Microsoft.Subscription/SubscriptionDefinitions/subscriptionDisplayName",
"Microsoft.Subscription/SubscriptionDefinitions/offerType",
"Microsoft.Subscription/SubscriptionDefinitions/etag",
"Microsoft.Subscription/aliases/subscriptionId"
]
Also, the way the policy engine works wouldn't allow you to count the number of instances meeting a particular rule : each ARM component is scanned individually and compared to the rules defined in the policy. You cannot see "all Storage Accounts in a given scope" - each one is scanned without the whole picture being seen at any point. That is why I started with looking if the Subscription object had something like a Resources [*] alias.

How to link Azure Resource sku api data to Azure consumption pricesheet api meter data?

Background: I'm trying to build an app for internal use to display prices for Azure Virtual Machines based on certain criteria, e.g. I want to specify that I require a VM with 4GB of ram, and then look up which VM sizes match that basic criteria, and the display the prices, i'll be comparing this data against other data we have internally for on-prem options.
This all needs to be our EA specific pricing so i can't use the anonymous retail pricing api.
Now, I can pull our EA specific pricesheet from the consumption > priceshet API documented at https://learn.microsoft.com/en-us/rest/api/consumption/pricesheet/get
This which will give me EA specific price details and a 'partNumber' such as 'aad-12345' and also a 'meterName' such as 'D2s v3' and also a 'meterid' which is a guid, but it does not include any further VM details like memory vCPUs etc.
That's fine, because I can pull Compute SKU data from the resource SKUs api documented here https://learn.microsoft.com/en-us/rest/api/compute/resourceskus/list
This will give me the specs for a virtual machine, including memory, vCPUs etc and also it will give me a 'size' property which roughly matches the 'meterName' property from the first API I mentioned above, but its not an exact match, for example, the SKU API will list the size as 'D2s_v3' and the consumption API will list a metername as 'D2s v3'. If that were consistent then perhaps I could make it work bu just replacing spaces with underscores or vice versa but I tried that and there are 80+ sizes in the sku output which dont match the pricesheet sizes if i follow this kind of matching process.
I'm looking for some unqiue identifier to cross reference these data sets or some technique for finding a match. I note that there is a 'meterId' property referenced in the sku api doco https://learn.microsoft.com/en-us/rest/api/compute/resourceskus/list#resourceskucosts - it would be great if i could use this if it matched the meterid in the pricesheet api, but i cannot get the sku api to return the meter id - is this possible?

Azure Cost Management - how to match ResourceGuid with ResourceId

I have a sponsored Azure subscription thanks to our partnership with Microsoft.
I have the ability to export usage from a dedicated web Site (Azure SponsorShip).
Unfortunately in the CSV file I received, I have only ResourceGUID and not ResourceId... And I don't know how to match these Ids.
Any ideas to find the Id related to a Resource Guid?
Thanks.
Resource GUID is different which denotes the Deployment GUID of the service. To get the breakdown of which resources are actually contributing towards the costs.
If you refer to the page Understand your bill for Microsoft Azure, you can see the description for the "Resource GUID" property:
The billed meter identifier. This is used as the identifier used to
price billing usage.
If you'd like to manually know the resource name which you are being billed for you can log into the Azure Account Center, click "Billing History" and download the usage details for the current period. This information is being updated daily, and you even get usage information with a daily breakdown

How to locate quota limits for Resource Types per Resource Group?

Trying to determine what the hard limits of Resources Types are within Resource Groups.
In our instance, we're specifically looking at the Resource Provider Microsoft.Network/publicIpAddresses.
The documentation states "Varies per resource type" but doesn't provide any additional details.
https://learn.microsoft.com/en-us/azure/azure-subscription-service-limits
We are aware that the default limit is 800 resources but would like to know what the hard limit beyond this is.
Also reviewed the Azure Management REST API's and PowerShell Cmdlets but unable to locate any way of pulling this information programmatically.
You need to contact support as the article says - SO doesn't have this info. Support can also adjust the limits for certain resource types.
If you're not getting an answer from support email me: bmoore at msft

what are the values that can be passed for sku.family and sku.capacity property in azure automation account

Here is the link for the resources of template format for the creation of azure automation account.
what is sku , sku.family and sku.capacity for automation account?
https://learn.microsoft.com/en-us/azure/templates/microsoft.automation/automationaccounts/jobschedules
Normally we can create the azure automation without sku.family and sku.capacity properties.But what are the possible values that can be passed to these resources for creation of arm template.
What could be the sku.family and its corresponding sku.capacity that can be passed????
What is the use of sku.family and sku.capacity in general for azure Resources ???
As you mentioned that link, we can find Sku object as pic.
Also we can get information about an automation account ,For a Free Sku, there is a response as below:
"properties":{
"sku":{
"name":"Free",
"family":null,
"capacity":null
},
Moreover, you can get more details from this relevant schema for Automation
https://raw.githubusercontent.com/Azure/azure-resource-manager-schemas/master/schemas/2015-10-31/Microsoft.Automation.json
Hope this helps.
In Azure Automation, SKU-Family and SKU-Capacity are unrequired and are more or less placeholders - "null" accepted.
SKu-name is the only required property of type "SKuNameEnum" with 2 possible values: "Basic" & "Free"
Here are 2 sample responses showing all 3 SKU object properties and you will notice family & capacity are both "null"
For your reference, there's a public facing API Browser page (in preview) that enumerates all supported REST APIs including API properties, description, usage and response samples. Simply enter the Azure service you would like to explore in the dropdown and drill through the listed APIs. In most cases, It includes a "Tryit" workflow to test the API call.
Hope this helps.

Resources