ms-rest-azure served as the foundational client runtime for Node.js Azure client libraries generated using the AutoRest toolchain. It provided essential infrastructure for handling HTTP requests, error responses, tracing, and Azure-specific authentication mechanisms such as Device Token, Service Principal, and Managed Identity. The package (version 3.0.2, last published approximately four years ago) was part of the older `azure-sdk-for-node` repository. As of March 2023, this package, along with many others in its repository, has been officially deprecated. The Azure SDK team has transitioned to a new generation of SDKs (`@azure/*` packages) that offer isomorphic capabilities (browser and Node.js support), consistent design guidelines, and native TypeScript support. Users are strongly encouraged to migrate to the newer `@azure/core-client` and `@azure/identity` packages for modern Azure development.
npm install ms-rest-azureVerified import paths — ran on the pinned version, not inferred.
Demonstrates authenticating with Azure using a service principal and listing subscriptions, typical for older SDK clients.
Migrate to the modern Azure SDK for JavaScript/TypeScript. Specifically, for authentication, use `@azure/identity` (e.g., `DefaultAzureCredential`). For client functionality, use `@azure/core-client` or service-specific `@azure/*` client libraries.
Replace calls to `ms-rest-azure` authentication functions with their counterparts in `@azure/identity`. For instance, `new ClientSecretCredential(tenantId, clientId, clientSecret)` instead of `loginWithServicePrincipalSecret`.
If you must use this package in an ESM context, consider using a build tool to transpile, or convert your project to CJS. However, the recommended fix is to migrate to the newer `@azure/*` packages which offer full ESM support.
Ensure your Node.js environment is version 6.10 or newer. Ideally, use a currently supported Node.js LTS version for security and compatibility with modern libraries.
Ensure that the credential object matches the expected interface of the client library. If using `ms-rest-azure` based clients, use `ms-rest-azure` or `@azure/ms-rest-nodeauth` credentials. If using modern `@azure/*` clients, use `@azure/identity` credentials. Avoid mixing credential types across different SDK generations.
Verify correct installation (`npm install ms-rest-azure`) and import syntax. For CommonJS, ensure `const msRestAzure = require('ms-rest-azure');` and then `msRestAzure.loginWithServicePrincipalSecret`. For ESM, use `import * as msRestAzure from 'ms-rest-azure';` or named imports `import { loginWithServicePrincipalSecret } from 'ms-rest-azure';`. If still problematic, consider migrating to `@azure/identity`.