将资源的配额 (服务限制) 创建或更新为请求的值。
步骤:
发出 Get 请求以获取特定资源的配额信息。
若要增加配额,请将响应中的限制字段从 Get 请求更新为新值。
将 JSON 提交到配额请求 API 以更新配额。
可以按如下方式构造创建配额请求。 PUT 操作可用于更新配额。
PUT https://management.azure.com/subscriptions/{subscriptionId}/providers/Microsoft.Capacity/resourceProviders/{providerId}/locations/{location}/serviceLimits/{resourceName}?api-version=2020-10-25
URI 参数
名称 |
在 |
必需 |
类型 |
说明 |
location
|
path |
True
|
string
|
Azure 区域。
|
providerId
|
path |
True
|
string
|
Azure 资源提供程序 ID。
|
resourceName
|
path |
True
|
string
|
资源提供程序的资源名称,例如 Microsoft.Compute 的 SKU 名称、Microsoft.MachineLearningServices 的 Sku 或 TotalLowPriorityCores
|
subscriptionId
|
path |
True
|
string
|
Azure 订阅 ID。
|
api-version
|
query |
True
|
string
|
API 版本。
|
请求正文
响应
安全性
azure_auth
Azure Active Directory OAuth2 流
Type:
oauth2
Flow:
implicit
Authorization URL:
https://login.microsoftonline.com/common/oauth2/authorize
Scopes
名称 |
说明 |
user_impersonation
|
模拟用户帐户
|
示例
Quotas_Request_PutForCompute
Sample Request
PUT https://management.azure.com/subscriptions/D7EC67B3-7657-4966-BFFC-41EFD36BAAB3/providers/Microsoft.Capacity/resourceProviders/Microsoft.Compute/locations/eastus/serviceLimits/standardFSv2Family?api-version=2020-10-25
{
"properties": {
"limit": 200,
"unit": "Count",
"name": {
"value": "standardFSv2Family"
}
}
}
import com.azure.resourcemanager.reservations.models.QuotaProperties;
import com.azure.resourcemanager.reservations.models.ResourceName;
/** Samples for Quota CreateOrUpdate. */
public final class Main {
/*
* x-ms-original-file: specification/reservations/resource-manager/Microsoft.Capacity/stable/2020-10-25/examples/putComputeOneSkuQuotaRequest.json
*/
/**
* Sample code: Quotas_Request_PutForCompute.
*
* @param manager Entry point to ReservationsManager.
*/
public static void quotasRequestPutForCompute(com.azure.resourcemanager.reservations.ReservationsManager manager) {
manager
.quotas()
.define("standardFSv2Family")
.withExistingLocation("D7EC67B3-7657-4966-BFFC-41EFD36BAAB3", "Microsoft.Compute", "eastus")
.withProperties(
new QuotaProperties()
.withLimit(200)
.withUnit("Count")
.withName(new ResourceName().withValue("standardFSv2Family")))
.create();
}
}
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.reservations import AzureReservationAPI
"""
# PREREQUISITES
pip install azure-identity
pip install azure-mgmt-reservations
# USAGE
python put_compute_one_sku_quota_request.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 = AzureReservationAPI(
credential=DefaultAzureCredential(),
)
response = client.quota.begin_create_or_update(
subscription_id="D7EC67B3-7657-4966-BFFC-41EFD36BAAB3",
provider_id="Microsoft.Compute",
location="eastus",
resource_name="standardFSv2Family",
create_quota_request={"properties": {"limit": 200, "name": {"value": "standardFSv2Family"}, "unit": "Count"}},
).result()
print(response)
# x-ms-original-file: specification/reservations/resource-manager/Microsoft.Capacity/stable/2020-10-25/examples/putComputeOneSkuQuotaRequest.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 armreservations_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/reservations/armreservations/v3"
)
// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/1e7b408f3323e7f5424745718fe62c7a043a2337/specification/reservations/resource-manager/Microsoft.Capacity/stable/2020-10-25/examples/putComputeOneSkuQuotaRequest.json
func ExampleQuotaClient_BeginCreateOrUpdate_quotasRequestPutForCompute() {
cred, err := azidentity.NewDefaultAzureCredential(nil)
if err != nil {
log.Fatalf("failed to obtain a credential: %v", err)
}
ctx := context.Background()
clientFactory, err := armreservations.NewClientFactory(cred, nil)
if err != nil {
log.Fatalf("failed to create client: %v", err)
}
poller, err := clientFactory.NewQuotaClient().BeginCreateOrUpdate(ctx, "D7EC67B3-7657-4966-BFFC-41EFD36BAAB3", "Microsoft.Compute", "eastus", "standardFSv2Family", armreservations.CurrentQuotaLimitBase{
Properties: &armreservations.QuotaProperties{
Name: &armreservations.ResourceName{
Value: to.Ptr("standardFSv2Family"),
},
Limit: to.Ptr[int32](200),
Unit: to.Ptr("Count"),
},
}, nil)
if err != nil {
log.Fatalf("failed to finish the request: %v", err)
}
res, err := poller.PollUntilDone(ctx, nil)
if err != nil {
log.Fatalf("failed to pull the result: %v", err)
}
// You could use response here. We use blank identifier for just demo purposes.
_ = res
// If the HTTP response code is 200 as defined in example definition, your response structure would look as follows. Please pay attention that all the values in the output are fake values for just demo purposes.
// res.CurrentQuotaLimitBase = armreservations.CurrentQuotaLimitBase{
// Name: to.Ptr("2B5C8515-37D8-4B6A-879B-CD641A2CF605"),
// Type: to.Ptr("Microsoft.Capacity/serviceLimits"),
// ID: to.Ptr("/subscriptions/D7EC67B3-7657-4966-BFFC-41EFD36BAAB3/providers/Microsoft.Capacity/resourceProviders/Microsoft.Compute/locations/eastus/serviceLimitsRequests/2B5C8515-37D8-4B6A-879B-CD641A2CF605"),
// Properties: &armreservations.QuotaProperties{
// Name: &armreservations.ResourceName{
// LocalizedValue: to.Ptr("Standard FSv2 Family vCPUs"),
// Value: to.Ptr("standardFSv2Family"),
// },
// CurrentValue: to.Ptr[int32](160),
// Limit: to.Ptr[int32](200),
// Properties: map[string]any{
// },
// QuotaPeriod: to.Ptr(""),
// Unit: to.Ptr("Count"),
// },
// }
}
To use the Azure SDK library in your project, see this documentation. To provide feedback on this code sample, open a GitHub issue
const { AzureReservationAPI } = require("@azure/arm-reservations");
const { DefaultAzureCredential } = require("@azure/identity");
/**
* This sample demonstrates how to Create or update the quota (service limits) of a resource to the requested value.
Steps:
1. Make the Get request to get the quota information for specific resource.
2. To increase the quota, update the limit field in the response from Get request to new value.
3. Submit the JSON to the quota request API to update the quota.
The Create quota request may be constructed as follows. The PUT operation can be used to update the quota.
*
* @summary Create or update the quota (service limits) of a resource to the requested value.
Steps:
1. Make the Get request to get the quota information for specific resource.
2. To increase the quota, update the limit field in the response from Get request to new value.
3. Submit the JSON to the quota request API to update the quota.
The Create quota request may be constructed as follows. The PUT operation can be used to update the quota.
* x-ms-original-file: specification/reservations/resource-manager/Microsoft.Capacity/stable/2020-10-25/examples/putComputeOneSkuQuotaRequest.json
*/
async function quotasRequestPutForCompute() {
const subscriptionId = "D7EC67B3-7657-4966-BFFC-41EFD36BAAB3";
const providerId = "Microsoft.Compute";
const location = "eastus";
const resourceName = "standardFSv2Family";
const createQuotaRequest = {
properties: {
name: { value: "standardFSv2Family" },
limit: 200,
unit: "Count",
},
};
const credential = new DefaultAzureCredential();
const client = new AzureReservationAPI(credential);
const result = await client.quota.beginCreateOrUpdateAndWait(
subscriptionId,
providerId,
location,
resourceName,
createQuotaRequest
);
console.log(result);
}
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;
using Azure.Core;
using Azure.Identity;
using Azure.ResourceManager;
using Azure.ResourceManager.Reservations;
using Azure.ResourceManager.Reservations.Models;
using Azure.ResourceManager.Resources;
// Generated from example definition: specification/reservations/resource-manager/Microsoft.Capacity/stable/2020-10-25/examples/putComputeOneSkuQuotaRequest.json
// this example is just showing the usage of "Quota_CreateOrUpdate" 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 = "D7EC67B3-7657-4966-BFFC-41EFD36BAAB3";
ResourceIdentifier subscriptionResourceId = SubscriptionResource.CreateResourceIdentifier(subscriptionId);
SubscriptionResource subscriptionResource = client.GetSubscriptionResource(subscriptionResourceId);
// get the collection of this ReservationQuotaResource
string providerId = "Microsoft.Compute";
AzureLocation location = new AzureLocation("eastus");
ReservationQuotaCollection collection = subscriptionResource.GetAllReservationQuota(providerId, location);
// invoke the operation
string resourceName = "standardFSv2Family";
ReservationQuotaData data = new ReservationQuotaData()
{
Properties = new QuotaProperties()
{
Limit = 200,
Unit = "Count",
ResourceName = new ReservationResourceName()
{
Value = "standardFSv2Family",
},
},
};
ArmOperation<ReservationQuotaResource> lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, resourceName, data);
ReservationQuotaResource result = lro.Value;
// the variable result is a resource, you could call other operations on this instance as well
// but just for demo, we get its data from this resource instance
ReservationQuotaData resourceData = result.Data;
// for demo we just print out the id
Console.WriteLine($"Succeeded on id: {resourceData.Id}");
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
{
"id": "/subscriptions/D7EC67B3-7657-4966-BFFC-41EFD36BAAB3/providers/Microsoft.Capacity/resourceProviders/Microsoft.Compute/locations/eastus/serviceLimitsRequests/2B5C8515-37D8-4B6A-879B-CD641A2CF605",
"name": "2B5C8515-37D8-4B6A-879B-CD641A2CF605",
"type": "Microsoft.Capacity/ServiceLimits",
"properties": {
"provisioningState": "InProgress",
"message": ""
}
}
{
"id": "/subscriptions/D7EC67B3-7657-4966-BFFC-41EFD36BAAB3/providers/Microsoft.Capacity/resourceProviders/Microsoft.Compute/locations/eastus/serviceLimitsRequests/2B5C8515-37D8-4B6A-879B-CD641A2CF605",
"name": "2B5C8515-37D8-4B6A-879B-CD641A2CF605",
"type": "Microsoft.Capacity/serviceLimits",
"properties": {
"limit": 200,
"unit": "Count",
"currentValue": 160,
"name": {
"value": "standardFSv2Family",
"localizedValue": "Standard FSv2 Family vCPUs"
},
"quotaPeriod": "",
"properties": {}
}
}
Sample Request
PUT https://management.azure.com/subscriptions/D7EC67B3-7657-4966-BFFC-41EFD36BAAB3/providers/Microsoft.Capacity/resourceProviders/Microsoft.MachineLearningServices/locations/eastus/serviceLimits/StandardDv2Family?api-version=2020-10-25
{
"properties": {
"limit": 200,
"unit": "Count",
"name": {
"value": "StandardDv2Family"
},
"resourceType": "dedicated"
}
}
import com.azure.resourcemanager.reservations.models.QuotaProperties;
import com.azure.resourcemanager.reservations.models.ResourceName;
import com.azure.resourcemanager.reservations.models.ResourceType;
/** Samples for Quota CreateOrUpdate. */
public final class Main {
/*
* x-ms-original-file: specification/reservations/resource-manager/Microsoft.Capacity/stable/2020-10-25/examples/putMachineLearningServicesQuotaRequestDedicated.json
*/
/**
* Sample code: Quotas_Request_PutForMachineLearningServices_DedicatedResource.
*
* @param manager Entry point to ReservationsManager.
*/
public static void quotasRequestPutForMachineLearningServicesDedicatedResource(
com.azure.resourcemanager.reservations.ReservationsManager manager) {
manager
.quotas()
.define("StandardDv2Family")
.withExistingLocation("D7EC67B3-7657-4966-BFFC-41EFD36BAAB3", "Microsoft.MachineLearningServices", "eastus")
.withProperties(
new QuotaProperties()
.withLimit(200)
.withUnit("Count")
.withName(new ResourceName().withValue("StandardDv2Family"))
.withResourceType(ResourceType.DEDICATED))
.create();
}
}
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.reservations import AzureReservationAPI
"""
# PREREQUISITES
pip install azure-identity
pip install azure-mgmt-reservations
# USAGE
python put_machine_learning_services_quota_request_dedicated.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 = AzureReservationAPI(
credential=DefaultAzureCredential(),
)
response = client.quota.begin_create_or_update(
subscription_id="D7EC67B3-7657-4966-BFFC-41EFD36BAAB3",
provider_id="Microsoft.MachineLearningServices",
location="eastus",
resource_name="StandardDv2Family",
create_quota_request={
"properties": {
"limit": 200,
"name": {"value": "StandardDv2Family"},
"resourceType": "dedicated",
"unit": "Count",
}
},
).result()
print(response)
# x-ms-original-file: specification/reservations/resource-manager/Microsoft.Capacity/stable/2020-10-25/examples/putMachineLearningServicesQuotaRequestDedicated.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 armreservations_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/reservations/armreservations/v3"
)
// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/1e7b408f3323e7f5424745718fe62c7a043a2337/specification/reservations/resource-manager/Microsoft.Capacity/stable/2020-10-25/examples/putMachineLearningServicesQuotaRequestDedicated.json
func ExampleQuotaClient_BeginCreateOrUpdate_quotasRequestPutForMachineLearningServicesDedicatedResource() {
cred, err := azidentity.NewDefaultAzureCredential(nil)
if err != nil {
log.Fatalf("failed to obtain a credential: %v", err)
}
ctx := context.Background()
clientFactory, err := armreservations.NewClientFactory(cred, nil)
if err != nil {
log.Fatalf("failed to create client: %v", err)
}
poller, err := clientFactory.NewQuotaClient().BeginCreateOrUpdate(ctx, "D7EC67B3-7657-4966-BFFC-41EFD36BAAB3", "Microsoft.MachineLearningServices", "eastus", "StandardDv2Family", armreservations.CurrentQuotaLimitBase{
Properties: &armreservations.QuotaProperties{
Name: &armreservations.ResourceName{
Value: to.Ptr("StandardDv2Family"),
},
Limit: to.Ptr[int32](200),
ResourceType: to.Ptr(armreservations.ResourceTypeDedicated),
Unit: to.Ptr("Count"),
},
}, nil)
if err != nil {
log.Fatalf("failed to finish the request: %v", err)
}
res, err := poller.PollUntilDone(ctx, nil)
if err != nil {
log.Fatalf("failed to pull the result: %v", err)
}
// You could use response here. We use blank identifier for just demo purposes.
_ = res
// If the HTTP response code is 200 as defined in example definition, your response structure would look as follows. Please pay attention that all the values in the output are fake values for just demo purposes.
// res.CurrentQuotaLimitBase = armreservations.CurrentQuotaLimitBase{
// Name: to.Ptr("2B5C8515-37D8-4B6A-879B-CD641A2CF605"),
// Type: to.Ptr("Microsoft.Capacity/serviceLimits"),
// ID: to.Ptr("/subscriptions/D7EC67B3-7657-4966-BFFC-41EFD36BAAB3/providers/Microsoft.Capacity/resourceProviders/Microsoft.MachineLearningServices/locations/eastus/serviceLimitsRequests/2B5C8515-37D8-4B6A-879B-CD641A2CF605"),
// Properties: &armreservations.QuotaProperties{
// Name: &armreservations.ResourceName{
// LocalizedValue: to.Ptr("Standard Dv2 Family Cluster Dedicated vCPUs"),
// Value: to.Ptr("StandardDv2Family"),
// },
// CurrentValue: to.Ptr[int32](160),
// Limit: to.Ptr[int32](200),
// Properties: map[string]any{
// },
// QuotaPeriod: to.Ptr(""),
// ResourceType: to.Ptr(armreservations.ResourceTypeDedicated),
// Unit: to.Ptr("Count"),
// },
// }
}
To use the Azure SDK library in your project, see this documentation. To provide feedback on this code sample, open a GitHub issue
const { AzureReservationAPI } = require("@azure/arm-reservations");
const { DefaultAzureCredential } = require("@azure/identity");
/**
* This sample demonstrates how to Create or update the quota (service limits) of a resource to the requested value.
Steps:
1. Make the Get request to get the quota information for specific resource.
2. To increase the quota, update the limit field in the response from Get request to new value.
3. Submit the JSON to the quota request API to update the quota.
The Create quota request may be constructed as follows. The PUT operation can be used to update the quota.
*
* @summary Create or update the quota (service limits) of a resource to the requested value.
Steps:
1. Make the Get request to get the quota information for specific resource.
2. To increase the quota, update the limit field in the response from Get request to new value.
3. Submit the JSON to the quota request API to update the quota.
The Create quota request may be constructed as follows. The PUT operation can be used to update the quota.
* x-ms-original-file: specification/reservations/resource-manager/Microsoft.Capacity/stable/2020-10-25/examples/putMachineLearningServicesQuotaRequestDedicated.json
*/
async function quotasRequestPutForMachineLearningServicesDedicatedResource() {
const subscriptionId = "D7EC67B3-7657-4966-BFFC-41EFD36BAAB3";
const providerId = "Microsoft.MachineLearningServices";
const location = "eastus";
const resourceName = "StandardDv2Family";
const createQuotaRequest = {
properties: {
name: { value: "StandardDv2Family" },
limit: 200,
resourceType: "dedicated",
unit: "Count",
},
};
const credential = new DefaultAzureCredential();
const client = new AzureReservationAPI(credential);
const result = await client.quota.beginCreateOrUpdateAndWait(
subscriptionId,
providerId,
location,
resourceName,
createQuotaRequest
);
console.log(result);
}
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;
using Azure.Core;
using Azure.Identity;
using Azure.ResourceManager;
using Azure.ResourceManager.Reservations;
using Azure.ResourceManager.Reservations.Models;
using Azure.ResourceManager.Resources;
// Generated from example definition: specification/reservations/resource-manager/Microsoft.Capacity/stable/2020-10-25/examples/putMachineLearningServicesQuotaRequestDedicated.json
// this example is just showing the usage of "Quota_CreateOrUpdate" 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 = "D7EC67B3-7657-4966-BFFC-41EFD36BAAB3";
ResourceIdentifier subscriptionResourceId = SubscriptionResource.CreateResourceIdentifier(subscriptionId);
SubscriptionResource subscriptionResource = client.GetSubscriptionResource(subscriptionResourceId);
// get the collection of this ReservationQuotaResource
string providerId = "Microsoft.MachineLearningServices";
AzureLocation location = new AzureLocation("eastus");
ReservationQuotaCollection collection = subscriptionResource.GetAllReservationQuota(providerId, location);
// invoke the operation
string resourceName = "StandardDv2Family";
ReservationQuotaData data = new ReservationQuotaData()
{
Properties = new QuotaProperties()
{
Limit = 200,
Unit = "Count",
ResourceName = new ReservationResourceName()
{
Value = "StandardDv2Family",
},
ResourceTypeName = ResourceTypeName.Dedicated,
},
};
ArmOperation<ReservationQuotaResource> lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, resourceName, data);
ReservationQuotaResource result = lro.Value;
// the variable result is a resource, you could call other operations on this instance as well
// but just for demo, we get its data from this resource instance
ReservationQuotaData resourceData = result.Data;
// for demo we just print out the id
Console.WriteLine($"Succeeded on id: {resourceData.Id}");
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
{
"id": "/subscriptions/D7EC67B3-7657-4966-BFFC-41EFD36BAAB3/providers/Microsoft.Capacity/resourceProviders/Microsoft.MachineLearningServices/locations/eastus/serviceLimitsRequests/2B5C8515-37D8-4B6A-879B-CD641A2CF605",
"name": "2B5C8515-37D8-4B6A-879B-CD641A2CF605",
"type": "Microsoft.Capacity/ServiceLimits",
"properties": {
"provisioningState": "InProgress",
"message": ""
}
}
{
"id": "/subscriptions/D7EC67B3-7657-4966-BFFC-41EFD36BAAB3/providers/Microsoft.Capacity/resourceProviders/Microsoft.MachineLearningServices/locations/eastus/serviceLimitsRequests/2B5C8515-37D8-4B6A-879B-CD641A2CF605",
"name": "2B5C8515-37D8-4B6A-879B-CD641A2CF605",
"type": "Microsoft.Capacity/serviceLimits",
"properties": {
"limit": 200,
"unit": "Count",
"currentValue": 160,
"name": {
"value": "StandardDv2Family",
"localizedValue": "Standard Dv2 Family Cluster Dedicated vCPUs"
},
"resourceType": "dedicated",
"quotaPeriod": "",
"properties": {}
}
}
Sample Request
PUT https://management.azure.com/subscriptions/D7EC67B3-7657-4966-BFFC-41EFD36BAAB3/providers/Microsoft.Capacity/resourceProviders/Microsoft.MachineLearningServices/locations/eastus/serviceLimits/TotalLowPriorityCores?api-version=2020-10-25
{
"properties": {
"limit": 200,
"unit": "Count",
"name": {
"value": "TotalLowPriorityCores"
},
"resourceType": "lowPriority"
}
}
import com.azure.resourcemanager.reservations.models.QuotaProperties;
import com.azure.resourcemanager.reservations.models.ResourceName;
import com.azure.resourcemanager.reservations.models.ResourceType;
/** Samples for Quota CreateOrUpdate. */
public final class Main {
/*
* x-ms-original-file: specification/reservations/resource-manager/Microsoft.Capacity/stable/2020-10-25/examples/putMachineLearningServicesQuotaRequestLowPriority.json
*/
/**
* Sample code: Quotas_Request_PutForMachineLearningServices_LowPriorityResource.
*
* @param manager Entry point to ReservationsManager.
*/
public static void quotasRequestPutForMachineLearningServicesLowPriorityResource(
com.azure.resourcemanager.reservations.ReservationsManager manager) {
manager
.quotas()
.define("TotalLowPriorityCores")
.withExistingLocation("D7EC67B3-7657-4966-BFFC-41EFD36BAAB3", "Microsoft.MachineLearningServices", "eastus")
.withProperties(
new QuotaProperties()
.withLimit(200)
.withUnit("Count")
.withName(new ResourceName().withValue("TotalLowPriorityCores"))
.withResourceType(ResourceType.LOW_PRIORITY))
.create();
}
}
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.reservations import AzureReservationAPI
"""
# PREREQUISITES
pip install azure-identity
pip install azure-mgmt-reservations
# USAGE
python put_machine_learning_services_quota_request_low_priority.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 = AzureReservationAPI(
credential=DefaultAzureCredential(),
)
response = client.quota.begin_create_or_update(
subscription_id="D7EC67B3-7657-4966-BFFC-41EFD36BAAB3",
provider_id="Microsoft.MachineLearningServices",
location="eastus",
resource_name="TotalLowPriorityCores",
create_quota_request={
"properties": {
"limit": 200,
"name": {"value": "TotalLowPriorityCores"},
"resourceType": "lowPriority",
"unit": "Count",
}
},
).result()
print(response)
# x-ms-original-file: specification/reservations/resource-manager/Microsoft.Capacity/stable/2020-10-25/examples/putMachineLearningServicesQuotaRequestLowPriority.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 armreservations_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/reservations/armreservations/v3"
)
// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/1e7b408f3323e7f5424745718fe62c7a043a2337/specification/reservations/resource-manager/Microsoft.Capacity/stable/2020-10-25/examples/putMachineLearningServicesQuotaRequestLowPriority.json
func ExampleQuotaClient_BeginCreateOrUpdate_quotasRequestPutForMachineLearningServicesLowPriorityResource() {
cred, err := azidentity.NewDefaultAzureCredential(nil)
if err != nil {
log.Fatalf("failed to obtain a credential: %v", err)
}
ctx := context.Background()
clientFactory, err := armreservations.NewClientFactory(cred, nil)
if err != nil {
log.Fatalf("failed to create client: %v", err)
}
poller, err := clientFactory.NewQuotaClient().BeginCreateOrUpdate(ctx, "D7EC67B3-7657-4966-BFFC-41EFD36BAAB3", "Microsoft.MachineLearningServices", "eastus", "TotalLowPriorityCores", armreservations.CurrentQuotaLimitBase{
Properties: &armreservations.QuotaProperties{
Name: &armreservations.ResourceName{
Value: to.Ptr("TotalLowPriorityCores"),
},
Limit: to.Ptr[int32](200),
ResourceType: to.Ptr(armreservations.ResourceTypeLowPriority),
Unit: to.Ptr("Count"),
},
}, nil)
if err != nil {
log.Fatalf("failed to finish the request: %v", err)
}
res, err := poller.PollUntilDone(ctx, nil)
if err != nil {
log.Fatalf("failed to pull the result: %v", err)
}
// You could use response here. We use blank identifier for just demo purposes.
_ = res
// If the HTTP response code is 200 as defined in example definition, your response structure would look as follows. Please pay attention that all the values in the output are fake values for just demo purposes.
// res.CurrentQuotaLimitBase = armreservations.CurrentQuotaLimitBase{
// Name: to.Ptr("2B5C8515-37D8-4B6A-879B-CD641A2CF605"),
// Type: to.Ptr("Microsoft.Capacity/serviceLimits"),
// ID: to.Ptr("/subscriptions/D7EC67B3-7657-4966-BFFC-41EFD36BAAB3/providers/Microsoft.Capacity/resourceProviders/Microsoft.MachineLearningServices/locations/eastus/serviceLimitsRequests/2B5C8515-37D8-4B6A-879B-CD641A2CF605"),
// Properties: &armreservations.QuotaProperties{
// Name: &armreservations.ResourceName{
// LocalizedValue: to.Ptr("Total Cluster Low Priority Regional vCPUs"),
// Value: to.Ptr("TotalLowPriorityCores"),
// },
// CurrentValue: to.Ptr[int32](160),
// Limit: to.Ptr[int32](200),
// Properties: map[string]any{
// },
// QuotaPeriod: to.Ptr(""),
// ResourceType: to.Ptr(armreservations.ResourceTypeLowPriority),
// Unit: to.Ptr("Count"),
// },
// }
}
To use the Azure SDK library in your project, see this documentation. To provide feedback on this code sample, open a GitHub issue
const { AzureReservationAPI } = require("@azure/arm-reservations");
const { DefaultAzureCredential } = require("@azure/identity");
/**
* This sample demonstrates how to Create or update the quota (service limits) of a resource to the requested value.
Steps:
1. Make the Get request to get the quota information for specific resource.
2. To increase the quota, update the limit field in the response from Get request to new value.
3. Submit the JSON to the quota request API to update the quota.
The Create quota request may be constructed as follows. The PUT operation can be used to update the quota.
*
* @summary Create or update the quota (service limits) of a resource to the requested value.
Steps:
1. Make the Get request to get the quota information for specific resource.
2. To increase the quota, update the limit field in the response from Get request to new value.
3. Submit the JSON to the quota request API to update the quota.
The Create quota request may be constructed as follows. The PUT operation can be used to update the quota.
* x-ms-original-file: specification/reservations/resource-manager/Microsoft.Capacity/stable/2020-10-25/examples/putMachineLearningServicesQuotaRequestLowPriority.json
*/
async function quotasRequestPutForMachineLearningServicesLowPriorityResource() {
const subscriptionId = "D7EC67B3-7657-4966-BFFC-41EFD36BAAB3";
const providerId = "Microsoft.MachineLearningServices";
const location = "eastus";
const resourceName = "TotalLowPriorityCores";
const createQuotaRequest = {
properties: {
name: { value: "TotalLowPriorityCores" },
limit: 200,
resourceType: "lowPriority",
unit: "Count",
},
};
const credential = new DefaultAzureCredential();
const client = new AzureReservationAPI(credential);
const result = await client.quota.beginCreateOrUpdateAndWait(
subscriptionId,
providerId,
location,
resourceName,
createQuotaRequest
);
console.log(result);
}
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;
using Azure.Core;
using Azure.Identity;
using Azure.ResourceManager;
using Azure.ResourceManager.Reservations;
using Azure.ResourceManager.Reservations.Models;
using Azure.ResourceManager.Resources;
// Generated from example definition: specification/reservations/resource-manager/Microsoft.Capacity/stable/2020-10-25/examples/putMachineLearningServicesQuotaRequestLowPriority.json
// this example is just showing the usage of "Quota_CreateOrUpdate" 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 = "D7EC67B3-7657-4966-BFFC-41EFD36BAAB3";
ResourceIdentifier subscriptionResourceId = SubscriptionResource.CreateResourceIdentifier(subscriptionId);
SubscriptionResource subscriptionResource = client.GetSubscriptionResource(subscriptionResourceId);
// get the collection of this ReservationQuotaResource
string providerId = "Microsoft.MachineLearningServices";
AzureLocation location = new AzureLocation("eastus");
ReservationQuotaCollection collection = subscriptionResource.GetAllReservationQuota(providerId, location);
// invoke the operation
string resourceName = "TotalLowPriorityCores";
ReservationQuotaData data = new ReservationQuotaData()
{
Properties = new QuotaProperties()
{
Limit = 200,
Unit = "Count",
ResourceName = new ReservationResourceName()
{
Value = "TotalLowPriorityCores",
},
ResourceTypeName = ResourceTypeName.LowPriority,
},
};
ArmOperation<ReservationQuotaResource> lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, resourceName, data);
ReservationQuotaResource result = lro.Value;
// the variable result is a resource, you could call other operations on this instance as well
// but just for demo, we get its data from this resource instance
ReservationQuotaData resourceData = result.Data;
// for demo we just print out the id
Console.WriteLine($"Succeeded on id: {resourceData.Id}");
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
{
"id": "/subscriptions/D7EC67B3-7657-4966-BFFC-41EFD36BAAB3/providers/Microsoft.Capacity/resourceProviders/Microsoft.MachineLearningServices/locations/eastus/serviceLimitsRequests/2B5C8515-37D8-4B6A-879B-CD641A2CF605",
"name": "2B5C8515-37D8-4B6A-879B-CD641A2CF605",
"type": "Microsoft.Capacity/ServiceLimits",
"properties": {
"provisioningState": "InProgress",
"message": ""
}
}
{
"id": "/subscriptions/D7EC67B3-7657-4966-BFFC-41EFD36BAAB3/providers/Microsoft.Capacity/resourceProviders/Microsoft.MachineLearningServices/locations/eastus/serviceLimitsRequests/2B5C8515-37D8-4B6A-879B-CD641A2CF605",
"name": "2B5C8515-37D8-4B6A-879B-CD641A2CF605",
"type": "Microsoft.Capacity/serviceLimits",
"properties": {
"limit": 200,
"unit": "Count",
"currentValue": 160,
"name": {
"value": "TotalLowPriorityCores",
"localizedValue": "Total Cluster Low Priority Regional vCPUs"
},
"resourceType": "lowPriority",
"quotaPeriod": "",
"properties": {}
}
}
定义
CurrentQuotaLimitBase
配额属性。
名称 |
类型 |
说明 |
id
|
string
|
配额请求 ID。
|
name
|
string
|
配额请求的名称。
|
properties
|
QuotaProperties
|
资源的配额属性。
|
type
|
string
|
资源的类型。 “Microsoft.Capacity/ServiceLimits”
|
ExceptionResponse
API 错误。
QuotaProperties
资源的配额属性。
名称 |
类型 |
说明 |
currentValue
|
integer
|
资源的当前使用情况值。
|
limit
|
integer
|
配额属性。
|
name
|
ResourceName
|
资源提供程序提供的资源的名称。 将此属性用于 quotaRequests 资源操作。
|
properties
|
object
|
指定资源提供程序的其他属性。
|
quotaPeriod
|
string
|
汇总配额使用情况值的时间段。 例如,每天) P1D (,) 每分钟 PT1M (,) 每 1 秒 PT1S (。 此参数是可选的,因为对于某些资源(例如计算),时间段无关紧要。
|
resourceType
|
ResourceType
|
资源类型的名称。
|
unit
|
string
|
限制单位,如 计数 和 字节数。 使用 GET 配额操作响应中提供的单位字段。
|
QuotaRequestState
配额请求状态。
名称 |
类型 |
说明 |
Accepted
|
string
|
|
Failed
|
string
|
|
InProgress
|
string
|
|
Invalid
|
string
|
|
Succeeded
|
string
|
|
QuotaRequestSubmitResponse201
包含已接受配额请求的请求 ID 的响应。
名称 |
类型 |
说明 |
id
|
string
|
配额请求 ID。 使用 requestId 参数检查请求状态。
|
name
|
string
|
Operation ID
|
properties.message
|
string
|
用户友好消息。
|
properties.provisioningState
|
QuotaRequestState
|
配额请求状态的详细信息。
|
type
|
string
|
资源类型
|
ResourceName
资源提供程序提供的资源名称。 将此属性用于 quotaRequest 参数。
名称 |
类型 |
说明 |
localizedValue
|
string
|
资源显示本地化名称。
|
value
|
string
|
资源名称。
|
ResourceType
资源类型的名称。
名称 |
类型 |
说明 |
dedicated
|
string
|
|
lowPriority
|
string
|
|
serviceSpecific
|
string
|
|
shared
|
string
|
|
standard
|
string
|
|
ServiceError
API 错误详细信息。
ServiceErrorDetail
错误详细信息。
名称 |
类型 |
说明 |
code
|
string
|
错误代码。
|
message
|
string
|
错误消息。
|