Laszlo Halmi
Laszlo Halmi

Reputation: 3

How can I get prices from Azure by SDK or API call

Could you please help me? We have a 3rd party tool and it can connect to Azure cloud. We can deploy new cloud service, VM, etc. by this tool. But, I want to develop a module which is able to show the actual price of the server types (A0,A1,A2,A3,etc.) on the UI.

What is the easiest way to get them in either JSON or XML format using Python, JavaScript, or Curl?

Upvotes: 0

Views: 2326

Answers (3)

Peter Pan
Peter Pan

Reputation: 24148

As I known, using the Azure Billing REST APIs to get prices for your subscription is the only way in programming by now, as @ramiramilu and @MichaelB said.

If you need some examples as references, there are three samples for dotNet on Azure offical Github page, please see https://github.com/Azure/BillingCodeSamples.

Upvotes: 0

ramiramilu
ramiramilu

Reputation: 17182

Azure provides Usage and RateCard API (they are in preview as of now). As per Azure blog article on Cloudyn -

The Usage API provides access to estimated Azure consumption data for a subscription. The RateCard API provides complete pricing information of all Azure services, for non-Enterprise Agreement (EA) customers.

For more information - https://azure.microsoft.com/en-in/documentation/articles/billing-usage-rate-card-overview/

For HTTP Requests you have to make please refer - https://msdn.microsoft.com/library/azure/1ea5b323-54bb-423d-916f-190de96c6a3c

Upvotes: 3

Michael B
Michael B

Reputation: 12228

There is the Azure Billing REST API which will give you back a JSON document describing the (estimated! - I'm not sure why they estimate it, but there it is) rate of services for your subscription.

From the Azure Billing Documentation

Customers and partners can use the Azure Resource RateCard API to get the list of available Azure resources, along with estimated pricing information for each.

In order to use the API you would need to have either a user or a Service Principal configured with appropriate access to the subscription

Azure Role-based Access Control - Customers and partners can configure their access policies on the Azure Preview Portal or through Azure PowerShell cmdlets to specify which users or applications can get access to the RateCard data. Callers must use standard Azure Active Directory tokens for authentication. The caller must also be added to either the Reader, Owner or Contributor role to get access to the usage data for a particular Azure subscription.

Upvotes: 0

Related Questions