Note: Development and Testing purposes only. Not supported in production environments.
For instructions on how to spin up a PI Data Archive container, please see Spin up PI Data Archive in less than 10 seconds
Following my previous blog post on spinning up the AF Server in less than 2 minutes,
I now present to you another blog post in this containerization series on spinning up PI Web API in less than 3 minutes (My test came out to be 2 min 44 sec!). If you are unfamiliar with the concept of containerization, please refer to the blog post mentioned above. Alternatively, you can attend my talk during PI World 2018.
Day 3, 26 April 2018: Developer Track 5 (10:30am to 12:15pm)
Topic: How to Put Your AF Server into a Container
Venue: PARC 55 Hotel, Market Street, Level 3
I will repeat the steps here for setting up Docker for your convenience. If you have already done so while using the AF Server image, then you do not need to repeat it again. The PI Web API image offered here is fully self contained. In other words, you do not have to worry about any dependencies such as where to store your PI Web API configuration. In a later blog post, I will be posting on a PI Web API image that only contain the application service for those of you who truly want a microservices architecture. In that image, you will need to furnish your own AF Server then. For now, you do not have to care about that.
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 PI Web API 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:piwebapi 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. Remember to pick a DNS hostname that is unique.
docker run -it --hostname <DNS hostname> --name <containername> elee3/afserver:piwebapi
After about 3 minutes, you will see that the command prompt switches to
This indicates that your PI Web API is ready for usage. At this point, you can just close the window.
Now you can open a browser on your container host and connect to it with the DNS hostname that you chose earlier.
When prompted for credentials, you can use
User name: afadmin
Browsing your PI Data Archive
You can use a URL of the form
https://<DNS hostname>/piwebapi/dataservers?path=\\<PI Data Archive hostname>
to access your PI Data Archive. Of course, you need to give access permissions by creating a local user on the PI Data Archive machine with the same username and password above and give a PI mapping to that user.
Browsing your AF Server
You can use a URL of the form
https://<DNS hostname>/piwebapi/assetservers?path=\\<AF Server hostname>
to access your AF Server. Again, you need to give access permissions by creating a local user on the AF Server machine with the same username and password above. By default, everyone has World identity in AF Server so you do not need to give any special AF mapping.
Multiple PI Web API instances
You can spin up several PI Web API instances by using the docker run command multiple times with a difference hostname and containername.
You can see above that I have spin up several instances on my container host.
Destroy PI Web API instance
If you no longer need the PI Web API instance, you can destroy it using
docker stop <containername> docker rm <containername>
Observe that the steps to deploy both the AF Server and PI Web API containers are quite similar and can be easily scripted. This helps to provision testing environments quickly and efficiently which helps in DevOps.