Recupera gli usi (dati più recenti) per il database specificato.
GET https://management.azure.com/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DocumentDB/databaseAccounts/{accountName}/databases/{databaseRid}/usages?api-version=2023-11-15
With optional parameters:
GET https://management.azure.com/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DocumentDB/databaseAccounts/{accountName}/databases/{databaseRid}/usages?api-version=2023-11-15&$filter={$filter}
Parametri dell'URI
Nome |
In |
Necessario |
Tipo |
Descrizione |
accountName
|
path |
True
|
string
|
Nome dell'account del database Cosmos DB.
Regex pattern: ^[a-z0-9]+(-[a-z0-9]+)*
|
databaseRid
|
path |
True
|
string
|
Rid del database Cosmos DB.
|
resourceGroupName
|
path |
True
|
string
|
Nome del gruppo di risorse. Per il nome non viene fatta distinzione tra maiuscole e minuscole.
|
subscriptionId
|
path |
True
|
string
|
ID della sottoscrizione di destinazione.
|
api-version
|
query |
True
|
string
|
Versione dell'API da usare per questa operazione.
|
$filter
|
query |
|
string
|
Espressione di filtro OData che descrive un subset di utilizzi da restituire. Il parametro supportato è name.value (nome della metrica, può avere uno o più nomi).
|
Risposte
Nome |
Tipo |
Descrizione |
200 OK
|
UsagesResult
|
Gli usi per il database sono stati recuperati correttamente.
|
Sicurezza
azure_auth
Flusso OAuth2 di Azure Active Directory
Type:
oauth2
Flow:
implicit
Authorization URL:
https://login.microsoftonline.com/common/oauth2/authorize
Scopes
Nome |
Descrizione |
user_impersonation
|
Rappresentare l'account utente
|
Esempio
CosmosDBDatabaseGetUsages
Sample Request
GET https://management.azure.com/subscriptions/subid/resourceGroups/rg1/providers/Microsoft.DocumentDB/databaseAccounts/ddb1/databases/databaseRid/usages?api-version=2023-11-15&$filter=$filter=name.value eq 'Storage'
/**
* Samples for Database ListUsages.
*/
public final class Main {
/*
* x-ms-original-file: specification/cosmos-db/resource-manager/Microsoft.DocumentDB/stable/2023-11-15/examples/
* CosmosDBDatabaseGetUsages.json
*/
/**
* Sample code: CosmosDBDatabaseGetUsages.
*
* @param azure The entry point for accessing resource management APIs in Azure.
*/
public static void cosmosDBDatabaseGetUsages(com.azure.resourcemanager.AzureResourceManager azure) {
azure.cosmosDBAccounts().manager().serviceClient().getDatabases().listUsages("rg1", "ddb1", "databaseRid",
"$filter=name.value eq 'Storage'", com.azure.core.util.Context.NONE);
}
}
To use the Azure SDK library in your project, see this documentation. To provide feedback on this code sample, open a GitHub issue
from azure.identity import DefaultAzureCredential
from azure.mgmt.cosmosdb import CosmosDBManagementClient
"""
# PREREQUISITES
pip install azure-identity
pip install azure-mgmt-cosmosdb
# USAGE
python cosmos_db_database_get_usages.py
Before run the sample, please set the values of the client ID, tenant ID and client secret
of the AAD application as environment variables: AZURE_CLIENT_ID, AZURE_TENANT_ID,
AZURE_CLIENT_SECRET. For more info about how to get the value, please see:
https://docs.microsoft.com/azure/active-directory/develop/howto-create-service-principal-portal
"""
def main():
client = CosmosDBManagementClient(
credential=DefaultAzureCredential(),
subscription_id="subid",
)
response = client.database.list_usages(
resource_group_name="rg1",
account_name="ddb1",
database_rid="databaseRid",
)
for item in response:
print(item)
# x-ms-original-file: specification/cosmos-db/resource-manager/Microsoft.DocumentDB/stable/2023-11-15/examples/CosmosDBDatabaseGetUsages.json
if __name__ == "__main__":
main()
To use the Azure SDK library in your project, see this documentation. To provide feedback on this code sample, open a GitHub issue
package armcosmos_test
import (
"context"
"log"
"github.com/Azure/azure-sdk-for-go/sdk/azcore/to"
"github.com/Azure/azure-sdk-for-go/sdk/azidentity"
"github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/cosmos/armcosmos/v2"
)
// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/41e4538ed7bb3ceac3c1322c9455a0812ed110ac/specification/cosmos-db/resource-manager/Microsoft.DocumentDB/stable/2023-11-15/examples/CosmosDBDatabaseGetUsages.json
func ExampleDatabaseClient_NewListUsagesPager() {
cred, err := azidentity.NewDefaultAzureCredential(nil)
if err != nil {
log.Fatalf("failed to obtain a credential: %v", err)
}
ctx := context.Background()
clientFactory, err := armcosmos.NewClientFactory("<subscription-id>", cred, nil)
if err != nil {
log.Fatalf("failed to create client: %v", err)
}
pager := clientFactory.NewDatabaseClient().NewListUsagesPager("rg1", "ddb1", "databaseRid", &armcosmos.DatabaseClientListUsagesOptions{Filter: to.Ptr("$filter=name.value eq 'Storage'")})
for pager.More() {
page, err := pager.NextPage(ctx)
if err != nil {
log.Fatalf("failed to advance page: %v", err)
}
for _, v := range page.Value {
// You could use page here. We use blank identifier for just demo purposes.
_ = v
}
// If the HTTP response code is 200 as defined in example definition, your page structure would look as follows. Please pay attention that all the values in the output are fake values for just demo purposes.
// page.UsagesResult = armcosmos.UsagesResult{
// Value: []*armcosmos.Usage{
// {
// Name: &armcosmos.MetricName{
// LocalizedValue: to.Ptr("Storage"),
// Value: to.Ptr("Storage"),
// },
// CurrentValue: to.Ptr[int64](0),
// Limit: to.Ptr[int64](10737418240),
// QuotaPeriod: to.Ptr("P1D"),
// Unit: to.Ptr(armcosmos.UnitTypeBytes),
// }},
// }
}
}
To use the Azure SDK library in your project, see this documentation. To provide feedback on this code sample, open a GitHub issue
const { CosmosDBManagementClient } = require("@azure/arm-cosmosdb");
const { DefaultAzureCredential } = require("@azure/identity");
/**
* This sample demonstrates how to Retrieves the usages (most recent data) for the given database.
*
* @summary Retrieves the usages (most recent data) for the given database.
* x-ms-original-file: specification/cosmos-db/resource-manager/Microsoft.DocumentDB/stable/2023-11-15/examples/CosmosDBDatabaseGetUsages.json
*/
async function cosmosDbDatabaseGetUsages() {
const subscriptionId = process.env["COSMOSDB_SUBSCRIPTION_ID"] || "subid";
const resourceGroupName = process.env["COSMOSDB_RESOURCE_GROUP"] || "rg1";
const accountName = "ddb1";
const databaseRid = "databaseRid";
const filter = "$filter=name.value eq 'Storage'";
const options = { filter };
const credential = new DefaultAzureCredential();
const client = new CosmosDBManagementClient(credential, subscriptionId);
const resArray = new Array();
for await (let item of client.database.listUsages(
resourceGroupName,
accountName,
databaseRid,
options,
)) {
resArray.push(item);
}
console.log(resArray);
}
To use the Azure SDK library in your project, see this documentation. To provide feedback on this code sample, open a GitHub issue
Sample Response
{
"value": [
{
"unit": "Bytes",
"quotaPeriod": "P1D",
"limit": 10737418240,
"currentValue": 0,
"name": {
"value": "Storage",
"localizedValue": "Storage"
}
}
]
}
Definizioni
Nome |
Descrizione |
MetricName
|
Un nome della metrica.
|
UnitType
|
Unità della metrica.
|
Usage
|
Dati di utilizzo per una richiesta di utilizzo.
|
UsagesResult
|
Risposta a una richiesta di utilizzo dell'elenco.
|
MetricName
Un nome della metrica.
Nome |
Tipo |
Descrizione |
localizedValue
|
string
|
Nome descrittivo della metrica.
|
value
|
string
|
Nome della metrica.
|
UnitType
Unità della metrica.
Nome |
Tipo |
Descrizione |
Bytes
|
string
|
|
BytesPerSecond
|
string
|
|
Count
|
string
|
|
CountPerSecond
|
string
|
|
Milliseconds
|
string
|
|
Percent
|
string
|
|
Seconds
|
string
|
|
Usage
Dati di utilizzo per una richiesta di utilizzo.
Nome |
Tipo |
Descrizione |
currentValue
|
integer
|
Valore corrente per questa metrica
|
limit
|
integer
|
Valore massimo per questa metrica
|
name
|
MetricName
|
Informazioni sul nome per la metrica.
|
quotaPeriod
|
string
|
Periodo di quota utilizzato per riepilogare i valori di utilizzo.
|
unit
|
UnitType
|
Unità della metrica.
|
UsagesResult
Risposta a una richiesta di utilizzo dell'elenco.
Nome |
Tipo |
Descrizione |
value
|
Usage[]
|
Elenco di utilizzi per il database. Un utilizzo è una metrica temporizzato
|