What is ms-rest-azure?
The ms-rest-azure npm package is a library for Node.js that provides authentication and client creation functionalities for Azure services. It simplifies the process of interacting with Azure resources by handling the complexities of authentication and service client management.
What are ms-rest-azure's main functionalities?
Authentication with Azure
This feature allows you to authenticate with Azure using a service principal. The code sample demonstrates how to log in using a client ID, secret, and domain.
const msRestAzure = require('ms-rest-azure');
msRestAzure.loginWithServicePrincipalSecret(clientId, secret, domain, (err, credentials) => {
if (err) return console.log(err);
console.log('Authenticated successfully');
});
Creating a Resource Management Client
This feature allows you to create a client for managing Azure resources. The code sample shows how to create a Resource Management Client after authenticating with Azure.
const msRestAzure = require('ms-rest-azure');
const AzureArmResource = require('azure-arm-resource');
msRestAzure.loginWithServicePrincipalSecret(clientId, secret, domain, (err, credentials) => {
if (err) return console.log(err);
const client = new AzureArmResource.ResourceManagementClient(credentials, subscriptionId);
console.log('Resource Management Client created successfully');
});
Listing Resource Groups
This feature allows you to list all resource groups in a subscription. The code sample demonstrates how to list resource groups using the Resource Management Client.
const msRestAzure = require('ms-rest-azure');
const AzureArmResource = require('azure-arm-resource');
msRestAzure.loginWithServicePrincipalSecret(clientId, secret, domain, (err, credentials) => {
if (err) return console.log(err);
const client = new AzureArmResource.ResourceManagementClient(credentials, subscriptionId);
client.resourceGroups.list((err, result) => {
if (err) return console.log(err);
console.log('Resource Groups:', result);
});
});
Other packages similar to ms-rest-azure
azure-sdk-for-js
The azure-sdk-for-js is a collection of libraries for various Azure services. It provides more modern and modular packages compared to ms-rest-azure, allowing you to include only the specific services you need. It also supports the latest Azure features and improvements.
azure-arm-resource
The azure-arm-resource package is specifically designed for managing Azure resources. It provides functionalities similar to ms-rest-azure but focuses solely on resource management. It can be used in conjunction with ms-rest-azure for authentication.
azure-storage
The azure-storage package is designed for interacting with Azure Storage services. While ms-rest-azure provides general authentication and client creation, azure-storage focuses on storage-specific operations like managing blobs, queues, and tables.
MS-Rest-Azure
Infrastructure for error handling, tracing, and http client pipeline configuration. Required by nodeJS Azure client libraries, generated using AutoRest.
- Node.js version: 0.10.0 or higher
How to Install
npm install ms-rest-azure
Related Projects