Skip to content

Issue downloading invoices with az billing invoice #25423

@bastianjohn

Description

@bastianjohn

Describe the bug

I try to download my invoices with the following method:
az billing invoice download --account-name "{accountName}" --invoice-name $invoiceName --download-token "token"

Command Name
az billing invoice download

Errors:

The command failed with an unexpected error. Here is the traceback:
'InvoicesOperations' object has no attribute 'download_invoice'
Traceback (most recent call last):
  File "/opt/homebrew/Cellar/azure-cli/2.45.0/libexec/lib/python3.10/site-packages/knack/cli.py", line 233, in invoke
    cmd_result = self.invocation.execute(args)
  File "/opt/homebrew/Cellar/azure-cli/2.45.0/libexec/lib/python3.10/site-packages/azure/cli/core/commands/__init__.py", line 663, in execute
    raise ex
  File "/opt/homebrew/Cellar/azure-cli/2.45.0/libexec/lib/python3.10/site-packages/azure/cli/core/commands/__init__.py", line 726, in _run_jobs_serially
    results.append(self._run_job(expanded_arg, cmd_copy))
  File "/opt/homebrew/Cellar/azure-cli/2.45.0/libexec/lib/python3.10/site-packages/azure/cli/core/commands/__init__.py", line 697, in _run_job
    result = cmd_copy(params)
  File "/opt/homebrew/Cellar/azure-cli/2.45.0/libexec/lib/python3.10/site-packages/azure/cli/core/commands/__init__.py", line 333, in __call__
    return self.handler(*args, **kwargs)
  File "/opt/homebrew/Cellar/azure-cli/2.45.0/libexec/lib/python3.10/site-packages/azure/cli/core/commands/command_operation.py", line 121, in handler
    return op(**command_args)
  File "/opt/homebrew/Cellar/azure-cli/2.45.0/libexec/lib/python3.10/site-packages/azure/cli/command_modules/billing/manual/custom.py", line 24, in billing_invoice_download
    return client.download_invoice(account_name, invoice_name, download_token)
AttributeError: 'InvoicesOperations' object has no attribute 'download_invoice'

What i wanted to do

Normally i just want to download all the invoices in all subscriptions. Therefore i tried to use AZ CLI. Unfortunaetly its not really working. I tried also:

$newInvoiceList = az billing invoice list

Invoke-WebRequest -Uri $_.newInvoiceListDocURL -headers $headers  -OutFile ($invoiceName + ".pdf")     

With this i get an authentication error | {"error":{"code":"AuthorizationFailed","message":"The client '{UserId}' with object id
| '297db162-cbe2-4cc4-8a24-99ea642014c0' does not have authorization to perform action
| 'Microsoft.Billing/billingAccounts/billingSubscriptions/invoices/download/read' over scope
| '/providers/Microsoft.Billing/billingAccounts/default/billingSubscriptions/subid/invoices/E0800XXXX' or the scope is invalid. If access was recently granted, please refresh your credentials."}}

Environment Summary

macOS-13.0-arm64-arm-64bit, Darwin 22.1.0
Python 3.10.10
Installer: HOMEBREW

azure-cli 2.45.0

Additional Context

Metadata

Metadata

Assignees

Labels

Azure CLI TeamThe command of the issue is owned by Azure CLI teamBillingaz billingService AttentionThis issue is responsible by Azure service team.customer-reportedIssues that are reported by GitHub users external to the Azure organization.feature-requestneeds-team-attentionThis issue needs attention from Azure service team or SDK team

Type

No type
No fields configured for issues without a type.

Projects

No projects

Relationships

None yet

Development

No branches or pull requests

Issue actions