Install the .NET Core agent with Azure App Service

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

To complete an express installation of the .NET Core agent using Azure Portal Extensions:

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

  2. Create a .NET Core 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 Core agent manually with NuGet.

  5. Configure settings that allow the agent to connect to Contrast by adding the following values in the Application Settings section of the Configuration blade 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.

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

  7. Select Extensions.

    UUID-386dc09b-b8d4-47e6-0f15-209d533b27c2.png
  8. Select Add.

  9. Select the Contrast .NET Core Site Extension. This is the extension for .NET Core applications.

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

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

  12. Go back to the application overview and Restart the application.

  13. Navigate to the application, and confirm the application is reporting to Contrast.

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 Core 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.

Note

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

CORECLR_ENABLE_PROFILING=1
CORECLR_PROFILER={8B2CE134-0948-48CA-A4B2-80DDAD9F5791}
CORECLR_PROFILER_PATH_32=D:\home\siteextensions\D:\Home\siteextensions\Contrast.NetCore.Azure.SiteExtension\ContrastNetCoreAppService\runtimes\win-x86\native\ContrastProfiler.dll
CORECLR_PROFILER_PATH_64=D:\Home\siteextensions\Contrast.NetCore.Azure.SiteExtension\ContrastNetCoreAppService\runtimes\win-x64\native\ContrastProfiler.dll
CONTRAST_INSTALL_DIRECTORY=D:\Home\siteextensions\Contrast.NetCore.Azure.SiteExtension\ContrastNetCoreAppService\
MicrosoftInstrumentationEngine_ConfigPath32_ContrastCoreX86Config=D:\Home\siteextensions\Contrast.NetCore.Azure.SiteExtension\ContrastCieCoreClrProfiler-32.config
MicrosoftInstrumentationEngine_ConfigPath64_ContrastCoreX64Config=D:\Home\siteextensions\Contrast.NetCore.Azure.SiteExtension\ContrastCieCoreClrProfiler-64.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.