適用於 Node.js 的 Azure 自動化模組Azure Automation Modules for Node.js

概觀Overview

Azure 自動化可讓使用者將雲端和企業環境中執行的手動、長時間執行、易發生錯誤且重複性高的工作加以自動化。Azure Automation provides a way for users to automate the manual, long-running, error-prone, and frequently repeated tasks that are commonly performed in a cloud and enterprise environment. 自動化可以節省時間並提高日常管理工作的可靠性,甚至將它們排程為定期自動執行。Automation saves time and increases the reliability of regular administrative tasks and even schedules them to be automatically performed at regular intervals. 您可以使用 Runbook 自動執行程序,或使用「期望狀態設定」自動進行組態管理。You can automate processes using runbooks or automate configuration management using Desired State Configuration.

管理封裝Management package

使用 npm 安裝模組Install the modules with npm

使用 npm 來安裝適用於 Node.js 的 Azure 自動化模組Use npm to install the Azure Automation modules for Node.js

npm install azure-arm-automation

範例Example

此範例會列出自動化帳戶。This example lists the automation accounts.

const msRestAzure = require('ms-rest-azure');
const AutomationManagement = require('azure-arm-automation');

const subcriptionId = 'your-subscription-id';
const resourceGroup = 'your-resource-group';

msRestAzure
  .interactiveLogin()
  .then(credentials => {
    const client = new AutomationManagement(credentials, subcriptionId);
    return client.automationAccounts.listByResourceGroup(resourceGroup);
  })
  .then(automationAccounts =>
    console.dir(automationAccounts, { depth: null, colors: true })
  )
  .catch(err => console.log(err));

範例Samples

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