How can I setup an Outlook notification webhook on Azure? - azure

Currently we have subscription in Office 365. All users has access to Outlook emails. We are planning to build a batch job using Daemon or Server application (as described here https://azure.microsoft.com/en-us/documentation/articles/active-directory-authentication-scenarios/#daemon-or-server-application-to-web-api). The reason for the batch job to be as Daemon service is because we wanted to access all user emails, filter and forward to another mail server with one app identity.
Question 1 : How can we grant an app in Azure to access all users emails ?
As an alternative we could also build a webhook that is subscribed to inbound/outbound emails and once we get a notification in our system we can filter/forward to another mail server. https://dev.outlook.com/restapi/concepts/webhooks
Instead of building a job and calling a REST API, is there a way to
register a webhook in Azure for all users at once and redirect the
url to our system ?
That will save us from building a batch job that has to run everyday to grab all incoming emails and then filter. If we can integrate a webhook all we have to build is just the filter/forward part.

The Webhooks are only supported for user level credentials. i.e Each user has to give the app a permission to request data on behalf of users. However, in our case, we need to get notifications for all user emails to reach our application and this is impossible to do at the time of writing (Sep 2016).
The solution we went forward is to build a batch job to pull all data. An Admin has to give an access to the application (the application will have its own identity) and make subsequent requests. For the app to identify itself, we have used X.509 certificate
We followed this documentation and this

If you want to redirect the specific messages with Office 365, a easy way is config the mail flow on the Exchange Admin Center.
For example, we can config a rule to redirect to the messages to the mailbox you wanted as below:
Here is the document for the mail flow rules for your reference.

Related

Azure Logic Apps - When a new email arrives workflow does not trigger

I'm trying to create an Azure Logic App Workflow to extract attachments when email arrives.
I have a workflow on my account to generate Logic App design.
This workflow is directly paste in our azuredeploy.json file to be deploy with our pipeline on the Azure Logic App main account.
This workflow works perfectly on my app but not in the deployed app. In the deployed app, when I send an email to test the workflow, it does not trigger the event like it does in my account.
It seems that our issue came from the office365 email that we specially created (which is different from ours) the be used to get email with attachments.
And now I just tried with the trigger "When a new email arrives in a shared mailbox" and it work exactly as expected. But it's not a shared mailbox !
Has anyone encountered this issue before?
I believe you have created your connection to Office 365 (Outlook) using your own account, which would explain why it works for you, and the Shared Mailbox (which only requires one having access to it).
However, your scenario requires the "delegated permissions" model, for which Graph API is better suited.
May I kindly suggest you read https://learn.microsoft.com/en-us/azure/connectors/connectors-native-http

Send azure monitor alert to slack not working

I am sure this has been asked many times but am unable to find relevant answer. Is there any way to send Azure monitor alerts to slack via Logic apps or some other way. I have found this template - https://github.com/Azure/azure-quickstart-templates/tree/master/demos/alert-to-slack-with-logic-app and integrated it into my azure system but it is not working.
Have tried some work around mentioned at - https://github.com/Azure/azure-quickstart-templates/issues/3319 but all in vain
Direct Webhook from action group using slack incoming webhook is not supported , as azure sends alert using its own schema.
Any input is highly appreciated ...
Azure Logic Apps is definitely an option, but if you are not needing complicated workflows, just send the alert directly from Azure Monitor to a Slack channel. You can do this by generating a unique email for the Slack channel and using that email in your Azure Monitor alert action group settings. Another option would be to send the alert to your company alert email inbox and have it automatically forwarded to that Slack channel email address. With this approach you completely remove the dependency and complexity of Azure Logic Apps.
https://slack.com/help/articles/206819278-Send-emails-to-Slack#h_01F4WDZG8RTCTNAMR4KJ7D419V

Accessing ms teams activity feed

Is there any way to send activities that are happening in external application to ms teams activity feed through any api.Now I have designed a blog where other users can like comment and follow my post in the blog.So I want to get all the activities that are happening in my blog to ms teams.
The Microsoft Graph REST API uses a webhook mechanism to deliver change notifications to clients. A client is a web service that configures its own URL to receive notifications. Client apps use notifications to update their state upon changes.
subscription operations require read permission to the resource. For example, to get notifications for messages, your app needs the Mail.Read permission.
Please look at change notification API

OAuth2 authentication for Microsoft Graph using service account credentials

I would like to create a webservice capable of automatically sending messages in Microsoft Teams. I tried authenticating as an application, but currently Microsoft does not support granting application permissions to send messages in Teams, so the only choice here is to authenticate using a service account with real credentials (Unless there is another way?). This method only specifies using user interaction to log in as a user.
I would like to use a service account teamchatbot#domain.com to authenticate with Microsoft Graph in order to send messages on Microsoft Teams. (similar to this but since I'm not accessing a resource it is a little different.) Is there a way I can silently obtain an access token on behalf of the service account in order to send messages?
It seems that you have a misunderstanding.
Your scene is actually the same as this post.
You should use Resource Owner Password Credentials to call Microsoft Graph API to send messages.
Based on permissions, you need the Group.ReadWrite.All delegated permission. So you need to add this permission into your Azure AD app firstly.
Don't forget to click on "Grant admin consent for {your tenant}" after you add this permission.
Then you can get an access token like this:
You can see that https://graph.microsoft.com/Group.ReadWrite.All has been included in the response.
Now you could use this access token to call POST /teams/{id}/channels/{id}/messages.
There are a few other ways I can think of.
1) One is that you can create a Bot using the Microsoft Bot Framework, and once that bot is installed to the particular team, it can send "pro-active" messages (i.e. not a message in response to a user's message, but rather whenever you need).
Essentially, when you bot is added to the team, you get access to a specific event in your bot (OnMembersAdded for a general bot, and there's now a new event just for Teams). See more on this in my answer on Detect bot application open event. In this event, you get the information you need for later, which you can store in a database or wherever, and then create the message as if it's your bot posting to the channel. You can see more on that at Programmatically sending a message to a bot in Microsoft Teams.
This option above is a lot of work, but useful if there's other functionality you want from a bot (e.g. the ability to receive messages from the users)
2) Another, and even more simple way, is to create an incoming webhook directly to the channel. Here's a post on doing this using PowerShell, so you can do that for simple testing and extrapolate from there for Node.
Of course, things like Flow (Power Automate) are an option too, but you're already writing code so one of the above is probably easier.
Hope that helps

Google Calendar live sync with node js app

I want to sync google calendar with my app.
When user add some event in the Google calendar at that time, I want these new event in my node server response
Means live sync with google calendar.
I want something like listener that listen new event.
With Google Calendar API you can watch for changes to Events or CalendarList resources, see this and this. Basically you will need to create an endpoint on your server which will receive events/calendars update notifications. When notification arrives, request a calendars/events synchronization. To make the synchronization efficient, use incremental sync. Check this question also to see the algorithm.
You may check this Quickstart tutorial and node-google-calendar.
You need to create a service account if you don't have one. A public/private key pair is generated for the service account, which is created from the Google API console. Take note of the service account's email address and store the service account's json or P12 private key file in a location accessible to your application. Your application needs them to make authorized API calls. If a user wants to give access to his Google Calendar to your application, he must give specific permission for each of the calendars to the created Service Account using the supplied email address under the Google Calendar settings.

Resources