List Usage API for DB Account is not working Properly

Ravi Teja Manchikanti 46 Reputation points
2020-06-23T12:43:35.147+00:00

Hi Team ,

I was using below API to fetch the usages of the DB Account, I was not really successful for fetching the Document Count and other custom filter parameters (Index Size,Storage Capacity)... It is working only for Storage Metric which is default
https://video2.skills-academy.com/en-us/rest/api/cosmos-db-resource-provider/databaseaccounts/listusages#code-try-0

Azure Cosmos DB
Azure Cosmos DB
An Azure NoSQL database service for app development.
1,520 questions
{count} votes

1 answer

Sort by: Most helpful
  1. Mike Ubezzi 2,776 Reputation points
    2020-06-24T22:18:57.173+00:00

    Hi @Ravi Teja Manchikanti ,

    The storage metric is currently the only component for which List Usage will return a result set for, either at Database Account or Database. If you do not include a filter or your filter is as follows:

    $filter=name.value eq 'Storage'

    you will see storage metrics such as:

    {  
        "value": [  
            {  
                "unit": "Bytes",  
                "quotaPeriod": "P1D",  
                "limit": 53687091200,  
                "currentValue": 0,  
                "name": {  
                    "value": "Storage",  
                    "localizedValue": "Storage"  
                }  
            }  
        ]  
    }  
    

    If you change the filter to to query on a different component, the result will be empty:

    $filter=name.value eq 'Compute'

    There is however, issues with the examples. The filter expression is not correct in the example where there are two $filter variables.

    Incorrect

    $filter=$filter=name.value eq 'Storage'

    Correct

    $filter=name.value eq 'Storage'

    All the examples under REST/ API / Cosmos DB Resource Provider where a $filter is being used, the filter expression is incorrect. The expression should only use a single $filter variable. This issue can be filed with the Azure REST API Specification team, where the documentation will be addressed.

    Please let me know if you have any additional questions. ~Mike

    0 comments No comments