How to Create Your First Azure Automation Runbook with PowerShell
How to Create Your First Azure Automation Runbook with PowerShell
Learn how to create, publish and run your first Azure Automation runbook using PowerShell and the Azure CLI. This step-by-step guide walks through setting up an Automation account, creating a runbook, and executing it in Azure.
adamtheautomator.com
- Azure Automation 서비스 개요
- Azure Automation은 Azure 및 온프레미스 환경에서 작업을 자동화할 수 있는 강력한 서비스
- Runbook은 특정 작업을 수행하는 스크립트 또는 워크플로우로, Azure 환경에서 자동화 작업을 수행
- 환경 설정
- 리소스 그룹 생성: 모든 자원을 담을 리소스 그룹을 PowerShell을 사용해 생성
New-AzResourceGroup -Name 'AzAutomationTutorial' -Location 'East US'
- 리소스 그룹 이름과 위치를 변수에 저장**
$resourceGroupName = 'AzAutomationTutorial' $location = 'East US'
- 리소스 그룹 생성: 모든 자원을 담을 리소스 그룹을 PowerShell을 사용해 생성
- 자동화 계정 생성
- 자동화 리소스를 관리할 Automation Account를 생성
New-AzAutomationAccount -Name 'MyAzAutomationAccount' -Location $location -ResourceGroupName $resourceGroupName
- 자동화 계정 이름을 변수에 저장
$automationAccountName = 'MyAzAutomationAccount'
- 자동화 리소스를 관리할 Automation Account를 생성
- Runbook 생성
- VS Code에서 Azure Automation 확장을 사용하여 PowerShell 7.2 Runbook 생성
- Azure 아이콘 클릭 → Automation Account > Runbooks로 이동 → "Create runbook" 선택
- 이름: MyAzAutomationRunbook, 타입: PowerShell 7.2
- 코드 추가
Write-Output "Hello from my first Azure Automation runbook!"
- VS Code에서 Azure Automation 확장을 사용하여 PowerShell 7.2 Runbook 생성
- Runbook 테스트 및 게시
- VS Code에서 로컬 실행 후 출력 확인
- Azure로 게시:
Get-AzAutomationRunbook -ResourceGroupName $resourceGroupName -AutomationAccountName $automationAccountName -Name 'MyAzAutomationRunbook'
- Runbook 실행
- Runbook 실행:
Start-AzAutomationRunbook -Name 'MyAzAutomationRunbook' -ResourceGroupName $resourceGroupName -AutomationAccountName $automationAccountName
- 실행된 Job 상태 확인 및 결과 출력:
$job = Get-AzAutomationJob -ResourceGroupName $resourceGroupName -AutomationAccountName $automationAccountName -RunbookName 'MyAzAutomationRunbook' Get-AzAutomationJobOutput -Id $job.JobId -ResourceGroupName $resourceGroupName -AutomationAccountName $automationAccountName -Stream Output
- Runbook 실행:
- 결론
- Azure Automation에서 PowerShell을 사용해 Runbook을 생성하고 실행하는 기본 흐름을 이해
- 이후 더 복잡한 작업을 자동화해 Azure 환경에서 운영 효율성을 높이는 다양한 Runbook을 작성할 수 있음
'Kant's IT > Issue on IT&Security' 카테고리의 다른 글
중국산 IP 카메라 및 와이파이 공유기의 해킹 문제와 보안 취약성 (1) | 2024.11.10 |
---|---|
중국 암표업자에 의한 국내 티켓 예매 사이트 보안 취약 문제 (2) | 2024.11.10 |
Imperva Adaptive Threshold: 레이어 7 DDoS 공격 방어로 온라인 서비스 보호 (0) | 2024.11.10 |
Marriott, 6년간의 데이터 유출 사건 후 $5200만 벌금 및 보안 프로그램 강화 (0) | 2024.11.10 |
Google, GASA 및 DNS RF와 협력하여 대규모 온라인 사기 대응 (0) | 2024.11.10 |