How to get cost of Azure subscription programmatically - azure

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

Related

How much does Azure APIM charge if I am using it for just an hour and then delete it?

If I create an Azure API Management service in my subscription (I select SKU Developer that cost 48$/month via this official website)
I used it for 1 hour. And then I deleted my Azure APIM right away.
Question is:
Do I get charged for only 1 hour using Azure APIM ?
Or Do I have to pay a total of 48$ once I created APIM in my subscription?
If you delete API Management after one hour of deployment you'll only be charged for a single hour of use. In the US that's currently $0.07 / hour for the developer SKU. The Azure Pricing Calculator is great for pricing questions like this.

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

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.

how to find ServiceName in Azure Cloud billing export

In Azure Cost analysis console, we have the option to filter by Service Name. The same Column is NOT there in the billing CSV export I’m getting from Azure. Does anyone know how to filter Service name in billing export
I tried to see cost analysis in 'Cost Management + Billing | Billing account' menu, and I also found the downloaded CSV files don't contain an Service Name column. So I prefer to use cost management api to get the details.
Here's the api link: https://learn.microsoft.com/en-us/rest/api/cost-management/query/usage
By the way, I remembered that if someone wanna use this api, please make sure that the target subscription has joined Azure plan.
Hope it will do some help. Wish you a good day.

Cognitive services text translation authentication issue

I'm utilizing Azure's Cognitive Services Text Analysis API. I'm attempting to authenticate by passing my secret key for an access token via these instructions: https://learn.microsoft.com/en-us/azure/cognitive-services/translator/reference/v3-0-reference
I POST my Ocp-Apim-Subscription-Key to https://eastus.api.cognitive.microsoft.com/sts/v1.0/issueToken and get the following error:
{"error":{"code":"401","message": "The issueToken Operation under Token API V1.0 API is not supported with the current subscription key and pricing tier TextAnalytics.S."}}
I'm performing this authentication request using The Info Lab's macro in Alteryx - https://www.theinformationlab.co.uk/2017/09/26/translate-foreign-language-text-alteryx/ - I had to edit URL in the macro to add the "eastus" as the region in the issueToken request. Before I did that, I was getting an AccessDenied error response. At least now I know it's logging on to my resource because it will change the last letter in the error from "F" (free) to "S" to "S1" which are the pricing tiers I was switching between.
I have a pay-as-you-go subscription and I switched the resource to use Free, S, and S0 pricing tiers. Still always getting the same error. Please help!
Thank you
All provided in my summary.
I expect to get an authenticated token.
Per my understanding, you want to use Azure translator API and want to get an authenticated token specified by region. Based this doc mentioned , if you want to get a region based token, you should use Cognitive Service’s multi-service subscription . You can create a multi-service subscription by this link and you can get a token by its region and key as below :
For differences between Single-service resource and Multi-service resource , as official mentioned :
Multi-service resource:
Access multiple Azure Cognitive Services with
a single key and endpoint. Consolidates billing from the services you
use.
Single-service resource:
Access a single Azure Cognitive Service
with a unique key and endpoint for each service created. Use the free
tier to try out the service.
As we know except for translation service , there are many other services on Azure cognitive service . So when you create a Multi-service resource , you can call all Azure Cognitive Services . If you just need one or two kind Azure Cognitive Services or you want to get a separate billing of them, you can create Single-service resources separately.
In a wold, the differences between them is more about management instead of service.
Hope it helps.

How do you query usage details in Azure for CSP/Sponsored subscriptions?

So for Pay-as-you-Go Azure subscriptions you can use the ConsumptionManagementClient. However, this does not work on Azure Sponsorship or CSP subscriptions. It even states this at https://learn.microsoft.com/en-us/rest/api/consumption/. However, if you do have one of those unsupported subscription types, how do you get usage details?
Basically I want to be able to query the usageDetails of any subscription I am authorized to view in C#. What is the right approach to this?
Seems odd that Microsoft has completely different interfaces like this for usage details. What API/SDK (C#) should I be using when ConsumptionManagementClient doesn't work?
OK, so I was exploring the ARM subscription REST endpoint in more detail and I stumbled upon how to get this directly without the need for the ConsumptionManagementClient. For anyone else that needs this info, you can find it in '/providers/Microsoft.Commerce/UsageAggregates'. I can confirm this is working for both PAYG and sponsored subscriptions.

Resources