您现在访问的是微软AZURE全球版技术文档网站,若需要访问由世纪互联运营的MICROSOFT AZURE中国区技术文档网站,请访问 https://docs.azure.cn.

用于 .NET 的 Azure 自动化库Azure Automation libraries for .NET

概述Overview

借助 Microsoft Azure 自动化,用户可以自动完成通常要在云环境和企业环境中执行的任务。Microsoft Azure Automation provides a way for users to automate the tasks that are commonly performed in a cloud and enterprise environment.

请阅读 Azure 自动化概述了解详细信息。Learn more by reading the Azure Automation Overview.

管理库Management library

使用管理库可以管理 Runbook 和作业,以及管理 Desired State Configuration 设置。Using the management library to manage runbooks and jobs and manage Desired State Configuration settings.

直接从 Visual Studio 包管理器控制台或使用 .NET Core CLI 安装 NuGet 包Install the NuGet package directly from the Visual Studio Package Manager console or with the .NET Core CLI.

Visual Studio 包管理器Visual Studio Package Manager

Install-Package Microsoft.Azure.Management.Automation
dotnet add package Microsoft.Azure.Management.Automation

代码示例Code Example

以下示例演示如何基于现有的 Runbook 启动新作业。The following example illustrates how to start a new job based on an existing runbook.

/*
  using Microsoft.Azure.Management.Automation;
*/
AutomationManagementClient client =
    new AutomationManagementClient(new CertificateCloudCredentials(subscriptionId, cert));

// Create job create parameters
JobCreateParameters jcParam = new JobCreateParameters
{
    Properties = new JobCreateProperties
    {
        Runbook = new RunbookAssociationProperty
        {
            Name = runbookName
        },
        Parameters = null // optional parameters here
    }
};

// create runbook job. This gives back the Job
Job job = automationManagementClient.Jobs.Create(automationAccountName, jcParam).Job;

示例Samples

详细了解可在应用中使用的示例 .NET 代码Explore more sample .NET code you can use in your apps.