Deploying a Sharepoint App to Sharepoint Online

This article is about how I was able to use the SharePoint Modules to successfully deploy an application to SharePoint Online.

I’ve used some scripting before to update items in Sharepoint.  This blog article is how I took the build that IOZ tools creates and deploy it to Sharepoint Online.

First I needed to start with downloading the latest copy of SharePointPnPPowerShellOnline.

I discovered while using this module that there is the capability to add a PSDrive to my session.  This means I should be able to upload files to sharepoint as if it were a drive on my local machine.  Here is how you connect to sharpeoint online:

PS> Install-Module -Name SharePointPnPPowerShellOnline
$adminpassword = 'password'
$adminUserName = ''
$creds = $AdminPassword | ConvertTo-SecureString -AsPlainText -Force
$SPdevcredentials = New-Object -TypeName System.Management.Automation.PSCredential -ArgumentList $AdminUserName, $creds
connect-pnponline -Url $url -Credentials $SPdevcredentials -CreateDrive

Now that I have a connection to the SharePoint online instance I can see that I have a new powershell drive through the get-psdrive cmdlet:


As you can see I have a new drive that is configured for use in my session, directorying the SPO: drive will get the contents of the SharePoint Site:


My Applications are in my AppCatalog folder to get to that folder all I need to do is issue a CD to that directory.   To upload my App to this folder all I need to do is add it with Add-pnpFile.

2017-01-10 07_56_30.png

I seemed to have the best success when I used Get-Item (gi) and then used the fullname property for the file that I was sending to SharePoint. In addition one other gotcha was that the folder to upload to is a subfolder of the site you are connected to. In my case \sites\apps was my site I was connected to so specifying appcatalog was all I needed.

Now all that I needed to do was to put this in a script that  I could call from my CI automation and put some Error logic.  Now I have a full fledged script called deployspapp.ps1.   Full Source is found on my Gist:

I hope this helped someone

Until then keep scripting


Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s