Authorising Office365 logic app API Connection with PowerShell


Trying to setup a bunch of logic apps with supporting Azure functions etc. concept is to utilize ML/Azure functions/Logic apps etc. to setup an automated mailing system.

Everything is deployed using ADO/Git with CD/CI pipelines, but we have a problem with the Office365 connector that needs authorization after creation. I found an article that creates a windows form for authentication "" , but we want to do this using azuredevops pipeline and thus are looking for a silent approach, any ideas or links would be appreciated?

Krupa G

Azure Logic Apps
Azure Logic Apps
An Azure service that automates the access and use of data across clouds without writing code.
2,543 questions
Windows Server PowerShell
Windows Server PowerShell
Windows Server: A family of Microsoft server operating systems that support enterprise-level management, data storage, applications, and communications.PowerShell: A family of Microsoft task automation and configuration management frameworks consisting of a command-line shell and associated scripting language.
5,173 questions
0 comments No comments
{count} votes

3 answers

Sort by: Most helpful
  1. MughundhanRaveendran-MSFT 12,361 Reputation points

    @KrupaGundrajuLarsenToubroInfotechL-6566 ,

    Thanks for reaching out to Q&A.

    Unfortunately, the Office365 connector will prompt for authentication which is a known limitation. The powershell article that you are refering seems to be archived, I am not sure if it would work as expected or it would be supported. If it works, you can run that script in devops via PowerShell task. However if you are looking for Single sign on approach, then you might want to explore Microsoft Graph API to send mails. You can leverage Azure functions to run the script/code using the Graph API (I have not tried it, you might have to trial and error).

  2. MayankBargali-MSFT 63,511 Reputation points

    @KrupaGundrajuLarsenToubroInfotechL-6566 Unfortunately you can’t authenticate the user in a non-interactive way in the connector. Thus, there is no way to fully automate this.

    • Consider not re-creating api connection after initial manual authentication since there's no need unless cred changes, and only include logic apps in the arm template for subsequent deployment.
    • Consider using HTTP with MSI to call graph API directly.

    For connection resource define you can refer to this.
    More details:

    0 comments No comments

  3. Limitless Technology 38,771 Reputation points

    Hi @KrupaGundrajuLarsenToubroInfotechL-6566

    Office365 API authorization works with the OAuth 2.0 Authorisation Code Grant Type, which means, you can only get the authorization code by getting the user owning the mailbox to sign in to get the code.

    This behavior of the API is by design. Thus, there is no way to fully automate this. But you can refer to the below article to get insights about using Powershell for your process.

    Use PowerShell Script to Manage Your API Connection of Logic App (Consumption) Resources

    Authenticate access to Azure resources with managed identities in Azure Logic Apps

    Hope this resolves your Query!!

    --If the reply is helpful, please Upvote and Accept it as an answer–

    0 comments No comments