適用於 Node.js 的 Azure 授權模組Azure Authorization modules for Node.js

概觀Overview

Azure App Service 驗證/授權是可讓應用程式接受使用者登入的一種功能,而不需要在應用程式後端變更程式碼。Azure App Service Authentication / Authorization is a feature that provides a way for your application to sign in users so that code doesn't have to be changed on the app backend. 授權提供簡單的方法來保護您的應用程式,以及使用每位使用者的資料。Authorization provides an easy way to protect your application and work with per-user data.

管理封裝Management package

使用 npm 來安裝適用於 Node.js 的 Azure 授權模組Use npm to install the Azure Authorization modules for Node.js

安裝 npm 模組Install the npm module

安裝 Azure 授權 npm 模組Install the Azure authorization npm module

npm install azure-arm-authorization

範例Example

此範例會列出所要求資源群組的所有角色指派。This example lists all role assignments for the requested resource group.

const msRestAzure = require('ms-rest-azure');
const authorizationManagement = require('azure-arm-authorization');

const resourceGroup = 'resource-group-name';
const subscriptionId = 'your-subscription-id';

msRestAzure.interactiveLogin().then(credentials => {
 const client = new authorizationManagement(credentials, subscriptionId);
 client.roleAssignments.listForResourceGroup(resourceGroupName).then(result => {
   console.log(result);
 });
});

範例Samples

深入探索可在應用程式中使用的 Node.js 程式碼範例Explore more sample Node.js code you can use in your apps.