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.
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.
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:
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!