웹 서버 로그로 웹앱 모니터링

이 시나리오에서는 리소스 그룹, App Service 계획, 웹앱을 만들고 웹 서버 로그를 사용하도록 웹앱을 구성합니다. 그런 다음 검토하기 위해 로그 파일을 다운로드합니다.

필요한 경우 Azure PowerShell 가이드에 있는 지침을 사용하여 Azure PowerShell을 설치한 다음, Connect-AzAccount를 실행하여 Azure에 연결합니다.

샘플 스크립트

참고 항목

Azure Az PowerShell 모듈을 사용하여 Azure와 상호 작용하는 것이 좋습니다. 시작하려면 Azure PowerShell 설치를 참조하세요. Az PowerShell 모듈로 마이그레이션하는 방법에 대한 자세한 내용은 Azure PowerShell을 AzureRM에서 Azure로 마이그레이션을 참조하세요.


# Generates a Random Value
$Random=(New-Guid).ToString().Substring(0,8)

# Variables
$ResourceGroupName="myResourceGroup$Random"
$AppName="AppServiceMonitor$Random"
$Location="WestUS"

# Create a Resource Group
New-AzResourceGroup -Name $ResourceGroupName -Location $Location

# Create an App Service Plan
New-AzAppservicePlan -Name AppServiceMonitorPlan -ResourceGroupName $ResourceGroupName -Location $Location -Tier Basic

# Create a Web App in the App Service Plan
New-AzWebApp -Name $AppName -ResourceGroupName $ResourceGroupName -Location $Location -AppServicePlan AppServiceMonitorPlan

# Enable Logs
Set-AzWebApp -RequestTracingEnabled $True -HttpLoggingEnabled $True -DetailedErrorLoggingEnabled $True -ResourceGroupName $ResourceGroupName -Name $AppName

# Make a Request
Invoke-WebRequest -Method "Get" -Uri https://$AppName.azurewebsites.net/404 -ErrorAction SilentlyContinue

# Download the Web App Logs
Write-Host "In your browser, download the logs for your app at https://$AppName.scm.azurewebsites.net/api/dump"

배포 정리

스크립트 샘플을 실행한 후에는 다음 명령을 사용하여 리소스 그룹, 웹앱 및 모든 관련된 리소스를 제거할 수 있습니다.

Remove-AzResourceGroup -Name myResourceGroup -Force

스크립트 설명

이 스크립트는 다음 명령을 사용합니다. 테이블에 있는 각 명령은 명령에 해당하는 문서에 연결됩니다.

명령 메모
New-AzResourceGroup 모든 리소스가 저장되는 리소스 그룹을 만듭니다.
New-AzAppServicePlan App Service 계획을 만듭니다.
New-AzWebApp 웹앱을 만듭니다.
Set-AzWebApp 웹앱의 구성을 수정합니다.

다음 단계

Azure PowerShell 모듈에 대한 자세한 내용은 Azure PowerShell 설명서를 참조하세요.

Azure App Service Web Apps에 대한 추가 Azure PowerShell 샘플은 Azure PowerShell 샘플에서 확인할 수 있습니다.