Use Azure Service Fabric with the .NET Framework or .NET Core agent
If you are using a container image, follow the instructions to install in containers. Otherwise, to add the Contrast .NET Framework or .NET Core agent to an Azure Service Fabric service:
Tip
For Standalone Executable services, the ServiceManifest.xml file is located in the top-level Azure Service Fabric project (for example, the .sfproj file).
Install the appropriate NuGet package to the main project for the service.
.NET Framework: Install
Contrast.NET.Azure.AppService
. All files in the contrastsecurity folder must haveCopy to Output Directory
set toCopy if newer
..NET Core: Install
Contrast.SensorsNetCore
. All files in the contrast folder haveCopy to Output Directory
set toCopy if newer
.
Set
ServiceManifest/CodePackage/EntryPoint/ExeHost/WorkingDirectory
in ServiceManifest.xml toCodePackage
.<CodePackage Name="Code" Version="1.0.0"> <EntryPoint> <ExeHost> <Program>DemoNetFxStatelessService.exe</Program> <WorkingFolder>CodePackage</WorkingFolder>
Set environment variables in ServiceManifest.xml to configure the profiler.
.NET Framework:
<CodePackage> <EnvironmentVariables> <EnvironmentVariable Name="COR_ENABLE_PROFILING" Value="1"/> <EnvironmentVariable Name="COR_PROFILER" Value="{EFEB8EE0-6D39-4347-A5FE-4D0C88BC5BC1}"/> <EnvironmentVariable Name="COR_PROFILER_PATH_32" Value=".\contrastsecurity\ContrastProfiler-32.dll" /> <EnvironmentVariable Name="COR_PROFILER_PATH_64" Value=".\contrastsecurity\ContrastProfiler-64.dll" /> <EnvironmentVariable Name="CONTRAST_CONFIG_PATH" Value="contrast_security.yaml"/>
.NET Core:
<CodePackage> <EnvironmentVariables> <EnvironmentVariable Name="CORECLR_ENABLE_PROFILING" Value="1"/> <EnvironmentVariable Name="CORECLR_PROFILER" Value="{8B2CE134-0948-48CA-A4B2-80DDAD9F5791}"/> <EnvironmentVariable Name="CORECLR_PROFILER_PATH_32" Value="contrast\runtimes\win-x86\native\ContrastProfiler.dll"/> <EnvironmentVariable Name="CORECLR_PROFILER_PATH_64" Value="contrast\runtimes\win-x64\native\ContrastProfiler.dll"/> <EnvironmentVariable Name="CONTRAST_CONFIG_PATH" Value="contrast_security.yaml"/>
Configure the agent with either:
A YAML file: Add it to the main project for the service. Make sure
Copy to Output Directory
for the file is set toCopy if newer
. Add an environment variable to ServiceManifest.xml specifying the location of the file, like this:<CodePackage> <EnvironmentVariables> <EnvironmentVariable Name="CONTRAST_CONFIG_PATH" Value="contrast_security.yaml"/>
Environment variables: Add them to ServiceManifest.xml, like this:
<CodePackage> <EnvironmentVariables> <EnvironmentVariable Name="CONTRAST__API__URL" Value="https://teamserver-staging.contsec.com"/> <EnvironmentVariable Name="CONTRAST__API__API_KEY" Value="aBcD0123"/> <EnvironmentVariable Name="CONTRAST__API__SERVICE_KEY" Value="ABCD0123"/> <EnvironmentVariable Name="CONTRAST__API__USER_NAME" Value="agent_123@Team"/>
Deploy the Azure Service Fabric application as usual.