Reputation: 69
i am struggling to figure out how to get the cost of a resource in azure with python sdk
i have created a client "BillingManagementClient" but i have no idea how to start using it and find cost information about resources , can anyone share his knowledge?
Upvotes: 1
Views: 1226
Reputation: 1864
To get the resource cost with Azure Python SDK, Billing is available as a SDK. azure-mgmt-billing 6.0.0 and azure-mgmt-consumption 8.0.0
def _send_request(self, http_request, **kwargs):
# type: (HttpRequest, Any) -> HttpResponse
"""Runs the network request through the client's chained policies.
:param http_request: The network request you want to make. Required.
:type http_request: ~azure.core.pipeline.transport.HttpRequest
:keyword bool stream: Whether the response payload will be streamed. Defaults to True.
:return: The response of your network call. Does not do error handling on your response.
:rtype: ~azure.core.pipeline.transport.HttpResponse
"""
path_format_arguments = {
'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'),
}
http_request.url = self._client.format_url(http_request.url, **path_format_arguments)
stream = kwargs.pop("stream", True)
pipeline_response = self._client._pipeline.run(http_request, stream=stream, **kwargs)
return pipeline_response.http_response
You can refer to Show azure cost analysis data using Azure billing API/SDK and Getting started - Managing Resource using Azure Python SDK
Upvotes: 1