Azure-sdk-for-js: Cannot use @azure/ms-rest-nodeauth loginWithServicePrincipalSecret for @azure/arm-sqlvirtualmachine

Created on 11 Sep 2020  路  5Comments  路  Source: Azure/azure-sdk-for-js

  • Package Name: @azure/arm-sqlvirtualmachine
  • Package Version: @azure/[email protected], @azure/[email protected]
  • Operating system: linux, macOS
  • [x] nodejs

    • version: v12.17.0

  • [ ] browser

    • name/version:

  • [x] typescript

    • version: v4.0.2

  • Is the bug related to documentation in

Describe the bug
A clear and concise description of what the bug is.

Repro Code:

import { loginWithServicePrincipalSecret } from "@azure/ms-rest-nodeauth";
import { SqlVirtualMachineManagementClient } from "@azure/arm-sqlvirtualmachine";

async function run() {
  const creds = await loginWithServicePrincipalSecret(
    "",
    "",
    ""
  );
  const client = new SqlVirtualMachineManagementClient(creds, "");
}
Argument of type 'ApplicationTokenCredentials' is not assignable to parameter of type 'ServiceClientCredentials'.
  Types of property 'signRequest' are incompatible.
    Type '(webResource: import("/Users/hdavidzhu/azure-vm-test/node_modules/@azure/ms-rest-js/es/lib/webResource").WebResource) => Promise<import("/Users/hdavidzhu/azure-vm-test/node_modules/@azure/ms-rest-js/es/lib/webResource").WebResource>' is not assignable to type '(webResource: import("/Users/hdavidzhu/azure-vm-test/node_modules/@azure/arm-sqlvirtualmachine/node_modules/@azure/ms-rest-js/es/lib/webResource").WebResource) => Promise<import("/Users/hdavidzhu/azure-vm-test/node_modules/@azure/arm-sqlvirtualmachine/node_modules/@azure/ms-rest-js/es/lib/webResource").WebResource>'.
      Types of parameters 'webResource' and 'webResource' are incompatible.
        Type 'import("/Users/hdavidzhu/azure-vm-test/node_modules/@azure/arm-sqlvirtualmachine/node_modules/@azure/ms-rest-js/es/lib/webResource").WebResource' is not assignable to type 'import("/Users/hdavidzhu/azure-vm-test/node_modules/@azure/ms-rest-js/es/lib/webResource").WebResource'.
          Types of property 'shouldDeserialize' are incompatible.
            Type 'boolean | ((response: import("/Users/hdavidzhu/azure-vm-test/node_modules/@azure/arm-sqlvirtualmachine/node_modules/@azure/ms-rest-js/es/lib/httpOperationResponse").HttpOperationResponse) => boolean)' is not assignable to type 'boolean | ((response: import("/Users/hdavidzhu/azure-vm-test/node_modules/@azure/ms-rest-js/es/lib/httpOperationResponse").HttpOperationResponse) => boolean)'.
              Type '(response: HttpOperationResponse) => boolean' is not assignable to type 'boolean | ((response: HttpOperationResponse) => boolean)'.
                Type '(response: import("/Users/hdavidzhu/azure-vm-test/node_modules/@azure/arm-sqlvirtualmachine/node_modules/@azure/ms-rest-js/es/lib/httpOperationResponse").HttpOperationResponse) => boolean' is not assignable to type '(response: import("/Users/hdavidzhu/azure-vm-test/node_modules/@azure/ms-rest-js/es/lib/httpOperationResponse").HttpOperationResponse) => boolean'.
                  Types of parameters 'response' and 'response' are incompatible.
                    Type 'import("/Users/hdavidzhu/azure-vm-test/node_modules/@azure/ms-rest-js/es/lib/httpOperationResponse").HttpOperationResponse' is not assignable to type 'import("/Users/hdavidzhu/azure-vm-test/node_modules/@azure/arm-sqlvirtualmachine/node_modules/@azure/ms-rest-js/es/lib/httpOperationResponse").HttpOperationResponse'.
                      The types of 'request.headers' are incompatible between these types.
                        Property '_headersMap' is missing in type 'HttpHeadersLike' but required in type 'HttpHeaders'.

To Reproduce
Steps to reproduce the behavior:

  1. Install the above packages
  2. Try to use the creds in the client

Expected behavior
A clear and concise description of what you expected to happen.

The client should accept the credentials.

Screenshots
If applicable, add screenshots to help explain your problem.

image

Additional context
Add any other context about the problem here.

From https://github.com/Azure/azure-sdk-for-js/issues/6368, it looks like @azure/arm-sqlvirtualmachine works with @azure/ms-rest-nodeauth@2, but I'm using v3 for all my other clients.

Mgmt SQL - VM customer-reported needs-team-attention question

All 5 comments

Thanks for reporting @hdavidzhu!

@qiaozha, Can we have the package re-generated using the latest v4 of the code generator to fix this?

@ramya-rao-a Hi, I have a PR #11252 to fix this issue. Could you please help review it? Thanks

@hdavidzhu Could you please try https://www.npmjs.com/package/@azure/arm-sqlvirtualmachine/v/4.0.0. This should resolve your problem. Thanks

Will do, thanks! (I'll report back later today.)

Looks like it worked! Thank you for all your help.

Was this page helpful?
0 / 5 - 0 ratings