Azure 仮想マシン上の Web アプリに対して Profiler を有効にする

注意

Azure を操作するには、Azure Az PowerShell モジュールを使用することをお勧めします。 作業を開始するには、Azure PowerShell のインストールに関する記事を参照してください。 Az PowerShell モジュールに移行する方法については、「AzureRM から Az への Azure PowerShell の移行」を参照してください。

この記事では、3 つの異なるメソッドを使用して、Azure 仮想マシン (VM) または Azure 仮想マシン スケール セットで Application Insights Profiler を実行する方法について説明します。

  • Visual Studio と Azure Resource Manager
  • PowerShell
  • Azure Resource Explorer

それらの方法のいずれかを使用して、以下を行います。

  • Azure Diagnostics 拡張機能を構成し、Profiler を実行します。
  • Application Insights SDK を VM にインストールします。
  • アプリケーションをデプロイします。
  • Azure portal で Application Insights インスタンスを介して Profiler トレースを表示します。

前提条件

Application Insights SDK をアプリケーションに追加する

  1. Visual Studio で ASP.NET Core プロジェクトを開きます。

  2. [プロジェクト]>[Application Insights Telemetry の追加] を選択します

  3. [Azure Application Insights]>[次へ] を選択します。

  4. Application Insights リソースが存在するサブスクリプションを選択し、[次へ] を選択します。

  5. 接続文字列を保存する場所を選択し、[次へ] を選択します。

  6. [完了] を選択します。

注意

Visual Studio を使用せずに ASP.NET Core アプリケーションで Application Insights を有効にする方法などの詳細な手順については、「Application Insights for ASP.NET Core アプリケーション」を参照してください。

Application Insights SDK の最新の安定したリリースを確認します。

  1. [プロジェクト]>[NuGet パッケージの管理] の順に移動します。

  2. [Microsoft.ApplicationInsights.AspNetCore] を選択します。

  3. サイド ペインで、ドロップダウンから最新バージョンの SDK を選択します。

  4. [更新] を選択します。

    更新用の Application Insights パッケージを選択する場所を示すスクリーンショット。

Profiler を有効にする

次の 3 つの方法のいずれかを使用して、Profiler を有効にすることができます。

  • Azure Resource Manager テンプレートと Visual Studio を使用して ASP.NET Core アプリケーション内で。 推奨。
  • Azure CLI で PowerShell コマンドを使用する。
  • Azure Resource Explorer を使用する。

Azure Diagnostics 拡張機能をインストールする

  1. 使用する ARM テンプレートを選択します。

  2. テンプレートで、種類がextension のリソースを見つけます。

  3. Visual Studio で、Application Insights SDK のインストール時に追加された ASP.NET Core アプリケーション内の arm.json ファイルに移動します。

  4. テンプレートから arm.json ファイルにリソースの種類 extension を追加して、Azure Diagnostics を使用して VM または仮想マシン スケール セットを設定します。

  5. WadCfg タグ内で、Application Insights インストルメンテーション キーを MyApplicationInsightsProfilerSink に追加します。

    "WadCfg": {
      "SinksConfig": {
        "Sink": [
          {
            "name": "MyApplicationInsightsProfilerSink",
            "ApplicationInsightsProfiler": "YOUR_APPLICATION_INSIGHTS_INSTRUMENTATION_KEY"
          }
        ]
      }
    }        
    
  6. アプリケーションをデプロイします。

オンプレミスのサーバーで Profiler を実行できますか。

現時点では、Application Insights Profiler はオンプレミス サーバーではサポートされていません。

次のステップ