Automating delivery of Message Center posts to Teams and Outlook using an Azure function

5/11/18: Updated with link to new blog post.

In a previous post, Using O365 APIs and PowerShell to access Intune messages from Message Center in Office 365, we shared how you could pull in all your Intune messages into a PowerShell Window. Now as a follow up to that post, we'll share how to get these messages into a Teams channel or delivered as emails into your Outlook inbox. The script also has the option to automate delivery of messages on a timer using an Azure function. We have an updated version of that script here: GetMessagesToTeamsAndOutlook

Using Connectors to deliver messages to Teams and Outlook

We’ve modified the script we shared in our previous post, to call a Teams and/or Outlook Webhook Connector from PowerShell. 

There is a quick one-time process to add an Incoming Webhook connector to your Teams channel and Outlook Group or account. Doing so will get you a webhook URI that you’ll hardcode into the script linked above.

Getting a webhook URI for a Teams channel

Detailed steps are listed here: Post notifications to Microsoft Teams using PowerShell

  • Open the Channel and click the More Options button (which appears as three dots at the top right of the window).
  • Select Connectors > Incoming Webhook > Add.
  • Give the connector a name and image (optional) of your choosing and finally click Create.
  • A new unique URI is automatically generated. Copy this URI string to your clipboard.
  • You can retrieve this in the future from this same configuration area of Teams. Select the Connector and then click the Manage button to reveal the URI string.

Getting a webhook URI for Outlook

Detailed steps are listed here: Accessing Office 365 Connectors from Outlook

  • Access Outlook on the web by navigating to
  • In the Office 365 Mail app, go to Settings in the upper right-hand corner. For Groups, click on the Group and go to Group Settings in the upper right-hand corner.
  • Click Manage Connectors > Incoming Webhook > Add.
  • Give the connector a name and image (optional) of your choosing and finally click Create.
  • A new unique URI is automatically generated. Copy this URI string to your clipboard.

Now that you have a way of pulling these messages out of the Office 365 admin portal, the next step is to make things easier by automating this process. You probably have your own preferences and tools for doing this. Here, we’re sharing how you can use Azure functions to run the script on a timer. Another way to do this is in this blog post: Using Azure runbooks to get Intune messages delivered on a schedule

Creating an Azure function to run the script on a timer

The first step is to create an Azure function that is triggered by a timer. More details can be found here: Create a function in Azure that is triggered by a timer

At, go to Create a Resource >> Compute >> Function App

Enter a name for your function. The rest of the fields will autofill. Click Create.

Click on notification icon in the upper right-hand corner to see if your deployment was successful. Click ‘Pin to Dashboard’ to make it easier to find your function.

Expand your function that is now open and click on the + button next to Functions. Click on ‘create your own custom function’.

Change toggle for experimental language support to Enabled.

Search for the function Timer Trigger and open the template.

Choose language with the default timer schedule which is a six field CRON expression. Click create.

Expand the function and click Integrate to make any further changes to the timer schedule after you’ve created the function or any time in the future. Expand Documentation to see examples of different schedule expressions.

Now comes the time to make changes to your settings. Click on your function which is named TimerTriggerPowerShell1 in this screenshot.

Modifications to Function App Settings:
- If you are planning to run the GetMessagesTeamsOutlook script via the TimerTrigger Azure function, modify the script to use the EnsureADModuleInAzureFunction instead of EnsureAzureADModule.

- Configure FTP/Deployment credentials in Azure by going to your Function App >> Platform features >> Deployment credentials, using the steps detailed here under the section titled "Where can I store ...". This username and password will be the same across all apps in all subscriptions associated with your Microsoft Azure account.
- Use the FTP Hostname or FTPS Hostname and with an FTP client of your choice to upload the DLLs shown in the next step.
- To use EnsureADModuleInAzureFunction, the two DLLs in the script shown in the screenshot below need to be uploaded to the Azure function app. Note: These files will be on your machine if you have run the GetMessages script once locally. Depending on your Azure function app name and upload folder, you will need to modify the path specified in this portion of the script: “TimerTriggerPowerShell1\AzureAd”

Here’s where you’ll paste in your GetMessagesToTeamsAndOutlook PowerShell script with your credentials and URIs filled in. Before using the Azure function for automation, the script needs one more modification. Be sure to uncomment and call EnsureAzureADModuleInAzureFunction instead of EnsureAzureADModule in the script.

Click Save. Message Center posts will now automatically be delivered to either Teams or Outlook or both, depending on what you’ve chosen, on the schedule that you have configured in your TimerTrigger function.

We hope this gives you more flexibility with where you receive your message center posts! Let us know if you have any questions or suggestions.

Skip to main content