Socket
Socket
Sign inDemoInstall

@azure/ms-rest-azure-js

Package Overview
Dependencies
Maintainers
6
Versions
22
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@azure/ms-rest-azure-js

Isomorphic Azure client runtime for Typescript/node.js/browser javascript client libraries generated using AutoRest


Version published
Weekly downloads
135K
decreased by-0.47%
Maintainers
6
Weekly downloads
 
Created

What is @azure/ms-rest-azure-js?

@azure/ms-rest-azure-js is a library that provides Azure-specific implementations of the ms-rest-js interfaces. It is used to handle authentication, HTTP requests, and responses when interacting with Azure services.

What are @azure/ms-rest-azure-js's main functionalities?

Authentication

This feature allows you to authenticate with Azure using a service principal and secret. The code sample demonstrates how to use the `loginWithServicePrincipalSecret` method to obtain credentials.

const msRestAzure = require('@azure/ms-rest-azure-js');
const loginWithServicePrincipalSecret = msRestAzure.loginWithServicePrincipalSecret;

const clientId = 'your-client-id';
const secret = 'your-secret';
const domain = 'your-tenant-id';

loginWithServicePrincipalSecret(clientId, secret, domain).then((credentials) => {
  console.log('Authenticated successfully');
}).catch((err) => {
  console.error('Authentication failed', err);
});

HTTP Requests

This feature allows you to make authenticated HTTP requests to Azure services. The code sample demonstrates how to create and sign a request using the obtained credentials.

const msRestAzure = require('@azure/ms-rest-azure-js');
const loginWithServicePrincipalSecret = msRestAzure.loginWithServicePrincipalSecret;
const { WebResource } = require('@azure/ms-rest-js');

const clientId = 'your-client-id';
const secret = 'your-secret';
const domain = 'your-tenant-id';

loginWithServicePrincipalSecret(clientId, secret, domain).then((credentials) => {
  const request = new WebResource();
  request.url = 'https://management.azure.com/subscriptions?api-version=2020-01-01';
  request.method = 'GET';
  credentials.signRequest(request).then((signedRequest) => {
    console.log('Signed request:', signedRequest);
  });
}).catch((err) => {
  console.error('Authentication failed', err);
});

Handling Responses

This feature allows you to handle responses from Azure services. The code sample demonstrates how to send a signed request and handle the response, including status and body.

const msRestAzure = require('@azure/ms-rest-azure-js');
const loginWithServicePrincipalSecret = msRestAzure.loginWithServicePrincipalSecret;
const { WebResource, HttpOperationResponse } = require('@azure/ms-rest-js');

const clientId = 'your-client-id';
const secret = 'your-secret';
const domain = 'your-tenant-id';

loginWithServicePrincipalSecret(clientId, secret, domain).then((credentials) => {
  const request = new WebResource();
  request.url = 'https://management.azure.com/subscriptions?api-version=2020-01-01';
  request.method = 'GET';
  credentials.signRequest(request).then((signedRequest) => {
    signedRequest.send().then((response) => {
      console.log('Response status:', response.status);
      console.log('Response body:', response.bodyAsText);
    });
  });
}).catch((err) => {
  console.error('Authentication failed', err);
});

Other packages similar to @azure/ms-rest-azure-js

Keywords

FAQs

Package last updated on 26 Jan 2021

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc