"Cost management data is unavailable for subscription" AZURE cost usage API - azure

I'm trying to retrieve Azure cost data for the management group using azure cost usage API.
https://learn.microsoft.com/en-us/rest/api/cost-management/query/usage
But Im getting below error.
"Cost management data is unavailable for subscription xxxxxxxxxxx. The offer MS-AZR-xxxxP is not supported. (Request ID: xxxxx-xxxxx-xxx-xxx-xxxxx)"
Request URL
https://management.azure.com/providers/Microsoft.Management/managementGroups/xxxxxxxxxx/providers/Microsoft.CostManagement/query?api-version=2019-11-01&$top=5000
Is there any way to skip such subsciptions and get data for supported subscriptions using above API.Please assist.

Reason you may be seeing this message is because Azure Cost Management is not supported for all Azure Offer types.
Please check this link for supported/unsupported Azure Offer types for Azure Cost Management: https://learn.microsoft.com/en-us/azure/cost-management-billing/costs/understand-cost-mgt-data#supported-microsoft-azure-offers.

Related

Get Azure Resource Utilization by using azure COSTMANAGEMENT-API

Is there any way to get Cost and Utilization(CPU, Memory, DTU) trend of azure resources by using azure cost management apis.
If you check this Azure Cost Management documentation, then you will find that -
The Azure Cost Management APIs provide the ability to explore cost and usage data by creating customized filters and expressions allowing you to answer consumption-related questions for your Azure resources.
But note that these APIs are currently available for Azure Enterprise customers. So you can use it if you have the Enterprise Subscription.
To solve your problem you can use the Azure Consumption APIs. These APIs support Enterprise Enrollments and also some Web Direct Subscriptions. The Azure Consumption APIs give you programmatic access to cost and usage data for your Azure resources.
You should use Balances API, to get a monthly summary of information on balances, new purchases, Azure Marketplace service charges, adjustments, and overage charges.
And use Budgets API, to to create either cost or usage budgets for resources, resource groups, or billing meters.
Use the Usage Details API to get charge and usage data for all Azure 1st party resources you have.
Currently Balances API and Budgets API is only for Enterprise Customers only.

How to get cost of Azure subscription programmatically

Trying to understand the different Azure APIs to get the Azure subscription cost details programmatically.
I see RateCard API is good approach. In the output/response of this API , there is something called meterID and meterDetails.
anyone know what is this meterID and meterDetails ? how to get it using Azure Portal ?
The meterID is a GUID for every resource except VMs. meterDetails is the detailed Usage. You can get these details from the cost management section in Azure portal

Azure Rate Card reserved instance pricing

Is there an API provided by Azure providing information about Azure Rate Card pricing ?
The usual rate card doesn't seem to have any such information.
You could use Azure Billing APIs to predict and manage your costs, refer to this article.
Use Azure Billing APIs to pull usage and resource data into your preferred data analysis tools. The Azure Resource Usage and RateCard APIs can help you accurately predict and manage your costs.
Azure Invoice Download API: download invoices
Azure Resource Usage API: get your estimated Azure consumption data
Azure Resource RateCard API: get the list of available Azure resources and estimated pricing information for each

How to monitor Azure Classic VM using REST API or via Java SDK?

HI i want to monitor Azure Classic VM using REST API/Java SDK , when i tried it with REST API with the following URL(The below url worked for Azure VM)
https://management.azure.com/subscriptions/<subscription_id>/resourceGroups/Preprod2-Resource-Group/providers/Microsoft.ClassicCompute/virtualMachines/cloudops-testvm1/providers/microsoft.insights/metrics?api-version=2016-09-01
I'm getting the following error
{
"code": "NotFound",
"message": "Resource provider not found: [Microsoft.ClassicCompute]"
}
Please suggest me if it can be done via REST API or if there is an SDK please suggest me the same.
My requirement is i want to monitor Classic VM and collect Network In,Network Out,Percentage CPU,Disk Read Operations/Sec,Disk Write Operations/Sec,Disk Write Bytes and Disk Read Bytes for every 5mins
This isn't a supported resource type through metrics API. The supported types and metrics are here:Supported metrics with Azure Monitor. You could check this link, for now, classic VM is not supported.
According to your description, you could use the Metric Definitions API. It works for classic VM.
https://management.azure.com/subscriptions/<subscription_id>/resourceGroups/<resourceGroups/>/providers/Microsoft.ClassicCompute/virtualMachines/<Virutal name>/providers/microsoft.insights/metricdefinitions?api-version=2015-07-01
Metric information stores in Azure storage account, you also could call Storage API to get VM metrics. More information please refer to this link:Storage Analytics.

How to get DocumentDB Disk Usage without Azure Portal

Our Azure DocumentDB is managed by a different team. We don't have access to the Azure Portal. Is there a way for us to see the disk usage of a DocumentCollection? A REST API or .NET API?
You can use client.ReadDocumentCollectionAsync to get this information, e.g.,
ResourceResponse<DocumentCollection> response =
await client.ReadDocumentCollectionAsync(collectionLink);
Console.WriteLine(response.CollectionSizeQuota);
Console.WriteLine(response.CollectionSizeUsage);
See https://msdn.microsoft.com/en-us/library/microsoft.azure.documents.client.documentclient.readdocumentcollectionasync.aspx and https://msdn.microsoft.com/en-us/library/dn799209.aspx for more details.
The equivalent in the REST API is the x-ms-* response headers from GET collection.

Resources