Running #ProjectOnline #PowerShell in #Azure using #AzureFunctions #PPM #Cloud #Flow #LogicApp Part1

July 28, 2017 at 4:50 pm | Posted in Add-on, Administration, App, Configuration, Customisation, Fixes, Functionality, Information, PowerShell, Workflow | 4 Comments
Tags: , , , , , ,

Following on from my last post where I published an example solution starter PowerShell script for adding project team users to the Project Site, here I mentioned about running the script in an Azure Function and even running this sync from a Project Online event. The blog post can be seen below if you missed that:

https://pwmather.wordpress.com/2017/07/07/projectonline-project-user-sync-to-project-sites-ppm-o365-powershell-sharepoint/

Whilst I will use that example PowerShell script from my last blog post as an example, the concept will work for any PowerShell script.

I wont cover the details in setting up the Azure Function in part 1 as there is plenty of support out there for this – for this example I created an Http Trigger – PowerShell function.

image

I then uploaded the SharePoint DLLs and copied in the PowerShell script into the editor:

image

The project site user sync script didn’t work as is as I had to make some minor changes to get this to run from the Azure Function. This included change the way the SharePoint CSOM DLLs where loaded in. In the example script I used Add-Type to load the DLLs but in the Azure Function I had to switch this out to use Import-Module:

image

The next change I had to make was to comment out all of the feedback to the console, so all of the write-hosts. I also had to remove the functions within the script so that is was one block. After these changes I could execute the PowerShell script to add the project team members from my example project into the associated project site from the Azure Function. As this was an HTTP Trigger Azure Function, you can get the URL to the function and access that URL to execute the function.

This opens up lots of possibilities to easily execute this Azure Function from other applications that can make the HTTP call. For example you build easily execute this script once the project has been published either using a remote event receiver (RER) or a Microsoft Flow / Azure Logic App. The example script would need to be made generic and pass in a variable into the Azure Function for it to be a workable solution.

In part 2 of this blog post we will look at make a full event driven solution that is fired on project publish then executing the Azure Function and passing in a variable.

Advertisements

4 Comments »

RSS feed for comments on this post. TrackBack URI

  1. Great post Paul. You’ve got me wondering about some Flow examples for both Project and Planner!

    • Thanks Brian. That would be good, could push certain tasks from Project into a Project in Planner maybe?

      • Yes, something like that. Just got your sample working against my test PWA – thanks again Paul. I’d been meaning to play more with Azure functions.


Leave a Reply

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

WordPress.com Logo

You are commenting using your WordPress.com 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 )

Google+ photo

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

Connecting to %s

Blog at WordPress.com.
Entries and comments feeds.

%d bloggers like this: