Azure / azure-rest-api-specs-examples

SDK examples for azure-rest-api-specs
MIT License
20 stars 13 forks source link

"Billing Accounts - List" returns empty list for api version 2020-05-01 #4364

Open RaniLinkov opened 6 months ago

RaniLinkov commented 6 months ago

Link to sample

https://learn.microsoft.com/en-us/rest/api/billing/billing-accounts/list?view=rest-billing-2020-05-01&viewFallbackFrom=rest-billing-2021-10-01

Library name and version

com.azure.resourcemanager:azure-resourcemanager-billing:1.0.0-beta.3

Language of the Sample

Sample Issue Type

Issue details

Getting empty billing account list when using api version 2020-05-01, both using REST and the billing sdk.

Able to retrieve account list using version 2019-10-01-preview.

Expected behavior

Expecting to get billing account list when using sdk method and\or HTTP endpoint

Actual behavior

Getting empty billing account list

Reproduction Steps

TokenCredential credential = new ClientSecretCredentialBuilder().clientId(credentials.getClientId())
                                                                            .clientSecret(credentials.getClientSecret())
                                                                            .tenantId(credentials.getTenantId())
                                                                            .build();

            AzureProfile profile = new AzureProfile(credentials.getTenantId(), null, AzureEnvironment.AZURE);

            BillingManager billingManager = BillingManager.authenticate(credential, profile);

            retVal = billingManager.billingAccounts().list().stream().collect(Collectors.toList());

Environment

Java 8 dropwizard

XiaofeiCao commented 3 months ago

Hi @RaniLinkov , this may be due to lack of permission. See https://github.com/Azure/azure-rest-api-specs/issues/21580#issuecomment-1340448613

2019-10-01-preview might not enforce permission on reading while 2020-05 might have. Would you try adding sufficient role/permission to your service principal and try again?(Billing Reader role may not be enough, you may need Account Administrator role as the comment above implies)