# Integrate Sitefinity CMS with Azure Application Insights

You can integrate your Sitefinity CMS application with *Azure Application Insights* to monitor application performance, track custom events, and gain visibility into system behavior.

## Install the Progress.Sitefinity.AppInsights package

1. Open the project where you want to install the add-on in Visual Studio.
2. Navigate to *TOOLS* » *Library Package Manager* » *Package Manager Console*.
3. In the command line, enter `Install-Package Progress.Sitefinity.AppInsights`.

This package enables Sitefinity-specific telemetry and logs to be sent to Application Insights.

## Enable Sitefinity logging for Application Insights

1. After installation, open your project’s web.config file.
2. Add the following key under the `<appSettings>` section:\
   `<add key="APPINSIGHTS_ENABLESITEFINITYLOGGING" value="True" />`

This enables Sitefinity’s internal logging to be captured by Application Insights.

## Configuration for Sitefinity hosted on Azure App Service

When Sitefinity is hosted in Azure App Service, use the following steps to connect your application to Application Insights.

1. Navigate to your App Service in the Azure portal.
2. In the left-hand menu, select *Configuration* under the *Settings* section.
3. Add a new Application setting:
   * Name: `APPLICATIONINSIGHTS_CONNECTION_STRING`
   * Value: your_connection_string
4. Save your changes.

Your Sitefinity instance will now automatically send telemetry data to Application Insights using the specified connection string.

## Configuration for On-Premise Installations (IIS/Virtual Machines)

If you are hosting Sitefinity on-premise, follow these steps:

1. Install the NuGet package.\
   Install `Progress.Sitefinity.AppInsights` in your Sitefinity project as shown above.
2. Create an Application Insights instance.\
   In the Azure portal, manually create an Application Insights resource.
3. Remove legacy instrumentation key.\
   Open your web.config file and delete any entry for `APPINSIGHTS_INSTRUMENTATIONKEY`.
4. Adjust IIS configuration validation.\
   Find all occurrences of the `validateIntegratedModeConfiguration` setting in the web.config file and set the value to `false`.
5. Enable Sitefinity logging.\
   Add the following key under `<appSettings>` if not already present:\
   `<add key="APPINSIGHTS_ENABLESITEFINITYLOGGING" value="True" />`
6. Set the connection string.\
   Open the ApplicationInsights.config file (this file is generated automatically after the NuGet package installation) and insert your connection string before the closing `</ApplicationInsights>` tag:\
    `<ConnectionString>your_connection_string</ConnectionString>`
7. Restart your Sitefinity site.\
   Restart the application pool or IIS site to apply the changes.
