Azure / azure-sdk-for-js

This repository is for active development of the Azure SDK for JavaScript (NodeJS & Browser). For consumers of the SDK we recommend visiting our public developer docs at https://docs.microsoft.com/javascript/azure/ or our versioned developer docs at https://azure.github.io/azure-sdk-for-js.
MIT License
2.03k stars 1.19k forks source link

Creating app service plan with custom locations doesn't sent extendedLocation and returns error. #29917

Open ccastrotrejo opened 3 months ago

ccastrotrejo commented 3 months ago

Describe the bug In the Logic Apps vscode extension we use the AppServicePlanCreateStep() to create a new app service plan when creating a new logic app in azure. There is a bug when we want to create a Logic App in a custom location, the api call for the service plan requires the type property in the extendedLocation property in the plan. I could tell that your documentation says that this property is not getting serialized, is there anything I can do to serialize it and not make the API call fail?

To Reproduce Steps to reproduce the behavior:

  1. Execute the Create logic app in azure command from the vscode extension
  2. Select a subscription
  3. Type the name of the Logic app
  4. Select a custom location
  5. Continue doing and filling the prompt steps and it will fail

Expected behavior Should be able to create the hosting plan.

Additional context { code: "InvalidRequestContent", statusCode: 400, request: { url: "https://management.azure.com/subscriptions/<subID>/resourceGroups/<resourceGroup>/providers/Microsoft.Web/serverfarms/testLogicAppHybrid?api-version=2022-03-01", method: "PUT", headers: { _headersMap: { }, }, timeout: 0, withCredentials: false, body: "{\"kind\":\"linux,kubernetes\",\"location\":\"northcentralusstage\",\"sku\":{\"name\":\"K1\",\"tier\":\"Kubernetes\",\"size\":\"K1\",\"family\":\"K\",\"capacity\":1},\"extendedLocation\":{\"name\":\"/subscriptions/<subID>/resourceGroups/<resourceGroup>/providers/Microsoft.ExtendedLocation/customLocations/bectest22\"},\"properties\":{\"perSiteScaling\":true,\"reserved\":true,\"kubeEnvironmentProfile\":{\"id\":\"/subscriptions/<subId>/resourceGroups/bectest22/providers/Microsoft.Web/kubeEnvironments/bectest22-kubeenv\"}}}", multipartBody: undefined, formData: undefined, streamResponseStatusCodes: { }, enableBrowserStreams: false, proxySettings: undefined, disableKeepAlive: false, abortSignal: undefined, requestId: "a09b2e3b-3f85-409b-88a0-68ee25e28af2", tracingOptions: undefined, allowInsecureConnection: false, onUploadProgress: undefined, onDownloadProgress: undefined, }, response: { status: 400, headers: { _headersMap: { }, }, request: { url: "https://management.azure.com/subscriptions<subId>/resourceGroups/<resourceGroup>/providers/Microsoft.Web/serverfarms/testLogicAppHybrid?api-version=2022-03-01", method: "PUT", headers: { _headersMap: { }, }, timeout: 0, withCredentials: false, body: "{\"kind\":\"linux,kubernetes\",\"location\":\"northcentralusstage\",\"sku\":{\"name\":\"K1\",\"tier\":\"Kubernetes\",\"size\":\"K1\",\"family\":\"K\",\"capacity\":1},\"extendedLocation\":{\"name\":\"/subscriptions/<subId>/resourceGroups/<resourceGroup>/providers/Microsoft.ExtendedLocation/customLocations/bectest22\"},\"properties\":{\"perSiteScaling\":true,\"reserved\":true,\"kubeEnvironmentProfile\":{\"id\":\"/subscriptions/<subId>/resourceGroups/<resourceGroup>/providers/Microsoft.Web/kubeEnvironments/bectest22-kubeenv\"}}}", multipartBody: undefined, formData: undefined, streamResponseStatusCodes: { }, enableBrowserStreams: false, proxySettings: undefined, disableKeepAlive: false, abortSignal: undefined, requestId: "a09b2e3b-3f85-409b-88a0-68ee25e28af2", tracingOptions: undefined, allowInsecureConnection: false, onUploadProgress: undefined, onDownloadProgress: undefined, }, bodyAsText: "{\"error\":{\"code\":\"InvalidRequestContent\",\"message\":\"The request content was invalid and could not be deserialized: 'Required property 'type' not found in JSON. Path 'extendedLocation', line 1, position 307.'.\"}}", parsedBody: { error: { code: "InvalidRequestContent", message: "The request content was invalid and could not be deserialized: 'Required property 'type' not found in JSON. Path 'extendedLocation', line 1, position 307.'.", }, }, }, details: { error: { code: "InvalidRequestContent", message: "The request content was invalid and could not be deserialized: 'Required property 'type' not found in JSON. Path 'extendedLocation', line 1, position 307.'.", }, }, name: "RestError", }

jeremymeng commented 2 months ago

@ccastrotrejo thank you for reporting this issue! Could you please kindly add the @azure/arm-* package names that you are using?

ccastrotrejo commented 2 months ago

Hi @jeremymeng sure, we are using these 3 "@azure/arm-appservice": "^13.0.3", "@azure/arm-appinsights": "^5.0.0-beta.7", "@azure/arm-storage": "17.2.1",

kazrael2119 commented 2 months ago

will check

kazrael2119 commented 2 months ago

@ccastrotrejo , sorry for the later reply , could you updrade the version of @azure/arm-appservice and @azure/arm-storage and try again? these are the latest stable versions of these two package: https://www.npmjs.com/package/@azure/arm-storage/v/18.2.0 https://www.npmjs.com/package/@azure/arm-appservice/v/14.1.0

I will go ahead to check this issue.

kazrael2119 commented 2 months ago

I see in sdk code https://github.com/Azure/azure-sdk-for-js/blob/main/sdk/appservice/arm-appservice/src/models/index.ts#L1459, it is readonly and it will not be serialized. but in your description, looks like type is required parameter in the request body, but SDK is generated from swagger, in swagger, it is defined as readonly https://github.com/Azure/azure-rest-api-specs/blob/main/specification/web/resource-manager/Microsoft.Web/stable/2023-12-01/CommonDefinitions.json#L1566, so sdk will not seserialize this parameter

kazrael2119 commented 2 months ago

azure-arm-appservice-15.0.0.zip I tried to remove readonly and regenerate this package, could you try to use this one and try again?

ccastrotrejo commented 2 months ago

Sure, thanks. I will be OOF next week, but I will give it a try the week after that