Получение сведений об использовании запрошенной подписки
GET https://management.azure.com/subscriptions/{subscriptionId}/providers/Microsoft.CognitiveServices/locations/{location}/usages?api-version=2023-05-01
С использованием необязательных параметров:
GET https://management.azure.com/subscriptions/{subscriptionId}/providers/Microsoft.CognitiveServices/locations/{location}/usages?api-version=2023-05-01&$filter={$filter}
Параметры URI
Имя |
В |
Обязательно |
Тип |
Описание |
location
|
path |
True
|
string
|
Расположение ресурса.
|
subscriptionId
|
path |
True
|
string
|
Идентификатор целевой подписки.
|
api-version
|
query |
True
|
string
|
Версия API, используемая для данной операции.
|
$filter
|
query |
|
string
|
Выражение фильтра OData, описывающее подмножество возвращаемых видов использования. Поддерживаемый параметр — name.value (имя метрики может иметь или из нескольких имен).
|
Ответы
Примеры
Get Usages
Образец запроса
GET https://management.azure.com/subscriptions/00000000-0000-0000-0000-000000000000/providers/Microsoft.CognitiveServices/locations/WestUS/usages?api-version=2023-05-01
/** Samples for Usages List. */
public final class Main {
/*
* x-ms-original-file: specification/cognitiveservices/resource-manager/Microsoft.CognitiveServices/stable/2023-05-01/examples/ListUsages.json
*/
/**
* Sample code: Get Usages.
*
* @param manager Entry point to CognitiveServicesManager.
*/
public static void getUsages(com.azure.resourcemanager.cognitiveservices.CognitiveServicesManager manager) {
manager.usages().list("WestUS", null, 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.cognitiveservices import CognitiveServicesManagementClient
"""
# PREREQUISITES
pip install azure-identity
pip install azure-mgmt-cognitiveservices
# USAGE
python list_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 = CognitiveServicesManagementClient(
credential=DefaultAzureCredential(),
subscription_id="00000000-0000-0000-0000-000000000000",
)
response = client.usages.list(
location="WestUS",
)
for item in response:
print(item)
# x-ms-original-file: specification/cognitiveservices/resource-manager/Microsoft.CognitiveServices/stable/2023-05-01/examples/ListUsages.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 armcognitiveservices_test
import (
"context"
"log"
"github.com/Azure/azure-sdk-for-go/sdk/azidentity"
"github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/cognitiveservices/armcognitiveservices"
)
// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/310a0100f5b020c1900c527a6aa70d21992f078a/specification/cognitiveservices/resource-manager/Microsoft.CognitiveServices/stable/2023-05-01/examples/ListUsages.json
func ExampleUsagesClient_NewListPager() {
cred, err := azidentity.NewDefaultAzureCredential(nil)
if err != nil {
log.Fatalf("failed to obtain a credential: %v", err)
}
ctx := context.Background()
clientFactory, err := armcognitiveservices.NewClientFactory("<subscription-id>", cred, nil)
if err != nil {
log.Fatalf("failed to create client: %v", err)
}
pager := clientFactory.NewUsagesClient().NewListPager("WestUS", &armcognitiveservices.UsagesClientListOptions{Filter: nil})
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.UsageListResult = armcognitiveservices.UsageListResult{
// Value: []*armcognitiveservices.Usage{
// {
// Name: &armcognitiveservices.MetricName{
// LocalizedValue: to.Ptr("Cognitive Services total account limit"),
// Value: to.Ptr("AccountCount"),
// },
// CurrentValue: to.Ptr[float64](3),
// Limit: to.Ptr[float64](200),
// Unit: to.Ptr(armcognitiveservices.UnitTypeCount),
// }},
// }
}
}
To use the Azure SDK library in your project, see this documentation. To provide feedback on this code sample, open a GitHub issue
const { CognitiveServicesManagementClient } = require("@azure/arm-cognitiveservices");
const { DefaultAzureCredential } = require("@azure/identity");
/**
* This sample demonstrates how to Get usages for the requested subscription
*
* @summary Get usages for the requested subscription
* x-ms-original-file: specification/cognitiveservices/resource-manager/Microsoft.CognitiveServices/stable/2023-05-01/examples/ListUsages.json
*/
async function getUsages() {
const subscriptionId =
process.env["COGNITIVESERVICES_SUBSCRIPTION_ID"] || "00000000-0000-0000-0000-000000000000";
const location = "WestUS";
const credential = new DefaultAzureCredential();
const client = new CognitiveServicesManagementClient(credential, subscriptionId);
const resArray = new Array();
for await (let item of client.usages.list(location)) {
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
using System;
using System.Threading.Tasks;
using Azure.Core;
using Azure.Identity;
using Azure.ResourceManager;
using Azure.ResourceManager.CognitiveServices;
using Azure.ResourceManager.CognitiveServices.Models;
using Azure.ResourceManager.Resources;
// Generated from example definition: specification/cognitiveservices/resource-manager/Microsoft.CognitiveServices/stable/2023-05-01/examples/ListUsages.json
// this example is just showing the usage of "Usages_List" operation, for the dependent resources, they will have to be created separately.
// get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line
TokenCredential cred = new DefaultAzureCredential();
// authenticate your client
ArmClient client = new ArmClient(cred);
// this example assumes you already have this SubscriptionResource created on azure
// for more information of creating SubscriptionResource, please refer to the document of SubscriptionResource
string subscriptionId = "00000000-0000-0000-0000-000000000000";
ResourceIdentifier subscriptionResourceId = SubscriptionResource.CreateResourceIdentifier(subscriptionId);
SubscriptionResource subscriptionResource = client.GetSubscriptionResource(subscriptionResourceId);
// invoke the operation and iterate over the result
AzureLocation location = new AzureLocation("WestUS");
await foreach (ServiceAccountUsage item in subscriptionResource.GetUsagesAsync(location))
{
Console.WriteLine($"Succeeded: {item}");
}
Console.WriteLine($"Succeeded");
To use the Azure SDK library in your project, see this documentation. To provide feedback on this code sample, open a GitHub issue
Пример ответа
{
"value": [
{
"name": {
"value": "AccountCount",
"localizedValue": "Cognitive Services total account limit"
},
"currentValue": 3,
"limit": 200,
"unit": "Count"
}
]
}
Определения
ErrorAdditionalInfo
Дополнительные сведения об ошибке управления ресурсами.
Имя |
Тип |
Описание |
info
|
object
|
Дополнительные сведения.
|
type
|
string
|
Тип дополнительных сведений.
|
ErrorDetail
Сведения об ошибке.
Имя |
Тип |
Описание |
additionalInfo
|
ErrorAdditionalInfo[]
|
Дополнительные сведения об ошибке.
|
code
|
string
|
Код ошибки.
|
details
|
ErrorDetail[]
|
Сведения об ошибке.
|
message
|
string
|
Сообщение об ошибке.
|
target
|
string
|
Целевой объект ошибки.
|
ErrorResponse
Сообщение об ошибке
MetricName
имя метрики;
Имя |
Тип |
Описание |
localizedValue
|
string
|
Понятное имя метрики.
|
value
|
string
|
Имя метрики.
|
QuotaUsageStatus
Состояние использования квоты учетной записи Cognitive Services.
Имя |
Тип |
Описание |
Blocked
|
string
|
|
InOverage
|
string
|
|
Included
|
string
|
|
Unknown
|
string
|
|
UnitType
Единица измерения метрики.
Имя |
Тип |
Описание |
Bytes
|
string
|
|
BytesPerSecond
|
string
|
|
Count
|
string
|
|
CountPerSecond
|
string
|
|
Milliseconds
|
string
|
|
Percent
|
string
|
|
Seconds
|
string
|
|
Usage
Данные об использовании для запроса на использование.
Имя |
Тип |
Описание |
currentValue
|
number
|
Текущее значение для этой метрики.
|
limit
|
number
|
Максимальное значение для этой метрики.
|
name
|
MetricName
|
Сведения об имени для метрики.
|
nextResetTime
|
string
|
Время следующего сброса текущей квоты.
|
quotaPeriod
|
string
|
Период квоты, используемый для суммы значений использования.
|
status
|
QuotaUsageStatus
|
Состояние использования квоты учетной записи Cognitive Services.
|
unit
|
UnitType
|
Единица измерения метрики.
|
UsageListResult
Ответ на запрос использования списка.
Имя |
Тип |
Описание |
nextLink
|
string
|
Ссылка, используемая для получения следующей страницы сведений об использовании.
|
value
|
Usage[]
|
Список вариантов использования учетной записи Cognitive Service.
|