Deploying an ASP.NET Blazor App to Azure using Octopus Deploy – Part 7 – Send a Notification to Microsoft Teams

What we did last time

In this series of posts we’re running through how to get Octopus Deploy setup, along with the required Azure Services, in order to deploy an ASP.NET Blazor app to Dev, Staging and Production environments.

In the previous post we created a Release of our Blazor WebAssembly app and view the deployed Web Apps in Azure.

What we’re doing this time

In this final post we’ll learn how to send Notifications of Releases to Microsoft Teams.

Contents

Part 1 – Environments and Deployment Targets
Part 2 – Linking Azure
Part 3 – Create Azure Web Apps + Staging and Production Deployment Targets
Part 4 – Create and Package a Blazor WebAssembly App
Part 5 – Octopus Deploy Projects, Variables and Processes
Part 6 – Create a Release
Part 7 – Send a Notification to Microsoft Teams

Prerequisites

Once again, for this tutorial you’ll need the following;

Sending Notifications to Microsoft Teams

Another great feature of Octopus Deploy is its ability to send notifications to other applications.

We can, for instance, send a notification to Microsoft Teams when our deployments complete.

To achieve this we need run through a couple of steps.

As a note, you’ll need a teams environment with the relvant access to complete these steps.

Setup Microsoft Teams to provide a WebHook

The first thing we need to do is configure Microsoft Teams correctly to receive a WebHook call from our Octopus Deploy instance.

If we open Microsoft Teams up, we can create ourselves a new channel to receive the notifications. We can do this by hitting the menu button next to our team name;

Microsoft Teams – Add Channel Menu Item

We can then click the “Add channel” menu item which will allow us to name our channel;

Microsoft Teams – Add Channel Dialog

We’ll name our channel “OctopusNotifcations”, and hit the “Add” button to add the new channel.

We’ll then see our new channel in the list. We can then add a WebHook connector to our channel, if we click the menu next to our “OctopusNotifcations” Channel and hit the “Connectors” menu item;

Microsoft Teams – Connectors Menu Item

We’ll then be shown the list of connectors we can choose from;

Microsoft Teams – Incoming Webhook Add Button

We should see an “Incoming Webhook” item in the list. If not, we can search for it using the search box on the left.

If we then click the “Add” button next to the “Incoming Webhook” item.

We’ll then be shown some information about this connector, and we can hit the “Add” button to add this to our Channel;

Microsoft Teams – Incoming Webhook Information Add

We can now configure our Webhook connector by returning to the Connectors page using the menu to the right of our “OctopusNotifications” channel and hitting “Connectors” again;

Microsoft Teams – Connectors Menu Item

We’ll then be shown our list of available Connectors. If we hit the “Configure” button next to our new “Incoming Webhook” connector;

Microsoft Teams – Incoming Webhook Configure Button

We’ll then be taken to the configuration page for our connector;

Microsoft Teams – Configure Incoming Webhook

We can enter a name for our connector in the first box, we’ll choose “OctopusHook”.

We can leave the image as it is and then hit the “Create” button to create our Webhook;

Microsoft Teams – Incoming Webhook Create Button

If we then scroll down to the bottom of the dialog, we’ll see our Incoming Webhook URL, where we can hit the copy button to copy that for later;

Microsoft Teams – Incoming Webhook URL

We can then close the dialogs that are open and switch over to Octopus Deploy to configure it to send our notifications.

Add Microsoft Teams Step to Octopus Deploy

Now that we have Microsoft Teams setup,

To add another step to our deployment process. If we navigate to our Deployment Process page. We can do that by navigating to Projects, selecting our Project and selecting the “Process” item from the menu on the left;

Octopus Deploy – Add Step to Deployment Process

If we click the “ADD STEP” button at the top right of the page, we can add our new notification step;

Octopus Deploy – Add Deployment Process Step – Community Steps Button

We’ll then be shown the list of community contributed steps available to us, with everything from Azure Devops, through DLLs and son on.

Scrolling down, you’ll find a “Microsoft Teams” item;

Octopus Deploy – Community Steps – Microsoft Teams

Clicking the “Microsoft Teams” Item will show us the “Microsoft Teams – Post a message” Step option ;

Octopus Deploy – Community Steps – Microsoft Teams Post a Message

If we then click the “Microsoft Teams – Post a message” Step option, we’ll be shown the “Install and add” dialog for this step;

Octopus Deploy – Community Steps – Microsoft Teams Post a Message – Install and Add

We can click the green “SAVE” button to install this step and add it to our Deployment Process.

We’ll then be shown the setup page for our new step;

Octopus Deploy – Community Steps – Microsoft Teams Post a Message – Setup

We can leave the “Step Name” at “Microsoft Teams – Post a message”, we can then enter some notes to describe this step… We’ll enter “Post a message”.

We can leave the “Enabled” checkbox checked and leave the Execution Location as the default of “Run on each deployment target (default)”.

Once again, we can select the “Web” role from the “Runs on targets in roles” dropdown;

Octopus Deploy – Community Steps – Microsoft Teams Post a Message – Select Role

The next item to complete is the Webhook URL. We took a copy of this from teams earlier, so we can paste that in now;

Octopus Deploy – Community Steps – Microsoft Teams Post a Message – Webhook URL

We can leave all of the other options at their default and hit the green “SAVE” button in the top right hand corner.

We’ll be shown the summary of the step we’ve just added;

Octopus Deploy – Community Steps – Microsoft Teams Post a Message – Summary

Create one more Release

Now that we’ve got everything set up, we can create one more release and see the notification in Microsoft Teams.

If we scroll to the left if needed and hit the “CREATE RELEASE” button on the left;

Octopus Deploy – Create Release Button

Once again, we’ll be shown the Release Information, where we can hit the green “SAVE” button;

Octopus Deploy – Save Release Button

We can then hit the “DEPLOY TO DEVELOPMENT” button;

Octopus Deploy – Deploy To Development Button

Finally, we can then hit the “DEPLOY” button on the summary page to begin our deployment to Development;

Octopus Deploy – Deploy Button

See our Notification in Teams

Once the deploy has completed, if we return back to teams, we should see our new notifcation appearing in our channel;

Microsoft Teams – Octopus Deploy Notification

Summary

So, with that we’ve set up our Octopus Deploy Instance to deploy a Blazor app to Development, Staging and Production environments as well as send a notification to a teams instance.

If you want to continue learning about Octopus, I can highly recommend their Documentation!