Note: Development and Testing purposes only. Not supported in production environments.
For instructions on how to spin up a PI Web API container, please see Spin up PI Web API in less than 3 minutes
For instructions on how to spin up a PI Data Archive container, please see Spin up PI Data Archive in less than 10 seconds
Currently, in order to set up an AF Server for testing/development purposes, you have two choices.
1. Install SQL Server and AF Server on your local machine
The problem with this method is that there is no isolation from the host operating system. Therefore, you risk the stability of the host computer if something goes wrong. You also can't spin up multiple AF Servers this way.
2. Provision a VM and then install SQL Server and AF Server on it
While this method provides isolation, the problem lies in the time it takes to get it set up and also the size of the VM which includes many unnecessary components.
There is a better way!
Today, I will be teaching you how spin up AF Server instances in less than 2 minutes (after performing the initial setup which might take a bit longer). This is made possible by the usage of containerization technology.
Windows Server build 1709, Windows Server 2016 (Core and with Desktop Experience) or Windows 10 Professional and Enterprise (Anniversary Edition). Ensure that your system is current with the Windows Update.
1. Portability. Easy to transfer containers to other container hosts that meet the prerequisites. No need to do tedious migrations.
2. Side by side versioning. Ability to run multiple versions of AF Server on the same container host for compatibility testing and debugging purposes.
3. Speed. Very fast to deploy.
4. Resource efficiency and density. More AF Servers can run on the same bare metal machine compared to virtualization.
5. Isolation. If you no longer need the AF Server. You can remove it easily. It won’t leave any temporary or configuration files on your container host.
6. Able to use with container orchestration systems.
For Windows 10,
You can install Docker for Windows. Please follow the instructions here
For Windows Server 2016,
You can use the OneGet provider PowerShell module. Open an elevated PowerShell session and run the below commands.
Install-Module -Name DockerMsftProvider -Repository PSGallery -Force Install-Package -Name docker -ProviderName DockerMsftProvider Restart-Computer -Force
Install AF Server image
Run the following command at a console. When prompted for the username and password during login, please contact me (firstname.lastname@example.org) for them. Currently, this image is only offered for users who already have a PI Server license or are PI Developers Club members (try it now for free!). You will have to login before doing the pull. Otherwise, the pull will be unsuccessful.
docker login docker pull elee3/afserver:2017R2 docker logout
Now that the setup is complete, you can proceed to running the container image. To do so, use the following command. Replace <DNS hostname> and <containername> with one of your own picking. This will take less than 2 minutes. Remember to pick a DNS hostname that is unique.
docker run -di --hostname <DNS hostname> --name <containername> elee3/afserver:2017R2 cmd
You can now open up PI System Explorer on your local machine and connect to the AF Server by specifying the DNS Hostname that you chose earlier. When prompted for credentials, use
User name: afadmin
Check the box to remember the credentials so that you won't have to enter it every time.
You can choose to rename the AF Server if you wish.
And you are done! Enjoy the new AF Server instance that you have created!
Using with AF SDK
To connect to the AF Server from code using AF SDK, the following Connect overload can be utilized with the same credentials as above.
Multiple AF Servers
In order to spin up another AF Server instance, follow the steps above. When you get the new container running. You have to change the ServerID. You can do this via
docker exec -i <containername> cmd /c "cd %pihome64%\af&afdiag.exe /cid:<guid>"
You can generate a new guid using this.
Destroy AF Server
If you no longer need the AF Server, you can destroy it using
docker stop <containername> docker rm <containername>
Thanks for reading and have a nice day!
New updates (14 Feb 2018)
1. 2017R2 tag is now available. Commands have been updated in the blog.
2. Image has been updated with ability to import in an existing AF Server backup in the form of PIFD.bak file. To do this, run
docker run -di --hostname <DNS hostname> --name <containername> -v <path to folder containing PIFD.bak>:c:\db elee3/afserver:2017R2 migrate.bat