Greetings AZ Community,
I am getting a 429 error whenever I interrogate the Cost Management API via Python.
This was happening occasionally but now I am being well and truly throttled.
Can you please advise if adjusting the rate limits in the Azure Resource Manager would help the situation?
Also “x-ms-ratelimit-microsoft.costmanagement-entity-retry-after” from the header of the API only retrieves ‘none’ after the 429 error.
Could you please advise how I should know how much time I should be waiting for API to go back to normal after a 429 error?
Also, I have a Python Azure SDK question.
I have the following code which should give me the Reservation Transactions which is from the cost management Python SDK examples in GitHub. (I have changed the subscription and billing account ids) and the file pvar.env contains the client_id, tenant_id and client_secret. The service principal has been
configured. Why would I get a client authentication error 401 when I run this? Ie caller is not authorised.
from azure.identity import DefaultAzureCredential
from azure.mgmt.consumption import ConsumptionManagementClient
from dotenv import load_dotenv
"""
# PREREQUISITES
pip install azure-identity
pip install azure-mgmt-consumption
# USAGE
python reservation_transactions_list_by_enrollment_number.py
Before run the sample, please set the values of the client ID, tenant ID and client secret
of the AAD application as environment variables: AZURE_CLIENT_ID, AZURE_TENANT_ID,
AZURE_CLIENT_SECRET. For more info about how to get the value, please see:
https://docs.microsoft.com/azure/active-directory/develop/howto-create-service-principal-portal
"""
load_dotenv("Pvar.env")
def main():
client = ConsumptionManagementClient(
credential=DefaultAzureCredential(),
subscription_id="xxx-xxx-xxx-xxx-xxxx",
)
response = client.reservation_transactions.list(
billing_account_id="xxxxxxxxx",
)
for item in response:
print(item)
# x-ms-original-file: specification/consumption/resource-manager/Microsoft.Consumption/stable/2021-10-01/examples/ReservationTransactionsListByEnrollmentNumber.json
if __name__ == "__main__":
main()