Modify the AF Application Service connect string
- Last UpdatedNov 21, 2025
- 2 minute read
- PI System
- PI Server 2024 R2
- PI Server
During an AF Server installation, the PI AF Application Service is configured to connect with the PI AF SQL Server database. For some installation scenarios, you may have to manually update the connect string in the . If you are using a PI AF Azure SQL database, see the examples in the Modify the AFService.exe.config file.
Definition: The AFService.exe.config file is a standard ADO.NET connection string that defines the location of the Microsoft Azure, Amazon RDS or SQL Server PI AF database, and the security mode used to connect to the database.
This file can be edited to reflect your PI AF database configuration and other settings.
It is important that only authorized users have access to this file, as well as the
account used to run the PI AF Application Service.
Note: We recommend that you configure certificates for SQL Server installations. If you are unable to install certificates on SQL Server, then a self-signed certificate can be issued and trusted by updating "Trust Server Certificate=True" as shown in the following code examples.
-
In Windows Explorer, navigate to the %PIHOME64%\AF folder on the PI AF Application Service computer.
-
Use a text editor to open the PI AF Application Service configuration file, AFService.exe.config.
-
Enter the name of the remote SQL Server, and the named instance if applicable, in the connect string server.
Code example 1
This code example shows a modified connect string.
<?xml version="1.0" encoding="utf-8"?>
<configuration>
<appSettings>
<add key="connectString" value="Data Source=<SQLName>[\SQLInstance];Initial Catalog=<PIFD>;Persist Security Info=False;User ID=af_sql_user;Password=af_sql_password;Trust Server Certificate=True;Application Name="AF Application Server"" />
Code example 2
This code example shows syntax for a SQL Server that runs on a cluster. In this scenario, the IP address or computer name of the clustered resource is referenced.
<?xml version="1.0" encoding="utf-8"?>
<configuration>
<appSettings>
<add key="connectString" value="Data Source=<SQLClusterName>[\SQLInstance];Initial Catalog=<PIFD>;Persist Security Info=False;User ID=af_sql_user;Password=af_sql_password;Trust Server Certificate=True;Application Name="AF Application Server"" />
Code example 3
This code example shows a SQL Server that is configured to use SQL Server mirroring with inserted after the server name.
<?xml version="1.0" encoding="utf-8"?>
<configuration>
<appSettings>
<add key="connectString" value="Data Source=<SQLClusterName>[\SQLInstance];Failover Partner=<SQLServerName>[\SQLInstance];Initial Catalog=<PIFD>;Persist Security Info=False;User ID=af_sql_user;Password=af_sql_password;Trust Server Certificate=True;Application Name="AF Application Server"" />
You can modify attributes for the connect string, such as enabling encrypted communication or changing the authentication mode. For other options, see this Microsoft topic: SqlConnection.ConnectionString Property.
-
If the PI AF Application Service is running, stop and restart it for your changes to take effect.