Install the .NET Framework agent for Azure App Service

Note

If you don't have access to the site extension, you can manually install the .NET Framework agent with NuGet.

Steps

To install the .NET Framework agent using Azure Portal Extensions:

  1. Create an application hosted on Azure App Service.

    To do this you must have an Azure account and create an ASP.NET Framework web app. Publish your application to Azure, and confirm that it works as expected without Contrast.

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

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

  4. Select Extensions.

  5. Select Add.

  6. Select the Contrast .NET Site Extension. This is the extension for .NET Framework applications.

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

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

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

  10. 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 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:

COR_ENABLE_PROFILING=1
COR_PROFILER={EFEB8EE0-6D39-4347-A5FE-4D0C88BC5BC1}
COR_PROFILER_PATH_32=D:\home\siteextensions\Contrast.Net.Azure.SiteExtension\ContrastAppService\ContrastProfiler-32.dll
COR_PROFILER_PATH_64=D:\home\siteextensions\Contrast.Net.Azure.SiteExtension\ContrastAppService\ContrastProfiler-64.dll
CONTRAST_INSTALL_DIRECTORY=D:\home\siteextensions\Contrast.Net.Azure.SiteExtension\ContrastAppService\
MicrosoftInstrumentationEngine_ConfigPath32_ContrastX86Config=D:\home\siteextensions\Contrast.Net.Azure.SiteExtension\ContrastCieProfiler-32.config
MicrosoftInstrumentationEngine_ConfigPath64_ContrastX64Config=D:\home\siteextensions\Contrast.Net.Azure.SiteExtension\ContrastCieProfiler-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 COR_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 COR_PROFILER* variables will be used to load the Contrast agent.