다음을 통해 공유


Azure App Service에서 .NET, Node.js, Python 및 Java 애플리케이션에 대한 애플리케이션 모니터링 사용

런타임 모니터링이라고도 하는 자동 계측은 코드 변경 또는 고급 구성 없이도 Azure App Service에서 Application Insights를 가장 쉽게 활성화하는 방법입니다. 특정 시나리오에 따라 수동 계측을 통해 고급 모니터링이 필요한지 여부를 평가합니다.

참고

2025년 3월 31일에 계측 키 수집에 대한 지원이 종료됩니다. 계측 키 수집은 계속 작동하지만 더 이상 기능에 대한 업데이트 또는 지원을 제공하지 않습니다. 새 기능을 활용하기 위해 연결 문자열로 전환합니다.

Application Insights 사용

중요합니다

자동 침입 모니터링 및 수동 SDK 기반 계측이 모두 감지되면 수동 계측 설정만 적용됩니다. 이 배열은 중복 데이터가 전송되는 것을 방지합니다. 자세한 내용은 Azure App Service와 Application Insights 통합 문제 해결을 참조하세요.

참고

Azure Portal의 자동 침입

  1. 앱 서비스의 왼쪽 탐색 메뉴에서 Application Insights를 선택한 다음 사용을 선택합니다.

     사용이 선택된 Application Insights 탭을 보여 주는 스크린샷.

  2. 새 리소스를 만들거나 이 애플리케이션에 대한 기존 Application Insights 리소스를 선택합니다.

    참고

    확인을 선택하여 새 리소스를 만들면 모니터링 설정을 적용하라는 메시지가 표시됩니다. 계속을 선택하면 새 Application Insights 리소스가 앱 서비스에 연결됩니다. 그러면 앱 서비스가 다시 시작됩니다.

    리소스 변경 드롭다운을 보여 주는 스크린샷.

  3. 사용할 리소스를 지정한 후 Application Insights에서 애플리케이션에 대한 플랫폼별 데이터를 수집하는 방법을 선택할 수 있습니다. ASP.NET Core 컬렉션 옵션은 권장 또는 사용 안 함입니다.

     애플리케이션 계측 섹션을 보여 주는 스크린샷.

모니터링 확장/에이전트 수동 업그레이드

버전 2.8.9 이상에서 업그레이드

버전 2.8.9에서 업그레이드는 추가 작업 없이 자동으로 수행됩니다. 새 모니터링 비트는 백그라운드에서 대상 앱 서비스로 전달되고 애플리케이션을 다시 시작할 때 선택됩니다.

실행 중인 확장의 버전을 확인하려면 https://yoursitename.scm.azurewebsites.net/ApplicationInsights로 이동합니다.

실행 중인 확장의 버전을 확인하는 URL 경로를 보여 주는 스크린샷.

버전 1.0.0~2.6.5에서 업그레이드

버전 2.8.9부터 미리 설치된 사이트 확장이 사용됩니다. 이전 버전을 사용 중인 경우 다음 두 가지 방법 중 하나로 업데이트할 수 있습니다.

2.5.1 이전 버전에서 업그레이드가 완료되면 ApplicationInsights DLL이 애플리케이션 bin 폴더에서 제거되었는지 확인합니다. 자세한 내용은 Azure App Service와 Application Insights 통합 문제 해결을 참조하세요.

모니터링 확장/에이전트 구성

현재 ASP.NET Core에 대한 모니터링 확장을 구성하는 옵션은 제공되지 않습니다.

클라이언트 쪽 모니터링 사용

클라이언트 쪽 모니터링은 앱 설정이 있는지 여부에 관계없이 권장 컬렉션이 있는 ASP.NET Core 앱에 대해 기본적으로 사용하도록 설정 APPINSIGHTS_JAVASCRIPT_ENABLED 됩니다.

클라이언트 쪽 모니터링을 사용하지 않도록 설정하려는 경우:

  1. 설정>구성을 선택합니다.

  2. 애플리케이션 설정에서 다음 정보를 사용하여 새 애플리케이션 설정을 만듭니다.

    • 이름: APPINSIGHTS_JAVASCRIPT_ENABLED
    • : false
  3. 설정을 저장합니다. 응용 프로그램을 다시 시작합니다.

모니터링 자동화

Application Insights로 원격 분석 컬렉션을 사용하려면 다음 애플리케이션 설정만 설정하면 됩니다.

Application Insights 설정이 있는 App Service 애플리케이션 설정을 보여 주는 스크린샷

애플리케이션 설정 정의

앱 설정 이름 정의
ApplicationInsightsAgent_EXTENSION_VERSION 런타임 모니터링을 제어하는 기본 확장입니다. Windows의 경우 ~2 또는 Linux의 경우 ~3
XDT_MicrosoftApplicationInsights_Mode 기본 모드에서는 최적의 성능을 보장하기 위해 필수 기능만 사용하도록 설정됩니다. disabled 또는 recommended입니다.
XDT_MicrosoftApplicationInsights_PreemptSdk ASP.NET Core 앱에만 해당합니다. Application Insights SDK와 상호 운용을 사용하도록 설정합니다. 확장을 SDK와 함께 로드하고 이를 사용하여 원격 분석을 보냅니다. (Application Insights SDK를 사용하지 않도록 설정합니다.) 1

Azure Resource Manager를 사용한 App Service 애플리케이션 설정

Azure App Service에 대한 애플리케이션 설정은 Azure Resource Manager 템플릿을 사용하여 관리 및 구성할 수 있습니다. Resource Manager 자동화를 사용하여 새 App Service 리소스를 배포하거나 기존 리소스의 설정을 수정할 때 이 방법을 사용할 수 있습니다.

App Service 리소스에 대한 애플리케이션 설정 JSON의 기본 구조:

      "resources": [
        {
          "name": "appsettings",
          "type": "config",
          "apiVersion": "2015-08-01",
          "dependsOn": [
            "[resourceId('Microsoft.Web/sites', variables('webSiteName'))]"
          ],
          "tags": {
            "displayName": "Application Insights Settings"
          },
          "properties": {
            "key1": "value1",
            "key2": "value2"
          }
        }
      ]

기본 Application Insights 설정을 사용하여 Resource Manager 템플릿을 만들려면 Application Insights를 사용하도록 설정하여 새 웹앱을 만들려는 것처럼 프로세스를 시작합니다.

  1. Azure Portal에서 원하는 정보를 사용하여 새 웹앱 리소스를 만듭니다. 모니터 + 보안 탭에서 Application Insights를 사용하도록 설정합니다.

  2. 검토 + 만들기로 이동한 다음 자동화를 위한 템플릿 다운로드를 선택합니다. 이 옵션은 모든 필수 설정이 구성된 최신 Resource Manager 템플릿을 생성합니다.

    App Service 웹앱 만들기 메뉴를 보여 주는 스크린샷

참고

다음 예제 템플릿은 Windows에서 실행되는 .NET 8(LTS) 애플리케이션용입니다. 애플리케이션 이름에 my-monitored-web-app를, 구독 ID에 aaaa0a0a-bb1b-cc2c-dd3d-eeeeee4e4e4e을 사용합니다.

복사하여 직접 사용하지 않는 것이 좋습니다. 대신 위의 지침에 따라 고유한 템플릿을 생성합니다.


예제 템플릿 보기
{
    "$schema": "http://schema.management.azure.com/schemas/2015-01-01/deploymentTemplate.json#",
    "contentVersion": "1.0.0.0",
    "parameters": {
        "subscriptionId": {
            "type": "string"
        },
        "resourceGroupName": {
            "type": "string"
        },
        "name": {
            "type": "string"
        },
        "___location": {
            "type": "string"
        },
        "hostingPlanName": {
            "type": "string"
        },
        "serverFarmResourceGroup": {
            "type": "string"
        },
        "alwaysOn": {
            "type": "bool"
        },
        "ftpsState": {
            "type": "string"
        },
        "autoGeneratedDomainNameLabelScope": {
            "type": "string"
        },
        "sku": {
            "type": "string"
        },
        "skuCode": {
            "type": "string"
        },
        "workerSize": {
            "type": "string"
        },
        "workerSizeId": {
            "type": "string"
        },
        "numberOfWorkers": {
            "type": "string"
        },
        "currentStack": {
            "type": "string"
        },
        "phpVersion": {
            "type": "string"
        },
        "netFrameworkVersion": {
            "type": "string"
        }
    },
    "variables": {},
    "resources": [
        {
            "apiVersion": "2022-03-01",
            "name": "[parameters('name')]",
            "type": "Microsoft.Web/sites",
            "___location": "[parameters('___location')]",
            "tags": null,
            "dependsOn": [
                "microsoft.insights/components/my-monitored-web-app",
                "[concat('Microsoft.Web/serverfarms/', parameters('hostingPlanName'))]"
            ],
            "properties": {
                "name": "[parameters('name')]",
                "siteConfig": {
                    "appSettings": [
                        {
                            "name": "APPLICATIONINSIGHTS_CONNECTION_STRING",
                            "value": "[reference('microsoft.insights/components/my-monitored-web-app', '2015-05-01').ConnectionString]"
                        },
                        {
                            "name": "ApplicationInsightsAgent_EXTENSION_VERSION",
                            "value": "~2"
                        },
                        {
                            "name": "XDT_MicrosoftApplicationInsights_Mode",
                            "value": "default"
                        }
                    ],
                    "metadata": [
                        {
                            "name": "CURRENT_STACK",
                            "value": "[parameters('currentStack')]"
                        }
                    ],
                    "phpVersion": "[parameters('phpVersion')]",
                    "netFrameworkVersion": "[parameters('netFrameworkVersion')]",
                    "alwaysOn": "[parameters('alwaysOn')]",
                    "ftpsState": "[parameters('ftpsState')]"
                },
                "serverFarmId": "[concat('/subscriptions/', parameters('subscriptionId'),'/resourcegroups/', parameters('serverFarmResourceGroup'), '/providers/Microsoft.Web/serverfarms/', parameters('hostingPlanName'))]",
                "clientAffinityEnabled": true,
                "virtualNetworkSubnetId": null,
                "httpsOnly": true,
                "publicNetworkAccess": "Enabled",
                "autoGeneratedDomainNameLabelScope": "[parameters('autoGeneratedDomainNameLabelScope')]"
            },
            "resources": [
                {
                    "type": "Microsoft.Web/sites/basicPublishingCredentialsPolicies",
                    "apiVersion": "2022-09-01",
                    "name": "[concat(parameters('name'), '/scm')]",
                    "properties": {
                        "allow": true
                    },
                    "dependsOn": [
                        "[resourceId('Microsoft.Web/Sites', parameters('name'))]"
                    ]
                },
                {
                    "type": "Microsoft.Web/sites/basicPublishingCredentialsPolicies",
                    "apiVersion": "2022-09-01",
                    "name": "[concat(parameters('name'), '/ftp')]",
                    "properties": {
                        "allow": true
                    },
                    "dependsOn": [
                        "[resourceId('Microsoft.Web/Sites', parameters('name'))]"
                    ]
                }
            ]
        },
        {
            "apiVersion": "2018-11-01",
            "name": "[parameters('hostingPlanName')]",
            "type": "Microsoft.Web/serverfarms",
            "___location": "[parameters('___location')]",
            "kind": "",
            "tags": null,
            "dependsOn": [],
            "properties": {
                "name": "[parameters('hostingPlanName')]",
                "workerSize": "[parameters('workerSize')]",
                "workerSizeId": "[parameters('workerSizeId')]",
                "numberOfWorkers": "[parameters('numberOfWorkers')]",
                "zoneRedundant": false
            },
            "sku": {
                "Tier": "[parameters('sku')]",
                "Name": "[parameters('skuCode')]"
            }
        },
        {
            "apiVersion": "2020-02-02-preview",
            "name": "my-monitored-web-app",
            "type": "microsoft.insights/components",
            "___location": "centralus",
            "tags": null,
            "dependsOn": [
                "newWorkspaceTemplate"
            ],
            "properties": {
                "ApplicationId": "[parameters('name')]",
                "Request_Source": "IbizaWebAppExtensionCreate",
                "Flow_Type": "Redfield",
                "Application_Type": "web",
                "WorkspaceResourceId": "/subscriptions/aaaa0a0a-bb1b-cc2c-dd3d-eeeeee4e4e4e/resourceGroups/DefaultResourceGroup-CUS/providers/Microsoft.OperationalInsights/workspaces/DefaultWorkspace-aaaa0a0a-bb1b-cc2c-dd3d-eeeeee4e4e4e-CUS"
            }
        },
        {
            "type": "Microsoft.Resources/deployments",
            "apiVersion": "2021-04-01",
            "name": "newWorkspaceTemplate",
            "resourceGroup": "DefaultResourceGroup-CUS",
            "subscriptionId": "[parameters('subscriptionId')]",
            "properties": {
                "mode": "Incremental",
                "template": {
                    "$schema": "https://schema.management.azure.com/schemas/2015-01-01/deploymentTemplate.json#",
                    "contentVersion": "1.0.0.0",
                    "parameters": {},
                    "variables": {},
                    "resources": [
                        {
                            "apiVersion": "2020-08-01",
                            "name": "DefaultWorkspace-aaaa0a0a-bb1b-cc2c-dd3d-eeeeee4e4e4e-CUS",
                            "type": "Microsoft.OperationalInsights/workspaces",
                            "___location": "centralus",
                            "properties": {}
                        }
                    ]
                }
            }
        }
    ]
}

PowerShell을 통해 사용

PowerShell을 통해 애플리케이션 모니터링을 사용하도록 설정하려면 기본 애플리케이션 설정만 변경해야 합니다. 다음 샘플은 리소스 그룹 my-monitored-web-app에서 my-resource-group라는 웹 사이트에 대한 애플리케이션 모니터링을 사용하도록 설정합니다. 데이터를 InstrumentationKey=012345678-abcd-ef01-2345-6789abcd 연결 문자열로 전송하도록 구성합니다.

참고

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

참고

Windows의 경우 ApplicationInsightsAgent_EXTENSION_VERSION ~2설정합니다.

Linux의 경우 ApplicationInsightsAgent_EXTENSION_VERSION ~3설정합니다.

$app = Get-AzWebApp -ResourceGroupName "my-resource-group" -Name "my-monitored-web-app" -ErrorAction Stop
$newAppSettings = @{} # Case-insensitive hash map
$app.SiteConfig.AppSettings | %{$newAppSettings[$_.Name] = $_.Value} # Preserve non-Application-Insights application settings.
$newAppSettings["APPLICATIONINSIGHTS_CONNECTION_STRING"] = "InstrumentationKey=aaaa0a0a-bb1b-cc2c-dd3d-eeeeee4e4e4e"; # Set the Application Insights connection string
$newAppSettings["ApplicationInsightsAgent_EXTENSION_VERSION"] = "~3"; # Enable the ApplicationInsightsAgent.
$app = Set-AzWebApp -AppSettings $newAppSettings -ResourceGroupName $app.ResourceGroup -Name $app.Name -ErrorAction Stop

문제 해결

전용 문제 해결 문서를 참조하세요.

다음 단계