원하는 상태로 머신 구성

참고 사항

Azure Automation State Configuration 2027년 9월 30일에 사용 중지됩니다. 해당 날짜까지 Azure Machine Configuration로 전환하세요. 자세한 내용은 블로그 게시물 공지 사항을 참조하세요. Azure Machine Configuration 서비스는 DSC 확장, Azure Automation State Configuration 및 고객 피드백에서 가장 일반적으로 요청되는 기능의 기능을 결합합니다. Azure Machine Configuration에는 Arc 지원 서버 통한 하이브리드 머신 지원도 포함됩니다.

중요

추가, 작성 구성갤러리 탐색 링크는 2025년 3월 31일에 포털에서 제거됩니다.

주의

linux용 Azure Automation DSC는 2023년 9월 30일에 사용 중지되었습니다. 자세한 내용은 공지를 참조하세요.

Azure Automation State Configuration 통해 서버에 대한 구성을 지정하고 해당 서버가 시간이 지남에 따라 지정된 상태에 있는지 확인할 수 있습니다.

  • Azure Automation DSC에서 관리할 VM 온보딩
  • Azure Automation에 구성 파일 업로드
  • 구성을 컴파일하여 노드 구성으로 변환하기
  • 관리되는 노드에 노드 구성 할당
  • 관리되는 노드에 대한 준수 상태 확인

이 자습서에서는 IIS가 VM에 설치되도록 하는 간단한 DSC 구성을 사용합니다.

필수 조건

참고 사항

Windows Server 2008 및 Windows Server 2008 R2는 EOS(지원 종료)에 도달했습니다. 자세한 내용은 Windows Server 2008 및 Windows Server 2008 R2 지원 종료Windows Server 2016, 2019, 2022 또는 2025로의 직접 업그레이드 수행를 참조하세요. 사용량을 검토하고 그에 따라 OS 업그레이드 및 마이그레이션을 계획합니다.

부분 구성 지원

Azure Automation State Configuration은 부분 구성의 사용을 지원합니다. 이 시나리오에서 DSC는 여러 구성을 독립적으로 관리하도록 구성되고 각 구성은 Azure Automation 검색됩니다. 그러나 Automation 계정마다 하나의 구성만 노드에 할당할 수 있습니다. 즉, 노드에 대해 두 개의 구성을 사용하는 경우 두 개의 Automation 계정이 필요합니다.

끌어오기 서비스에서 부분 구성을 등록하는 방법에 대한 자세한 내용은 부분 구성 설명서를 참조하세요.

팀에서 구성을 코드로 사용하여 서버를 공동으로 관리할 수 있는 방법에 대한 자세한 내용은 CI/CD 파이프라인에서 DSC의 역할 이해를 참조하세요.

Azure 로그인

Connect-AzAccount cmdlet을 사용하여 Azure 구독에 로그인하고 화면의 지침을 따릅니다.

Connect-AzAccount

Azure Automation에 구성을 만들고 업로드하기

텍스트 편집기에서 다음을 입력하고 로컬에서 TestConfig.ps1로 저장합니다.

configuration TestConfig {
   Node WebServer {
      WindowsFeature IIS {
         Ensure               = 'Present'
         Name                 = 'Web-Server'
         IncludeAllSubFeature = $true
      }
   }
}

참고 사항

Azure Automation 구성 이름은 100자 이하로 제한해야 합니다.

DSC 리소스를 제공하는 여러 모듈을 가져와야 하는 고급 시나리오에서는 각 모듈이 구성에서 고유한 Import-DscResource 줄을 사용하도록 해야 합니다.

Import-AzAutomationDscConfiguration cmdlet을 호출하여 구성을 Automation 계정에 업로드합니다.

$importAzAutomationDscConfigurationSplat = @{
    SourcePath = 'C:\DscConfigs\TestConfig.ps1'
    ResourceGroupName = 'MyResourceGroup'
    AutomationAccountName = 'myAutomationAccount'
    Published = $true
}
Import-AzAutomationDscConfiguration @importAzAutomationDscConfigurationSplat

구성을 컴파일하여 노드 구성으로 변환하기

DSC 구성을 노드에 할당하려면 먼저 노드 구성으로 컴파일해야 합니다. DSC 구성을 참조하세요.

Start-AzAutomationDscCompilationJob cmdlet 을 호출하여 TestConfig 구성을 Automation 계정의 TestConfig.WebServer라는 노드 구성에 컴파일합니다.

$startAzAutomationDscCompilationJobSplat = @{
    ConfigurationName = 'TestConfig'
    ResourceGroupName = 'MyResourceGroup'
    AutomationAccountName = 'myAutomationAccount'
}
Start-AzAutomationDscCompilationJob @startAzAutomationDscCompilationJobSplat

State Configuration 관리할 VM 등록

Azure Automation State Configuration 사용하여 Azure VM(클래식 및 Resource Manager), 온-프레미스 VM, Linux 머신, AWS VM 및 온-프레미스 물리적 컴퓨터를 관리할 수 있습니다. 이 문서에서는 Azure Resource Manager VM만 등록하는 방법을 설명합니다. 다른 유형의 컴퓨터를 등록하는 방법에 대한 자세한 내용은 Azure Automation State Configuration 관리용 컴퓨터 등록을 참조하세요.

Register-AzAutomationDscNode cmdlet을 호출하여 Azure Automation State Configuration VM을 관리 노드로 등록합니다.

$registerAzAutomationDscNodeSplat = @{
    ResourceGroupName = 'MyResourceGroup'
    AutomationAccountName = 'myAutomationAccount'
    AzureVMName = 'DscVm'
}
Register-AzAutomationDscNode @registerAzAutomationDscNodeSplat

구성 모드 설정 지정

Register-AzAutomationDscNode cmdlet을 사용하여 VM을 관리 노드로 등록하고 구성 속성을 지정합니다. 예를 들어 ApplyOnly 속성 값으로 ConfigurationMode를 지정하여 머신의 상태를 한 번만 적용하도록 지정할 수 있습니다. State Configuration 초기 검사 후 구성을 적용하려고 하지 않습니다.

$registerAzAutomationDscNodeSplat = @{
    ResourceGroupName = 'MyResourceGroup'
    AutomationAccountName = 'myAutomationAccount'
    AzureVMName = 'DscVm'
    ConfigurationMode = 'ApplyOnly'
}
Register-AzAutomationDscNode @registerAzAutomationDscNodeSplat```

You can also specify how often DSC checks the configuration state by using the
`ConfigurationModeFrequencyMins` property. For more information about DSC configuration settings,
see [Configuring the Local Configuration Manager][05].

```powershell
# Run a DSC check every 60 minutes
$registerAzAutomationDscNodeSplat = @{
    ResourceGroupName = 'MyResourceGroup'
    AutomationAccountName = 'myAutomationAccount'
    AzureVMName = 'DscVm'
    ConfigurationModeFrequencyMins = 60
}
Register-AzAutomationDscNode @registerAzAutomationDscNodeSplat```

## Assign a node configuration to a managed node

Now we can assign the compiled node configuration to the VM we want to configure.

```powershell
# Get the ID of the DSC node
$getAzAutomationDscNodeSplat = @{
    ResourceGroupName = 'MyResourceGroup'
    AutomationAccountName = 'myAutomationAccount'
    Name = 'DscVm'
}
$node = Get-AzAutomationDscNode @getAzAutomationDscNodeSplat

# Assign the node configuration to the DSC node
$setAzAutomationDscNodeSplat = @{
    ResourceGroupName = 'MyResourceGroup'
    AutomationAccountName = 'myAutomationAccount'
    NodeConfigurationName = 'TestConfig.WebServer'
    NodeId = $node.Id
}
Set-AzAutomationDscNode @setAzAutomationDscNodeSplat

그러면 등록된 DSC 노드 TestConfig.WebServerDscVm라는 노드 구성이 할당됩니다. 기본적으로 DSC 노드에서는 30분마다 노드 구성이 준수되는지 확인합니다. 준수 확인 간격을 변경하는 방법에 대한 자세한 내용은 로컬 구성 관리자 구성을 참조하세요.

관리되는 노드에 대한 준수 상태 확인

Get-AzAutomationDscNodeReport cmdlet을 사용하여 관리 노드의 준수 상태에 대한 보고서를 가져올 수 있습니다.

# Get the ID of the DSC node
$getAzAutomationDscNodeSplat = @{
    ResourceGroupName = 'MyResourceGroup'
    AutomationAccountName = 'myAutomationAccount'
    Name = 'DscVm'
}
$node = Get-AzAutomationDscNode @getAzAutomationDscNodeSplat

# Get an array of status reports for the DSC node
$getAzAutomationDscNodeReportSplat = @{
    ResourceGroupName = 'MyResourceGroup'
    AutomationAccountName = 'myAutomationAccount'
    NodeId = $node.Id
}
$reports = Get-AzAutomationDscNodeReport @getAzAutomationDscNodeReportSplat

# Display the most recent report
$reports[0]

다음 단계