I am using the Azure Invoice API which has asks for the following parameters https://management.azure.com/providers/Microsoft.Billing/billingAccounts/**{billingAccountName}**/billingProfiles/**{billingProfileName}**/invoices/**{invoiceName}**?api-version=2019-10-01-preview
but after having all the parameters and running my Python code, I am facing an error which is defined below:
{'code': 'NotFound', 'message': 'The resource or one of its dependencies could not be found.'}
and I have given the Billing reader access to the Service Principle that I am using for generating access token. Is there anything required other than this role for reading Billing data of Azure? Is there a possibility that I am entering wrong parameters?
We are expecting to get the invoice data for Azure.
I am facing an error defined below {'code': 'NotFound', 'message': 'The resource or one of its dependencies could not be found.'}
The above error occurs maybe you have passed incorrect parameters, incorrect permissions, or issues with the API itself.
You can use the below Python code to fetch invoice details from a user with billing reader
role. it supports only users and groups to get the info of invoice details.
Portal:
Roles:
Code:
from azure.identity import DefaultAzureCredential
from azure.mgmt.billing import BillingManagementClient
def main():
client = BillingManagementClient(
credential=credential=DefaultAzureCredential(),
subscription_id="Your-subscription-id",
)
response = client.invoices.get(
billing_account_name="<your-billing-account-name>",
invoice_name="<Your-invoice-name>",
)
print(response)
if __name__ == "__main__":
main()
Output:
Reference: