適用於 Node.js 的 Azure 流量管理員模組Azure Traffic Manager modules for Node.js

概觀Overview

Microsoft Azure 流量管理員可讓您控制使用者流量,將流量分散到不同資料中心的服務端點。Microsoft Azure Traffic Manager allows you to control the distribution of user traffic for service endpoints in different datacenters. 流量管理員支援的服務端點包括 Azure VM、Web Apps 和雲端服務。Service endpoints supported by Traffic Manager include Azure VMs, Web Apps, and cloud services. 您也可以將流量管理員使用於外部、非 Azure 端點。You can also use Traffic Manager with external, non-Azure endpoints.

深入了解 Azure 流量管理員Learn more about Azure Traffic Manager.

管理套件Management Package

安裝 npm 模組Install the npm module

安裝 Azure 流量管理員 npm 模組Install the Azure traffic manager npm module

npm install azure-arm-trafficmanager

範例Example

此範例會列出指定之資源群組的所有流量管理員。This example lists all Traffic Managers for a given resource group.

const msRestAzure = require('ms-rest-azure');
const trafficManager = require('azure-arm-trafficmanager');

const subscriptionId = 'your-subscription-id';

msRestAzure.interactiveLogin().then(credentials => {
  const client = new trafficManager(credentials, subscriptionId);
  const resourceGroupName = 'resource-group-name';
  client.profiles.listAllInResourceGroup(resourceGroupName).then(profiles => {
    profiles.map(profile => {
      console.log(`found profile : ${profile.name}`);
    });
  });
});

範例Samples

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