azure-sdk-for-net icon indicating copy to clipboard operation
azure-sdk-for-net copied to clipboard

[BUG] Azure.ResourceManager.AppService - Error when updating `AppServicePlanResource` - Missing `Sku` on `AppServicePlanPatch`

Open thomhurst opened this issue 2 years ago • 1 comments
trafficstars

Library name and version

Azure.ResourceManager.AppService 1.0.0

Describe the bug

Trying to update an AppServicePlanResource with an AppServicePlanPatch fails with exception of missing Sku.

However Sku isn't an available property on AppServicePlanPatch so can't be added to the request.

Expected behavior

Either the request succeeds, or the AppServicePlanPatch has a Sku property that can be populated

Actual behavior

Exception:

Azure.RequestFailedException: Service request failed.
Status: 400 (Bad Request)

Content:
{"Code":"BadRequest","Message":"The parameter SKU cannot be null.","Target":null,"Details":[{"Message":"The parameter SKU cannot be null."},{"Code":"BadRequest"},{"ErrorEntity":{"MessageTemplate":"The parameter {0} cannot be null.","Parameters":["SKU"],"Code":"BadRequest","Message":"The parameter SKU cannot be null."}}],"Innererror":null}

Headers:
Cache-Control: no-cache
Pragma: no-cache
Strict-Transport-Security: REDACTED
Server: Microsoft-IIS/10.0
X-AspNet-Version: REDACTED
X-Powered-By: REDACTED
x-ms-ratelimit-remaining-subscription-writes: REDACTED
x-ms-request-id: 0b57d6b7-8179-489a-8a3a-0041dbcac1b8
x-ms-correlation-request-id: REDACTED
x-ms-routing-request-id: REDACTED
X-Content-Type-Options: REDACTED
Date: Fri, 17 Feb 2023 11:21:29 GMT
Content-Length: 340
Content-Type: application/json; charset=utf-8
Expires: -1

   at Azure.ResourceManager.AppService.AppServicePlansRestOperations.UpdateAsync(String subscriptionId, String resourceGroupName, String name, AppServicePlanPatch patch, CancellationToken cancellationToken)
   at Azure.ResourceManager.AppService.AppServicePlanResource.UpdateAsync(AppServicePlanPatch patch, CancellationToken cancellationToken)
   at MyApp.Core.Scaling.AppService.AppServiceElasticPremiumScalingHandler.Scale(ResourceIdentifier resourceIdentifier, AppServiceElasticPremiumScalingDefinition scalingDefinition, ScaleScheduleInstruction scaleScheduleInstruction) in C:\git\MyApp.Core.Scaling\MyApp.Core.Scaling.AppService\AppServiceElasticPremiumScalingHandler.cs:line 41

Reproduction Steps

        var armClient = new ArmClient(new DefaultAzureCredential());

        var appServicePlan = await armClient.GetAppServicePlanResource(new ResourceIdentifier("azure-resource-id")).GetAsync();
        
        var appServicePlanData = appServicePlan.Value.Data;
        
        var patchRequest = new AppServicePlanPatch
        {
            MaximumElasticWorkerCount = 10,
            
            TargetWorkerCount = appServicePlanData.TargetWorkerCount,
            HostingEnvironmentProfile = appServicePlanData.HostingEnvironmentProfile,
            Kind = appServicePlanData.Kind,
            IsReserved = appServicePlanData.IsReserved,
            IsSpot = appServicePlanData.IsSpot,
            IsXenon = appServicePlanData.IsXenon,
            IsHyperV = appServicePlanData.IsHyperV,
            IsZoneRedundant = appServicePlanData.IsZoneRedundant,
            KubeEnvironmentProfile = appServicePlanData.KubeEnvironmentProfile,
            SpotExpirationOn = appServicePlanData.SpotExpireOn,
            WorkerTierName = appServicePlanData.WorkerTierName,
            IsElasticScaleEnabled = appServicePlanData.IsElasticScaleEnabled,
            IsPerSiteScaling = appServicePlanData.IsPerSiteScaling,
            TargetWorkerSizeId = appServicePlanData.TargetWorkerSizeId,
            FreeOfferExpirationOn = appServicePlanData.FreeOfferExpireOn
        };

        await appServicePlan.Value.UpdateAsync(patchRequest);

Environment

.NET 7 Windows 10

thomhurst avatar Feb 17 '23 11:02 thomhurst

Thank you for your feedback. Tagging and routing to the team member best able to assist.

jsquire avatar Feb 17 '23 13:02 jsquire

Thank you for the issue! We believe this is a service side issue and we will call the corresponding team member to take a look at this.

In the meantime, you could also use CreateOrUpdate method to update your AppServicePlan, because this will be a override, do remember to fetch the existing data to your side, change it, and then put it back to CreateOrUpdate on the collection.

ArcturusZhang avatar Feb 18 '23 01:02 ArcturusZhang

Thanks for the feedback! We are routing this to the appropriate team for follow-up. cc @antcp, @AzureAppServiceCLI.

Issue Details

Library name and version

Azure.ResourceManager.AppService 1.0.0

Describe the bug

Trying to update an AppServicePlanResource with an AppServicePlanPatch fails with exception of missing Sku.

However Sku isn't an available property on AppServicePlanPatch so can't be added to the request.

Expected behavior

Either the request succeeds, or the AppServicePlanPatch has a Sku property that can be populated

Actual behavior

Exception:

Azure.RequestFailedException: Service request failed.
Status: 400 (Bad Request)

Content:
{"Code":"BadRequest","Message":"The parameter SKU cannot be null.","Target":null,"Details":[{"Message":"The parameter SKU cannot be null."},{"Code":"BadRequest"},{"ErrorEntity":{"MessageTemplate":"The parameter {0} cannot be null.","Parameters":["SKU"],"Code":"BadRequest","Message":"The parameter SKU cannot be null."}}],"Innererror":null}

Headers:
Cache-Control: no-cache
Pragma: no-cache
Strict-Transport-Security: REDACTED
Server: Microsoft-IIS/10.0
X-AspNet-Version: REDACTED
X-Powered-By: REDACTED
x-ms-ratelimit-remaining-subscription-writes: REDACTED
x-ms-request-id: 0b57d6b7-8179-489a-8a3a-0041dbcac1b8
x-ms-correlation-request-id: REDACTED
x-ms-routing-request-id: REDACTED
X-Content-Type-Options: REDACTED
Date: Fri, 17 Feb 2023 11:21:29 GMT
Content-Length: 340
Content-Type: application/json; charset=utf-8
Expires: -1

   at Azure.ResourceManager.AppService.AppServicePlansRestOperations.UpdateAsync(String subscriptionId, String resourceGroupName, String name, AppServicePlanPatch patch, CancellationToken cancellationToken)
   at Azure.ResourceManager.AppService.AppServicePlanResource.UpdateAsync(AppServicePlanPatch patch, CancellationToken cancellationToken)
   at MyApp.Core.Scaling.AppService.AppServiceElasticPremiumScalingHandler.Scale(ResourceIdentifier resourceIdentifier, AppServiceElasticPremiumScalingDefinition scalingDefinition, ScaleScheduleInstruction scaleScheduleInstruction) in C:\git\MyApp.Core.Scaling\MyApp.Core.Scaling.AppService\AppServiceElasticPremiumScalingHandler.cs:line 41

Reproduction Steps

        var armClient = new ArmClient(new DefaultAzureCredential());

        var appServicePlan = await armClient.GetAppServicePlanResource(new ResourceIdentifier("azure-resource-id")).GetAsync();
        
        var appServicePlanData = appServicePlan.Value.Data;
        
        var patchRequest = new AppServicePlanPatch
        {
            MaximumElasticWorkerCount = 10,
            
            TargetWorkerCount = appServicePlanData.TargetWorkerCount,
            HostingEnvironmentProfile = appServicePlanData.HostingEnvironmentProfile,
            Kind = appServicePlanData.Kind,
            IsReserved = appServicePlanData.IsReserved,
            IsSpot = appServicePlanData.IsSpot,
            IsXenon = appServicePlanData.IsXenon,
            IsHyperV = appServicePlanData.IsHyperV,
            IsZoneRedundant = appServicePlanData.IsZoneRedundant,
            KubeEnvironmentProfile = appServicePlanData.KubeEnvironmentProfile,
            SpotExpirationOn = appServicePlanData.SpotExpireOn,
            WorkerTierName = appServicePlanData.WorkerTierName,
            IsElasticScaleEnabled = appServicePlanData.IsElasticScaleEnabled,
            IsPerSiteScaling = appServicePlanData.IsPerSiteScaling,
            TargetWorkerSizeId = appServicePlanData.TargetWorkerSizeId,
            FreeOfferExpirationOn = appServicePlanData.FreeOfferExpireOn
        };

        await appServicePlan.Value.UpdateAsync(patchRequest);

Environment

.NET 7 Windows 10

Author: thomhurst
Assignees: xboxeer
Labels:

App Services, Service Attention, Mgmt, customer-reported, question, needs-team-attention

Milestone: -

ghost avatar Feb 18 '23 01:02 ghost