Using AF for Power Automate and 365 Exchange

Tom Wrigglesworth 91 Reputation points
2024-07-12T11:00:22.73+00:00

Hello,

I am currently learning AF at the moment so not sure if this is a simple question. Is it possible to run a Power Automate flow that triggers a Azure Function, to run a PowerShell command to convert a user to a shared mailbox, without any user intervention?

Reading around, some websites say no and some say yes so a tad confused.

If there's an easier way to go about this, that would be welcomed.

Kind regards

Tom

Azure Functions
Azure Functions
An Azure service that provides an event-driven serverless compute platform.
5,016 questions
0 comments No comments
{count} votes

3 answers

Sort by: Most helpful
  1. Thomas Smith 0 Reputation points
    2024-07-13T11:43:58.1166667+00:00

    Hello,
    Converting a user mailbox to a shared mailbox using Power Automate and Azure Functions is indeed possible. Here’s how you can achieve it:

    Azure Function for PowerShell:

    Create an Azure Function that hosts your PowerShell code. This function will execute the necessary PowerShell command to convert the user mailbox to a shared mailbox.

    You can trigger this Azure Function from Power Automate using the HTTP action.

    PowerShell Command:

    The PowerShell command to convert a user mailbox to a shared mailbox is as follows:

    Set-Mailbox -Identity <MailboxIdentity> -Type Shared

    Replace <MailboxIdentity> with the actual identity (email address or display name) of the user mailbox you want to convert.

    Flow Configuration:

    In your Power Automate flow:

    Use a trigger (e.g., when a new user is offboarded).

    Add an HTTP action to call your Azure Function endpoint.

    Pass the necessary parameters (e.g., mailbox identity) to the Azure Function.

    The Azure Function will execute the PowerShell command to convert the user mailbox to a shared mailbox.

    Remember to handle any error scenarios (e.g., if the mailbox doesn’t exist or if the Official Site conversion fails).

    Hope this will help you.
    Best regards,
    Thomas Smith

    0 comments No comments

  2. Dillon Silzer 57,491 Reputation points
    2024-07-13T19:58:49.8766667+00:00

    Hi Tom,

    Just to add to what Thomas has already stated you also need to ensure that you set up a Service Principal/Managed Identity. You cannot run anything in AF without the ability to do a non-interactive signin.

    Register a Microsoft Entra app and create a service principal

    https://learn.microsoft.com/en-us/entra/identity-platform/howto-create-service-principal-portal


    If this is helpful please accept as answer or upvote.

    Best regards,

    Dillon Silzer, Director | Cloudaen.com | Cloudaen Computing Solutions

    0 comments No comments

  3. Tom Wrigglesworth 91 Reputation points
    2024-07-15T08:30:59.5333333+00:00

    Fantastic, thank you for this :)

    Would there be a charge for every time this process runs? I looked on the calculator and there were parts that were free and parts that were chargeable

    0 comments No comments

Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.