azure-sdk-for-python icon indicating copy to clipboard operation
azure-sdk-for-python copied to clipboard

azure.mgmt.billing > invoices.list_by_billing_account does not work for EA Customers

Open Git-BT-Hub opened this issue 3 years ago • 7 comments

  • Package Name: azure.mgmt.billing
  • Package Version: latest
  • Operating System:
  • Python Version: 3.7+

Package: azure.mgmt.billing def main(): client = BillingManagementClient( credential=DefaultAzureCredential(), subscription_id="SUBSCRIPTION_ID", )

response = client.invoices.list_by_billing_account(
    billing_account_name="{billingAccountName}",
    period_start_date="2018-01-01",
    period_end_date="2018-06-30",
)
for item in response:
    print(item)

This does not seems to work as expected for Customers with Enterprise Agreement Accounts, where the billing_account_name and billing_account_id is the same thing

Error : (BadRequest) Invalid billing account name.

I am sending Enrollment Account number in [ billing_account_name="{billingAccountName}"]

The REST API works with Billing Account ID / Enrollment Account number > GET https://management.azure.com/providers/Microsoft.Billing/billingAccounts/{billingAccountName}/invoices?api-version=2019-10-01-preview&periodStartDate={periodStartDate}&periodEndDate={periodEndDate}

Please can you fix this or let me know which version will work as per REST API

Thanks

Git-BT-Hub avatar Oct 12 '23 06:10 Git-BT-Hub

Thanks for the report @Git-BT-Hub! @msyyc, could please help take a look to determine if this issue is in our SDK or the swagger spec?

annatisch avatar Oct 12 '23 22:10 annatisch

@ChenxiJiang333 Please help on this issue.

msyyc avatar Oct 13 '23 01:10 msyyc

Hi @Git-BT-Hub SDK method is used to call the api as well and this error was raised by the service. Since the api version 2019-10-01-preview works with REST API, it might also work with sdk methods. You could try to use sdk methods to call api in that version by updating your code on creating the client like:

client = BillingManagementClient(
    credential=DefaultAzureCredential(),
    subscription_id=SUBSCRIPTION_ID,
    api_version="2019-10-01-preview"
)

ChenxiJiang333 avatar Oct 13 '23 07:10 ChenxiJiang333

Hi @ChenxiJiang333 - Thanks for your help, adding api_version="2019-10-01-preview" still does not work Also this issue is not limited to "client.invoices.list_by_billing_account" , there are others which result in same error Please see below screenshot , let me know if you need more details

Thanks

image

Git-BT-Hub avatar Oct 13 '23 13:10 Git-BT-Hub

Hi @Git-BT-Hub Please add the following code to get the detailed log and see whether the billing_account_name found in the Request URL is expected.

import logging
logging.basicConfig(level=logging.DEBUG,
                    format='%(asctime)s - %(name)s - %(levelname)s - %(message)s',
                    filename=".log",
                    filemode="w")

billing_client = BillingManagementClient(credential, subscription_id="SUBSCRIPTION_ID", logging_enable=True)

Screenshot 2023-10-16 114642

ChenxiJiang333 avatar Oct 16 '23 03:10 ChenxiJiang333

Hi @Git-BT-Hub. Thank you for opening this issue and giving us the opportunity to assist. To help our team better understand your issue and the details of your scenario please provide a response to the question asked above or the information requested above. This will help us more accurately address your issue.

github-actions[bot] avatar Oct 20 '23 14:10 github-actions[bot]

Hi @Git-BT-Hub, we're sending this friendly reminder because we haven't heard back from you in 7 days. We need more information about this issue to help address it. Please be sure to give us your input. If we don't hear back from you within 14 days of this comment the issue will be automatically closed. Thank you!

github-actions[bot] avatar Oct 27 '23 15:10 github-actions[bot]