Following up on last weeks post, this week we will look at using our Azure Function app to post work item information from a custom task in the Cireson Portal to Slack.



Using Azure Functions to Post to Slack from Multiple Sources – Part 1

Today, I’m starting a new short series demonstrating how we can easily integrate multiple internal and external systems to bring data into Slack using a single Azure function.

The idea here is to define a single simple web based API using the capabilities of Azure Functions in order to provide a company standard format for pushing notifications into Slack from multiple sources.

For my part I’m going to show how to setup the Azure Function, code the integration into Slack, how to trigger the function, and then how to trigger and test that Azure function. In subsequent posts we’ll show how to trigger it from other related systems.

Continue reading “Using Azure Functions to Post to Slack from Multiple Sources – Part 1”

SCSM + Cireson Portal API + Slack = Better Together, Part 2

Assuming that you’ve read part 1, you know we are now going to look at how to get data out of SCSM and into Slack without having to be proactive about it. Rather than having to reach into SCSM and get the data, we are going to look at how SCSM can alert us in Slack to changes that are occurring from within.

This is actually quite easy, and we will look at more complicated and comprehensive scenarios for this in the future, but I want to touch on something just about anyone with a little PS knowledge could emulate.

With that in mind our example today will use nothing more than powershell and our own little custom module.

Continue reading “SCSM + Cireson Portal API + Slack = Better Together, Part 2”

SCSM + Cireson Portal API + Slack = Better Together, Part 1

This is an updated post, the original is found here.

As the services lead for Cireson I’m always looking for new ways to facilitate communication among my team. We have many brilliant people here and increasing the efficiency of our communication is a part of what separates us from the pack. We have a mantra here at Cireson that says when we tackle an engagement we ‘bring the team’ and that is more true today than it ever has been, and It’s my job to make sure that gets better and better.

In that regard we’ve been using Slack to improve our inter-team communication. I won’t go into the details of Slack or it’s capabilities here, other than to say that is is a Web 2.0 IRC like chat client and more. It has dramatically increased our real-time communication within the team and improved our knowledge and solution retention, but for this article I’ll focus on a feature called ‘slash commands’.

In essence a Slash Command is a user configurable API call to an outside web interface using a JSON formatted payload. At a higher level it’s a command that sends out a request to another website for information or to post information. Here is an example:
In this example I can type a simple command:

/getkb 75

And I’ll get this Knowledge Base article summary back from our Cireson Support Portal:


Now, this is just one example. We’ve also integrated Incident retrieval, knowledge article search, daily new knowledge article and new announcement notifications, and soon we will include a notification for new incidents that have been created.


All of this provides us with easy access to the things we use most often within a single interface. It also works via the mobile Slack application and brings the needed information directly into the conversation within the context of the request. It’s even searchable later and the answer (KB) is displayed right inline with the question or discussion.

I know, this all sounds great, but how does it work!? At a high level it works like this:

  • We setup a Slash command for each function in the Slack admin settings and point it to our custom web service
  • Each time the Slash command is run it sends the requested information to our custom web service that pulls required information out of the payload
  • The web service then utilizes the Cireson Portal API to retreive the required information, translate it into a format that works with Slack and then posts it back into the channel in which the request originated
  • For the scheduled tasks and notifications we use a simple Azure webjob that runs on a schedule, hits the web service and performs that same operations depending on the task

All of this is made possible thanks to the Cireson Portal API, where we can use an authentication token to perform JSON calls and retrieve data from Service Manager easily in order to put that data anywhere and in any format we could want.

In later blogs I’ll go into further detail on the Cireson Portal API, how it’s used and the internals of the custom web service we’ve created to utilize it. Beyond that though, what if we wanted to get data out of Service Manager and into Slack?

That will be the focus on my next blog in this series.

Using LINQPad with Azure Table Storage

First, we need to load up LINQPad (I’m using V5) and creation a new connection. We will use the Azure Storage Driver for this.


Then we will enter the required credentials in order to create the connection with our storage account.


Once we’ve completed this process we can easily run C# expressions again our table using LINQ syntax. Let’s look at a few examples.

Viewing all entries:


Viewing a specific entry by a simple where criteria:


Now if we wanted to do something more complex, say delete all of the entries in a table or just a specific set of entries then we need to expand our process a bit. We can use the language type of “C# program” to build an actual C# program in LINQPad.

First, for this to work we need to add some DLL and Namespace references using the query properties.

Once we’ve added these references we can write a simple void Main() program and pretend like we are working with the table in C#.

In this example we are creating a storage account variable by using the CloudStorageAccount.Parse command to parse the connection string that Azure gives us.

Then we create a table client, pull in our table, and query it for all the entries with a specific partition key.

Finally, we run all the discovered queries through a loop and delete them.

Deleting an entry using a C# program layout:2016-04-13_12-09-02

Keep in mind this is a very simple example and does not take into account batches, continuation tokens, or any sort of API limits (of which there are a few you should be aware of).

Hope this helps get you started!

Lost Single Item Array in Powershell Array to JSON Conversion

I thought I would throw this out there for anyone possibly running into this issue. Basically, when converting a PSObject to JSON in Powershell, I had an array that only had one value in some cases. When this happened the conversion would unpack the array and I would get the @{} at the root level of the property instead of an array:

Continue reading “Lost Single Item Array in Powershell Array to JSON Conversion”

Modify WorkItem Title When Creating Via Template / Projection

Quick one today. I ran into a bit of an issue when creating a new SR via an object projection and applying a template.

#projection setup
$TemplateObject = Get-SCSMObjectTemplate -Id $TemplateId
$TemplateMP = $TemplateObject.GetManagementPack()
$mpAlias = $TemplateMP.References.GetAlias((Get-SCSMManagementPack system.workitem.library))
foreach ($obj in $TemplateObject.ObjectCollection)
   fn_UpdatePropertyCollection -Object $obj -Alias $mpAlias

#get the new status for workflows
$statusNewEnum = Get-SCSMEnumeration ServiceRequestStatusEnum.New

$seedTypeSR = '^System.WorkItem.ServiceRequestProjection$'
$seedclassSR = Get-SCSMClass -Name System.WorkItem.ServiceRequest
$seedPropertyValuesSR = @{
CreatedDate = (Get-Date)
   Id = "SR{0}";
   Status = $statusNewEnum;
   Title = $afUser.DisplayName

$seedProjectionSR = @{
   __CLASS = "System.WorkItem.ServiceRequest"
   __OBJECT= $seedPropertyValuesSR
   CreatedBy = $AffectedUser
   AffectedUser = $AffectedUser
   AssignedTo = $AssignedUser

$newSrProjection = New-SCSMObjectProjection -Type $seedTypeSR -Projection $seedProjectionSR -Template $TemplateObject -PassThru -ErrorAction SilentlyContinue

When the template was applied it was overwriting my title. To remedy this, I had to dynamically modify the title within the template itself using this code:

#update the template title with the affected users displayname
foreach ($obj in $TemplateObject.PropertyCollection){
   if($obj.Path -like '*Title$'){
      $obj.MixedValue = $afUser.DisplayName + " - " + $obj.MixedValue

Hope this helps someone else!

Automation Series 1, Part 4: Azure Automation


If you’ve been following along with our series you now have a beautiful Power BI dashboard for your incidents that is using real data injected directly into Power BI from SCSM using Powershell and the Power BI API.

All that to say, we are missing one very important capability, and that’s how we update the data regularly without the SCSM admin having to log into the system in the middle of the night to refresh the data for the CIO currently in the UK. This is where Azure Automation comes in.

Continue reading “Automation Series 1, Part 4: Azure Automation”