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.07k stars 1.19k forks source link

[arm-dns] Client hangs when trying to create recordSet #6152

Closed SkyaTura closed 4 years ago

SkyaTura commented 4 years ago

Describe the bug DnsManagementClient won't createOrUpdate a recordSet.

When trying to use recordSets.createOrUpdate() method, the client hangs for a while and then throws an InternalServerError.

While this may be related with #420, it's important to notice that, for me, other methods like get and list works fine. Only recordSets.createOrUpdate() is failing.

To Reproduce Steps to reproduce the behavior:

  1. Create a new project with npm init
  2. Install both @azure/ms-rest-nodeatuh and @azure/arm-dns
  3. Create the index.js file
    
    import * as msRestNodeAuth from "@azure/ms-rest-nodeauth";
    import { DnsManagementClient } from "@azure/arm-dns";
    const subscriptionId = process.env["AZURE_SUBSCRIPTION_ID"];

msRestNodeAuth.interactiveLogin().then((creds) => { const client = new DnsManagementClient(creds, subscriptionId); const resourceGroupName = "testresourceGroupName"; const zoneName = "testzoneName"; const relativeRecordSetName = "testrelativeRecordSetName"; const recordType = "TXT"; const parameters = { TTL: 5, TXTRecords: [{ value: ['test'] }], }; client.recordSets.set( resourceGroupName, zoneName, relativeRecordSetName, recordType, parameters ).then((result) => { console.log("The result is:"); console.log(result); }); }).catch((err) => { console.error(err); });

4. Define your subcription id as environmental variable
5. Run the application with `node`

**Expected behavior**
The record set with relative path `testrelativeRecordSetName` and type `TXT` to be created on the DNS Zone with name `testzoneName` and resource group `testresourceGroupName` at my subscription.

**Additional context**
Error log:
```javascript
{ Error: {"code":"InternalServerError","message":""}
    at new RestError (XXX/node_modules/@azure/ms-rest-js/lib/restError.ts:18:5)
    at XXX/node_modules/@azure/ms-rest-js/lib/policies/deserializationPolicy.ts:117:27
    at process._tickCallback (internal/process/next_tick.js:68:7)
  code: 'InternalServerError',
  statusCode: 500,
  request:
   WebResource {
     streamResponseBody: false,
     url:
      'https://management.azure.com/subscriptions/XXX/resourceGroups/XXX/providers/Microsoft.Network/dnsZones/XXX/TXT/teste?api-version=2018-05-01',
     method: 'PUT',
     headers: HttpHeaders { _headersMap: [Object] },
     body: '{}',
     query: undefined,
     formData: undefined,
     withCredentials: false,
     abortSignal: undefined,
     timeout: 0,
     onUploadProgress: undefined,
     onDownloadProgress: undefined,
     proxySettings: undefined,
     operationSpec:
      { httpMethod: 'PUT',
        path:
         'subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Network/dnsZones/{zoneName}/{recordType}/{relativeRecordSetName}',
        urlParameters: [Array],
        queryParameters: [Array],
        headerParameters: [Array],
        requestBody: [Object],
        responses: [Object],
        serializer: [Serializer] } },
  response:
   { body: '{"code":"InternalServerError","message":""}',
     headers: HttpHeaders { _headersMap: [Object] },
     status: 500 },
  body: { code: 'InternalServerError', message: '' },
  innerError:
   { Error: {"code":"InternalServerError","message":""}
       at new RestError (XXX/node_modules/@azure/ms-rest-js/lib/restError.ts:18:5)
       at XXX/node_modules/@azure/ms-rest-js/lib/policies/deserializationPolicy.ts:117:27
       at process._tickCallback (internal/process/next_tick.js:68:7)
     code: 'InternalServerError',
     statusCode: 500,
     request:
      WebResource {
        streamResponseBody: false,
        url:
         'https://management.azure.com/subscriptions/XXX/resourceGroups/XXX/providers/Microsoft.Network/dnsZones/XXX/TXT/teste?api-version=2018-05-01',
        method: 'PUT',
        headers: [HttpHeaders],
        body: '{}',
        query: undefined,
        formData: undefined,
        withCredentials: false,
        abortSignal: undefined,
        timeout: 0,
        onUploadProgress: undefined,
        onDownloadProgress: undefined,
        proxySettings: undefined,
        operationSpec: [Object] },
     response:
      { body: '{"code":"InternalServerError","message":""}',
        headers: [HttpHeaders],
        status: 500 },
     body: { code: 'InternalServerError', message: '' },
     innerError:
      { Error: {"code":"InternalServerError","message":""}
          at new RestError (XXX/node_modules/@azure/ms-rest-js/lib/restError.ts:18:5)
          at XXX/node_modules/@azure/ms-rest-js/lib/policies/deserializationPolicy.ts:117:27
          at process._tickCallback (internal/process/next_tick.js:68:7)
        code: 'InternalServerError',
        statusCode: 500,
        request: [WebResource],
        response: [Object],
        body: [Object] } } }
ghost commented 4 years ago

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

sfiguemsft commented 4 years ago

@KarenHammons @rohinkoul can you look into this please?

sfiguemsft commented 4 years ago

@karravi-msft looks like the operation is failing with a 5xx error which can be due to problems in ARM or DNS frontend - can you look into this please?

qiaozha commented 4 years ago

@SkyaTura I think your parameters definition is not right. you can refer to line 270 to 453 of sdk/dns/arm-dns/src/models/mappers.ts. parameters here should have common properties of a RecordSet. So I changed the parameters properties TTL to tTL, TXTRecords to txtRecords and found it succeeded.

SkyaTura commented 4 years ago

I'll check it as soon as possible, but in that case, the error shouldn't be 4xx?

qiaozha commented 4 years ago

I feel that's strange too, but I did change the parameter properties and it works for me. If problem still exists, I need to involve relevant team to take a look.

SkyaTura commented 4 years ago

I've tried as you said and that worked fine.

ghost commented 4 years ago

Thanks for working with Microsoft on GitHub! Tell us how you feel about your experience using the reactions on this comment.