As part of an experiment, I looked at running the new PnP Core SDK preview 3 on my Raspberry Pi 4, and it worked like a charm! So I will take you through an overview of running the latest SDK on these cool devices.
What is the PnP Core SDK?
This is the newest core component currently under development (Preview 3) that will become the next generation of PnP Sites Core, designed to provide a unified object model written in ASP.NET for the Microsoft 365 ecosystem. The new SDK will:
- Support for Microsoft Graph first, then Rest API, CSOM for SharePoint – this is taken care of under the hood, providing a standard model across these services.
- Support for Microsoft 365 workloads initially SharePoint and Teams but looking at extending to additional workloads.
- High-quality engine with over 80% unit test coverage with mocking features to speed up local testing
- Designed to be used in modern ASP.NET techniques relying on Dependency Injection, Generic Host for services
- Uses ASP.NET Standard v2 with support for running non any OS including my Raspberry Pi.
Naturally, with this being a new framework currently in preview and wanting to contribute towards the project, as part of my work with the PnP Core team, I will explore whether this can run on these small devices combining two of my hobbies.
Setting up a Raspberry Pi
A Raspberry Pi is a small cheap (£30-50 or the smaller Pi Zero at £12) Linux based computer typically used for tinkering, IoT projects, experiments etc. Nowadays contains decent processing power for the cost, you can run perform a range of experiments from click button analogue to more intelligent projects, weather monitoring stations, even photography. An example personal project, I built a simple monitor to collect environmental data inside an enclosure for my 3D printer, streaming the data to Azure IoT, using Azure Stream Analytics to produce a Power Bi dashboard from the sensor data.
For this experiment, I wanted to prove that I can combine a Raspberry PI and the PnP Core SDK together. I created a basic app in Visual Studio on my desktop to connect to SharePoint Online to grab some data and display in a console testing the cross-platform support.
First your need to setup ASP.NET on the Raspberry Pi, you can find the details of the install on https://docs.microsoft.com/en-gb/dotnet/core/tools/dotnet-install-script specifically installing the ARM32 Linux version. To install, run the following commands below, to download the install script from Microsoft and to amend your profile to run the SDK from any location:
Using the PnP Core SDK, I wrote a small console app in Visual Studio (the full-fat desktop version), this app connects to SharePoint using a username and password combination, I have placed the full sample at https://pnp.github.io/pnpcore/demos/Demo.RPi/README.html this includes the source code, instructions on getting started. You can download the code and run the app by:
In Documents folder, use git clone https://github.com/pnp/pnpcore.git # Update the settings file nano ~/Documents/pnpcore/src/samples/Demo.RPi/appsettings.json # Update according to article cd ~/Documents/pnpcore/src/samples/Demo.RPi # Build the app dotnet build # Run the app dotnet run
Whilst an elementary example does show the demonstrate OS support and a new range of options when considering IoT devices and solutions. There are other samples available within the project for you to explore such as Blazor, Azure Functions, ASP.Net Core and WPF examples. Check out the PnP Core SDK site samples for further demos of the SDK capabilities: https://pnp.github.io/pnpcore/demos/README.html
Update: I’ve added instructions on installing ASP.NET onto a Raspberry Pi, and executing the App from a vanilla Raspberry Pi
Sharing is Caring – Enjoy!