Registry / azure / ms-rest-azure

ms-rest-azure

JSON →
library3.0.2jsnpmunverified

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-azure
INSTALL
IMPORT
SIG · MS-REST-AZURE
M
ms-rest-azure
azurejavascriptv3.0.2
Install
Import
Disk
Pass rate
0/ 6
Env Coverage0 / 6
glibc
1822
musl
1822
Install & Compatibility
Where this runs
tested against v? · npm install
Install × environment matrix
Each cell = how many times install + import succeeded across repeated harness runs. Partial = flaky.
glibc = Debian/Ubuntu slim · musl = Alpine Linux
musl
node 18226 runs
build_error
glibc
node 18226 runs
build_error
Code
Verified usage

Verified import paths — ran on the pinned version, not inferred.

loginWithServicePrincipalSecret
import { loginWithServicePrincipalSecret } from 'ms-rest-azure';
const { loginWithServicePrincipalSecret } = require('ms-rest-azure');
While this pattern works, prefer ESM imports. Note that authentication functions have largely moved to @azure/ms-rest-nodeauth and then @azure/identity in the modern SDK.
DeviceTokenCredentials
import { DeviceTokenCredentials } from 'ms-rest-azure';
const { DeviceTokenCredentials } = require('ms-rest-azure');
Used for interactive login flows. This functionality, like other authentication methods, has been migrated to @azure/ms-rest-nodeauth and ultimately to @azure/identity in the newer Azure SDKs.
AzureServiceClient
import { AzureServiceClient } from 'ms-rest-azure';
const { AzureServiceClient } = require('ms-rest-azure');
The base client for interacting with Azure services. In the modern SDK, this is largely replaced by `@azure/core-client`.

Demonstrates authenticating with Azure using a service principal and listing subscriptions, typical for older SDK clients.

import { loginWithServicePrincipalSecret } from 'ms-rest-azure'; import { SubscriptionClient } from '@azure/arm-subscriptions'; // Example: using a client that depends on ms-rest-azure const clientId = process.env.AZURE_CLIENT_ID ?? ''; const secret = process.env.AZURE_CLIENT_SECRET ?? ''; const domain = process.env.AZURE_TENANT_ID ?? ''; // Also known as tenantId const subscriptionId = process.env.AZURE_SUBSCRIPTION_ID ?? ''; async function authenticateAndListSubscriptions() { if (!clientId || !secret || !domain || !subscriptionId) { console.error('Please set AZURE_CLIENT_ID, AZURE_CLIENT_SECRET, AZURE_TENANT_ID, and AZURE_SUBSCRIPTION_ID environment variables.'); return; } try { console.log('Attempting to log in with Service Principal...'); const credentials = await loginWithServicePrincipalSecret(clientId, secret, domain); console.log('Successfully authenticated.'); const client = new SubscriptionClient(credentials); const subscriptions = await client.subscriptions.list(); console.log('Azure Subscriptions:'); for await (const sub of subscriptions) { console.log(`- ${sub.displayName} (${sub.subscriptionId})`); } } catch (err) { console.error('Authentication or API call failed:', err); } } authenticateAndListSubscriptions();
Debug
Known issues
breakingThe `ms-rest-azure` package was officially deprecated as of March 2023, along with many other packages in the `azure-sdk-for-node` repository. It no longer receives active development, new features, or security updates. Users should migrate to the new Azure SDK for JavaScript/TypeScript packages (`@azure/*`).
fix
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.
affects: >=3.0.0
deprecatedAuthentication methods like `loginWithServicePrincipalSecret` and `interactiveLogin` were initially moved from `ms-rest-azure` to `@azure/ms-rest-nodeauth` to support isomorphic libraries. `@azure/ms-rest-nodeauth` itself is now deprecated in favor of `@azure/identity`.
fix
Replace calls to `ms-rest-azure` authentication functions with their counterparts in `@azure/identity`. For instance, `new ClientSecretCredential(tenantId, clientId, clientSecret)` instead of `loginWithServicePrincipalSecret`.
affects: >=3.0.0
gotcha`ms-rest-azure` was primarily designed for Node.js and CommonJS (CJS) environments as part of the older Azure SDKs. Modern JavaScript development often uses ECMAScript Modules (ESM), which can lead to compatibility issues when mixing `require()` and `import` statements or running in pure ESM projects.
fix
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.
affects: >=3.0.0
gotchaVersions of `ms-rest-azure` (via its dependency `ms-rest`) require Node.js version 6.10 or higher. Running on older Node.js environments will result in compatibility errors due to ES6 syntax and features introduced in those versions.
fix
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.
affects: <3.0.0
Errors
Common errors & fixes
Error: credentials argument needs to implement signRequest method
This error often occurs when an incompatible credential object is passed to a client library, frequently due to mixing versions of `@azure/ms-rest-nodeauth` or `ms-rest-azure` or attempting to use a modern `@azure/identity` credential with an older client.
fix
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.
TypeError: msRestAzure.loginWithServicePrincipalSecret is not a function
This error can occur if `ms-rest-azure` is imported incorrectly (e.g., trying to destructure a default export as named), or if the package is truly not installed or corrupted. It's also common if attempting to use older `ms-rest-azure` functions in an environment where they are not correctly resolved, especially in newer ESM contexts where `require` patterns are discouraged.
fix
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`.
Upgrade
Version history
3.0.2latest on npm
Audit
Dependencies
ms-restrequiredCore HTTP client runtime providing basic request/response handling and serialization. ms-rest-azure builds upon this.
Agent activity
26 hits · last 30 days
node
24
OpenAI (training)
2
Resources
ms-rest-azure — npm install ms-rest-azure · libregistry