Configuring .NET Agent for use in Azure App Services
tCell Azure web app Agent can be installed using a NuGet package available on nuget.org. The following guide outlines the steps for adding and configuring this agent within an ASP.NET MVC application starting with initial creation of the solution.
Prerequisites
- A tCell account setup
- An application created (Admin > Applications)
- Download the agent config file:
- Click tCell Admin in top menu.
- Click Download Agent.
- Select the .NET agent.
- Click Download Config File to download the agent's config file that is pre-populated with the application and API key information.
Initial Setup
The initial solution creation shown mostly for reference
The Web Application shown here will be a the default ASP.NET Framework MVC template, again provided for reference.
To add the tCell agent the Tcell.AspNet.Agent.AzureWebApp nuget package will need to be added to the web application project.
The tCell Agent runs as an HTTP Module, for Azure App Services this should be included in web.config.
After you complete these steps, the application can be published to Azure using the processes already in place, further guidance on this can be found in at https://docs.microsoft.com/en-us/aspnet/web-api/overview/data/using-web-api-with-entity-framework/part-10 or within Microsoft's documentation.
Agent Configuration
The agent can be configured in one of two ways:
Option 1: Include the tcell_agent.config in the web app
Include tcell_agent.config in the web application project and configure it to copy to the output folder, so that it will be included in the published application.
Option 2: Include environment variables
Each of the values shown in the download tcell_agent.config have equivalents in Environment variables which can be found at https://docs.rapid7.com/tcell/server-agent-options/#tcell_agent_app_id.
By default, the following environment variables should be included, the values for these can be found in tcell_agent.config:
- TCELL_AGENT_APP_ID - "app_id"
- TCELL_AGENT_API_KEY - "api_key"
- TCELL_AGENT_API_URL - "tcell_api_url"
- TCELL_AGENT_INPUT_URL - "tcell_input_url"
- TCELL_AGENT_JS_AGENT_API_URL - "js_agent_api_base_url"
You can add the environment variables in Application Settings for the App within the Azure Portal.