Skip to main content

Install the .NET Framework agent for Azure App Service

Use this procedure for an express installation of the .NET Framework agent using Azure Portal Extensions.

Before you begin

Before you begin, check the system requirements and supported technologies to be sure installation will work and ensure best performance.

Steps

  1. Create an Azure account, if you don't have one already.

  2. Create a .NET web application and deploy it to Azure App Service.

  3. Publish your application to Azure, and confirm that it works as expected without Contrast.

  4. Ensure that your application is deployed using a Windows plan. (Linux plans do not support Site Extensions.)

    Note

    If you do not have access to the site extension, you can install the .NET Framework agent manually with NuGet.

  5. Add the Contrast .NET Framework Agent Site Extension:

    • With the Azure portal

      1. In the Azure Portal, select your hosted application.

      2. Select Extensions.

        Image shows Azure Portal with Extensions selected.
      3. Select Add.

      4. Select the Contrast .NET Framework Site Extension for Azure App Service. This is the extension for .NET Framework applications.

      5. Select OK, and agree to the terms and conditions.

      6. Wait a few seconds and confirm the site extension installed correctly.

      Note

      The site extension sets a number of environment variables, including:

      COR_ENABLE_PROFILING=1
      COR_PROFILER={EFEB8EE0-6D39-4347-A5FE-4D0C88BC5BC1}
      COR_PROFILER_PATH_32=D:\home\siteextensions\Contrast.Net.Azure.SiteExtension\ContrastAppService\runtimes\win-x86\native\ContrastProfiler.dll
      COR_PROFILER_PATH_64=D:\home\siteextensions\Contrast.Net.Azure.SiteExtension\ContrastAppService\runtimes\win-x64\native\ContrastProfiler.dll
      CONTRAST_INSTALL_DIRECTORY=D:\home\siteextensions\Contrast.Net.Azure.SiteExtension\ContrastAppService\
      MicrosoftInstrumentationEngine_ConfigPath32_ContrastX86Config=D:\home\siteextensions\Contrast.Net.Azure.SiteExtension\runtimes\win-x86\ContrastCieProfiler.config
      MicrosoftInstrumentationEngine_ConfigPath64_ContrastX64Config=D:\home\siteextensions\Contrast.Net.Azure.SiteExtension\runtimes\win-x64\ContrastCieProfiler.config

      If the CLR instrumentation engine (CIE) is configured for the application (for example, because Application Insights is enabled), Azure should automatically overwrite the CORECLR_PROFILER* variables to point to the profiler of the CIE.

      The CIE will then use the MicrosoftInstrumentationEngine_* variables to load the Contrast agent.

      If the CIE is not configured for the application, the standard CORECLR_PROFILER* variables will be used to load the Contrast agent.

    • With the Azure CLI

      • Use a command similar to this one for a .NET Framework Site Extension

        az resource create --resource-group 'myResourceGroup' --resource-type Microsoft.Web/sites/siteextensions --name myAppService/siteextensions/Contrast.NET.Azure.SiteExtension --properties "{}"

        In this example, the command adds a Contrast .NET Framework Site Extension to an App Service named "myAppService" in Resource Group "myResourceGroup".

      After you add the extension, the Azure Portal displays a list of the installed agents with details similar to the following:

      Name

      Version

      Update Available

      Contrast.NET Framework Site Extension for Azure App Service

      51.0.22

      No

    Tip

    You can also install the agent from the Site Extensions area of your application management SCM (Kudu) site.

    Important

    If a new version of the .NET Framework agent is available, it's indicated in the Azure Portal or Kudu dashboard. You must stop the site before starting the update; otherwise, the update may fail.

  6. Add configuration options

    • With the Azure Portal

      1. In the Azure Portal, select your hosted application.

      2. Select Configuration under Settings to configure settings that allow the agent to connect to Contrast.

      3. Select New application setting and add the following values for your application:

        Key

        Value

        CONTRAST__API__USER_NAME

        Replace with your agent username.

        CONTRAST__API__SERVICE_KEY

        Replace with your agent service key.

        CONTRAST__API__API_KEY

        Replace with your agent API key.

        CONTRAST__API__URL

        Defaults to https://app.contrastsecurity.com. Replace with another URL, if you're using a Contrast application that's hosted elsewhere.

    • With the Azure CLI

      • Enter a command similar to this one:

        az webapp config appsettings set --resource-group 'myResourceGroup' --name 'myAppService' --settings CONTRAST__API__URL=https://app.contrastsecurity.com CONTRAST__API__API_KEY={Your API KEY} CONTRAST__API__SERVICE_KEY={Your Service key} CONTRAST__API__USER_NAME={Your agent user}

    Get API values (agent keys) from the Contrast web interface or by downloading a YAML file for the or .NET Framework agent.

  7. In the Azure Portal, go to the application overview and Restart the application.

    Running the application automatically instruments any application that is running inside of the App Service. You should begin to see data in Contrast

  8. Navigate to the application and confirm the application is reporting to Contrast.

    You can view log files to verify that Contrast is running:

    1. In the Azure Portal, go to Advanced Tools for the app service.

    2. Select Go.

    3. In the Kudu Services window, select “Debug console” menu at the top and select “CMD”.

    4. Select the LogFiles directory.

    5. Select the Contrast directory.

    6. Select the dotnet directory.

      You will see an agent log named <PID>_Profiler_<App Service Name>_<XXX>.log.

    7. Verify that there are no ERROR log entries.