public void Test_ComputeSkusPutRequestFailedDueToQuotaReduction() { HttpMockServer.RecordsDirectory = GetSessionsDirectoryPath(); var newQuotaLimit = new CurrentQuotaLimitBase() { Properties = new QuotaProperties() { Limit = 2, Name = new ResourceName() { Value = SKUName } } }; try { using (MockContext context = MockContext.Start(this.GetType())) { var reservationsClient = ReservationsTestUtilities.GetAzureReservationAPIClient( context, new RecordedDelegatingHandler { StatusCodeToReturn = HttpStatusCode.Created }); var quotaResponse = reservationsClient.Quota.CreateOrUpdate(QuotaSubscriptionId, ComputeProviderId, LocationWUS, newQuotaLimit.Properties.Name.Value, newQuotaLimit); System.Diagnostics.Trace.TraceInformation($"Response: {quotaResponse}"); } } catch (CloudException ex) { System.Diagnostics.Trace.TraceInformation($"Exception: {ex}"); Assert.Contains("Request failed.", ex.ToString()); } }
public void Test_BatchMLTotalLowPriorityCoresPutRequestFailedDueToQuotaReduction() { HttpMockServer.RecordsDirectory = GetSessionsDirectoryPath(); var newQuotaLimit = new CurrentQuotaLimitBase() { Properties = new QuotaProperties() { Limit = 2, Name = new ResourceName() { Value = "TotalLowPriorityCores" }, ResourceType = "lowPriority" } }; try { using (MockContext context = MockContext.Start(this.GetType())) { var reservationsClient = ReservationsTestUtilities.GetAzureReservationAPIClient( context, new RecordedDelegatingHandler { StatusCodeToReturn = HttpStatusCode.Created }); var quotaResponse = reservationsClient.Quota.CreateOrUpdate(QuotaSubscriptionId, BatchMLProviderId, LocationWUS, newQuotaLimit.Properties.Name.Value, newQuotaLimit); } } catch (CloudException ex) { Assert.Contains("Quota reduction is not supported", ex.ToString()); } }
public void Test_BatchMLBadResourceIdPutRequestFailed() { HttpMockServer.RecordsDirectory = GetSessionsDirectoryPath(); var badResourceId = "badResId"; var newQuotaLimit = new CurrentQuotaLimitBase() { Properties = new QuotaProperties() { Limit = 2000, Name = new ResourceName() { Value = badResourceId }, ResourceType = "lowPriority" } }; try { using (MockContext context = MockContext.Start(this.GetType())) { var reservationsClient = ReservationsTestUtilities.GetAzureReservationAPIClient( context, new RecordedDelegatingHandler { StatusCodeToReturn = HttpStatusCode.BadRequest }); var quotaResponse = reservationsClient.Quota.CreateOrUpdate(QuotaSubscriptionId, BatchMLProviderId, LocationWUS, newQuotaLimit.Properties.Name.Value, newQuotaLimit); } } catch (CloudException ex) { Assert.True(ex.Response.StatusCode == HttpStatusCode.BadRequest); Assert.Contains("BadRequest", ex.ToString()); } catch (ExceptionResponseException ex) { Assert.True(ex.Response.StatusCode == HttpStatusCode.BadRequest); } }
/// <summary> /// Update the service limits (quota) of a resource to 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 Update quota request may be constructed as follows. The PATCH operation /// can be used to update the quota. /// </summary> /// <param name='operations'> /// The operations group for this extension method. /// </param> /// <param name='subscriptionId'> /// Azure subscription id. /// </param> /// <param name='providerId'> /// Azure resource provider id. /// </param> /// <param name='location'> /// Azure region. /// </param> /// <param name='resourceName'> /// The resource name for a resource provider, such as SKU name for /// Microsoft.Compute, Sku or TotalLowPriorityCores for /// Microsoft.MachineLearningServices /// </param> /// <param name='createQuotaRequest'> /// Quota requests payload. /// </param> /// <param name='cancellationToken'> /// The cancellation token. /// </param> public static async Task <object> BeginUpdateAsync(this IQuotaOperations operations, string subscriptionId, string providerId, string location, string resourceName, CurrentQuotaLimitBase createQuotaRequest, CancellationToken cancellationToken = default(CancellationToken)) { using (var _result = await operations.BeginUpdateWithHttpMessagesAsync(subscriptionId, providerId, location, resourceName, createQuotaRequest, null, cancellationToken).ConfigureAwait(false)) { return(_result.Body); } }
/// <summary> /// Update the service limits (quota) of a resource to 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 Update quota request may be constructed as follows. The PATCH operation /// can be used to update the quota. /// </summary> /// <param name='operations'> /// The operations group for this extension method. /// </param> /// <param name='subscriptionId'> /// Azure subscription id. /// </param> /// <param name='providerId'> /// Azure resource provider id. /// </param> /// <param name='location'> /// Azure region. /// </param> /// <param name='resourceName'> /// The resource name for a resource provider, such as SKU name for /// Microsoft.Compute, Sku or TotalLowPriorityCores for /// Microsoft.MachineLearningServices /// </param> /// <param name='createQuotaRequest'> /// Quota requests payload. /// </param> public static object BeginUpdate(this IQuotaOperations operations, string subscriptionId, string providerId, string location, string resourceName, CurrentQuotaLimitBase createQuotaRequest) { return(operations.BeginUpdateAsync(subscriptionId, providerId, location, resourceName, createQuotaRequest).GetAwaiter().GetResult()); }