cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
Vidanaw
Helper IV
Helper IV

Create a Flow with Service account

Hi All,

I m building a Flow as follows.

  1. Flow triggers when an Item is added to the SharePoint online list.
  2. Flow will send approval to the selected manager in the SP list.
  3. Flow will send an email notification to the requester with the approval status.
  4. Update the SP list item with approver approval status.

Can someone please tell me what are the best practice of creating this Flow based on the following areas. 

1. Flow ownership is it better to create MS FLow with a service account ( normal O365 user account with a generic name)

2. Give Service account contributor permission to the SP list.

3. If I m sending email using a shared mailbox, give send as permission to the service account.

4. If the organization has 90 days password expiry policy, how that will affects on this service account.

 

Thanks.

1 ACCEPTED SOLUTION

Accepted Solutions
Pstork1
Most Valuable Professional
Most Valuable Professional

1) using a service account to won Flows is a common best practice in large enterprises because it protects you from issues if the original Maker leaves the company.  But it will cost you an additional license since the service account needs full licensing.

2) In general yes, the service account will need permissions on the list just like a user.  Depending on the trigger there is a way to add the list itself as a RunOnly user.  But that only works for specific triggers.

3) It depends on the email action you use.  Many Flow actions that send email, like the Approval actions, send the email from a Microsoft mailbox and that can't be changed.  For the actions where you can specify the From then yes the account running the Flow must have Send As permissions to the mailbox.

4) I would normally recommend setting up the service account as exempt from the 90 day password change policy. Otherwise someone will need to login as that account every 90 days and change the password. But remember the Flow runs connections using an OAUTH connection. That isn't dependent on the account password until it needs to be renewed.



-------------------------------------------------------------------------
If I have answered your question, please mark your post as Solved.
If you like my response, please give it a Thumbs Up.

View solution in original post

18 REPLIES 18
Pstork1
Most Valuable Professional
Most Valuable Professional

1) using a service account to won Flows is a common best practice in large enterprises because it protects you from issues if the original Maker leaves the company.  But it will cost you an additional license since the service account needs full licensing.

2) In general yes, the service account will need permissions on the list just like a user.  Depending on the trigger there is a way to add the list itself as a RunOnly user.  But that only works for specific triggers.

3) It depends on the email action you use.  Many Flow actions that send email, like the Approval actions, send the email from a Microsoft mailbox and that can't be changed.  For the actions where you can specify the From then yes the account running the Flow must have Send As permissions to the mailbox.

4) I would normally recommend setting up the service account as exempt from the 90 day password change policy. Otherwise someone will need to login as that account every 90 days and change the password. But remember the Flow runs connections using an OAUTH connection. That isn't dependent on the account password until it needs to be renewed.



-------------------------------------------------------------------------
If I have answered your question, please mark your post as Solved.
If you like my response, please give it a Thumbs Up.

Thank you  Pstork1.

Hi @Pstork1 ,

Do you have any recommendations on number of service accounts.

I am trying to build close to 400 flows uses commonly Sharepoint,outlook and Approval connectors.

Pstork1
Most Valuable Professional
Most Valuable Professional

Unless you start running into capacity issues with the number of API calls you are making, you can normally do it with just one account.  I would start there and add a second account if you have to scale up your capacity.



-------------------------------------------------------------------------
If I have answered your question, please mark your post as Solved.
If you like my response, please give it a Thumbs Up.

So as to the number of service accounts.  Isn't it a security issue to have a single account having access to many different databases, SharePoint lists, etc.?  If for some reason that one account is hacked/used by someone they have access to a lot of data.  On the other hand as mentioned on this thread, creating a service account for each and ever application created is racking up the number of licenses used.   There ought to be some middle ground.

Pstork1
Most Valuable Professional
Most Valuable Professional

Yes, it would be a concern.  But since its a service account you would limit the number of people who have access to it and set a very difficult password for it (like a 12-16 character nonsense string).  Then audit access to it and look for potential issues.  IF it gets hacked its a bigger issue, but you can put much more stringent controls and auditing on it than you generally would a normal account.  Its a concern, but not an insurmountable risk.



-------------------------------------------------------------------------
If I have answered your question, please mark your post as Solved.
If you like my response, please give it a Thumbs Up.
Anonymous
Not applicable

@Pstork1 @Vidanaw 

 

I have the same requirements as @Vidanaw where a user can add a new record in a Sharepoint list and then manually triggers a flow using a button on the form. The flow sends an email, starts an approval process, then creates a new record in a different list which the initiating user does not have permissions to do so, so the flow fails on 'Access is denied. (Exception from HRESULT: 0x80070005 (E_ACCESSDENIED))'.

 

I am new to power automate so are still learning some of the basics.

 

As i created the flow, the connections are using my office365 account so all works ok for me. The flow is also a 'team flow' which i assume lets anyone who has access to the Sharepoint list use the flow, but with their account, not mine, which is why the flow fails when it tries to update the sharepoint list.

 

I've read creating a service account should resolve my issue where users do not have sharepoint permissions for the list that the flow updates. I should give the service account the correct permissions in sharepoint to update the list.

 

The thing i don't fully understand, is how i get the flow to run every time using the service account and not the account of the person who initiates the flow? Any advice to help me understand how to setup would be much appreciated. thanks.

 

 

flow1.jpg

 
 

 

 

 

Pstork1
Most Valuable Professional
Most Valuable Professional

The problem is that flows which are triggered using a button run in the context of the person who presses the button, not the original maker.  Flows that are triggered automatically by an event in the list will run in the context of the maker.  That's why you are getting the access denied error when someone else runs the flow. Creating a flow using a service account won't change that.



-------------------------------------------------------------------------
If I have answered your question, please mark your post as Solved.
If you like my response, please give it a Thumbs Up.
Anonymous
Not applicable

@Pstork1 thanks for the quick reply, any suggestions on how i can resolve my issue? without given all end users edit access to the sharepoint list?

Pstork1
Most Valuable Professional
Most Valuable Professional

The easiest way to fix it is to change the trigger.  If the flow is kicked off automatically when the record is created or modified then it will run in the context of the maker.  Then only the maker, or a service account if you use that to make the flow, needs access to the second SharePoint list.  There really is no way to do it if the user's start the flow themselves.



-------------------------------------------------------------------------
If I have answered your question, please mark your post as Solved.
If you like my response, please give it a Thumbs Up.

@Anonymous like @Pstork1 mentioned you have to change the trigger which you can easily done based on the Form submission. 

Anonymous
Not applicable

@Vidanaw @Pstork1 thanks for your feedback. I've split my flow into 2, the first being triggered from the pushbutton and the second is triggered on new / change of record. All seems to work ok now. thanks.

SA3
New Member

what is the recommendation around MFA for these service accounts? 

Pstork1
Most Valuable Professional
Most Valuable Professional

Since security is actually based on OAuth I don't think it really matters.  The only point where MFA will enter into it is when you log in as the Service Account to edit the flow.



-------------------------------------------------------------------------
If I have answered your question, please mark your post as Solved.
If you like my response, please give it a Thumbs Up.

We've set a conditional access policy requiring MFA after 24h, so we're experiencing problems with users having to login to continue their Flows and Power BI data refreshes. Creating a service account for these apps with MFA would result in the same problem, as the token keeps expiring. Is there any other way to keep a service account with MFA, or make it more secure in another way?

Anonymous
Not applicable

would PowerAutomate Service Account Password rotation break the work flows if so how can we address the issue and have password rotation in place? Also can Service Account be replaced by Managed Identities?

Pstork1
Most Valuable Professional
Most Valuable Professional

Every time your service account resets its password you will need to re-authenticate each connection using that account.  I have not found a way to do that programmatically.  Nor do I think you can use managed Identities at this point to authenticate connections.



-------------------------------------------------------------------------
If I have answered your question, please mark your post as Solved.
If you like my response, please give it a Thumbs Up.
Anonymous
Not applicable

Hoping you can have a look at my post here:

https://powerusers.microsoft.com/t5/General-Power-Automate/Service-Accounts-and-Dashboard-Alerts/m-p...

 

Service Accounts and Dashboard Alerts

 

Thx

Helpful resources

Announcements

Celebrating the May Super User of the Month: Laurens Martens

  @LaurensM  is an exceptional contributor to the Power Platform Community. Super Users like Laurens inspire others through their example, encouragement, and active participation. We are excited to celebrated Laurens as our Super User of the Month for May 2024.   Consistent Engagement:  He consistently engages with the community by answering forum questions, sharing insights, and providing solutions. Laurens dedication helps other users find answers and overcome challenges.   Community Expertise: As a Super User, Laurens plays a crucial role in maintaining a knowledge sharing environment. Always ensuring a positive experience for everyone.   Leadership: He shares valuable insights on community growth, engagement, and future trends. Their contributions help shape the Power Platform Community.   Congratulations, Laurens Martens, for your outstanding work! Keep inspiring others and making a difference in the community!   Keep up the fantastic work!        

Check out the Copilot Studio Cookbook today!

We are excited to announce our new Copilot Cookbook Gallery in the Copilot Studio Community. We can't wait for you to share your expertise and your experience!    Join us for an amazing opportunity where you'll be one of the first to contribute to the Copilot Cookbook—your ultimate guide to mastering Microsoft Copilot. Whether you're seeking inspiration or grappling with a challenge while crafting apps, you probably already know that Copilot Cookbook is your reliable assistant, offering a wealth of tips and tricks at your fingertips--and we want you to add your expertise. What can you "cook" up?   Click this link to get started: https://aka.ms/CS_Copilot_Cookbook_Gallery   Don't miss out on this exclusive opportunity to be one of the first in the Community to share your app creation journey with Copilot. We'll be announcing a Cookbook Challenge very soon and want to make sure you one of the first "cooks" in the kitchen.   Don't miss your moment--start submitting in the Copilot Cookbook Gallery today!     Thank you,  Engagement Team

Announcing Power Apps Copilot Cookbook Gallery

We are excited to share that the all-new Copilot Cookbook Gallery for Power Apps is now available in the Power Apps Community, full of tips and tricks on how to best use Microsoft Copilot as you develop and create in Power Apps. The new Copilot Cookbook is your go-to resource when you need inspiration--or when you're stuck--and aren't sure how to best partner with Copilot while creating apps.   Whether you're looking for the best prompts or just want to know about responsible AI use, visit Copilot Cookbook for regular updates you can rely on--while also serving up some of your greatest tips and tricks for the Community. Check Out the new Copilot Cookbook for Power Apps today: Copilot Cookbook - Power Platform Community.  We can't wait to see what you "cook" up!    

Welcome to the Power Automate Community

You are now a part of a fast-growing vibrant group of peers and industry experts who are here to network, share knowledge, and even have a little fun.   Now that you are a member, you can enjoy the following resources:   Welcome to the Community   News & Announcements: The is your place to get all the latest news around community events and announcements. This is where we share with the community what is going on and how to participate.  Be sure to subscribe to this board and not miss an announcement.   Get Help with Power Automate Forums: If you're looking for support with any part of Power Automate, our forums are the place to go. From General Power Automate forums to Using Connectors, Building Flows and Using Flows.  You will find thousands of technical professionals, and Super Users with years of experience who are ready and eager to answer your questions. You now have the ability to post, reply and give "kudos" on the Power Automate community forums. Make sure you conduct a quick search before creating a new post because your question may have already been asked and answered. Galleries: The galleries are full of content and can assist you with information on creating a flow in our Webinars and Video Gallery, and the ability to share the flows you have created in the Power Automate Cookbook.  Stay connected with the Community Connections & How-To Videos from the Microsoft Community Team. Check out the awesome content being shared there today.   Power Automate Community Blog: Over the years, more than 700 Power Automate Community Blog articles have been written and published by our thriving community. Our community members have learned some excellent tips and have keen insights on the future of process automation. In the Power Automate Community Blog, you can read the latest Power Automate-related posts from our community blog authors around the world. Let us know if you'd like to become an author and contribute your own writing — everything Power Automate-related is welcome.   Community Support: Check out and learn more about Using the Community for tips & tricks. Let us know in the Community Feedback  board if you have any questions or comments about your community experience. Again, we are so excited to welcome you to the Microsoft Power Automate community family. Whether you are brand new to the world of process automation or you are a seasoned Power Automate veteran - our goal is to shape the community to be your 'go to' for support, networking, education, inspiration and encouragement as we enjoy this adventure together.     Power Automate Community Team

Hear what's next for the Power Up Program

Hear from Principal Program Manager, Dimpi Gandhi, to discover the latest enhancements to the Microsoft #PowerUpProgram, including a new accelerated video-based curriculum crafted with the expertise of Microsoft MVPs, Rory Neary and Charlie Phipps-Bennett. If you’d like to hear what’s coming next, click the link below to sign up today! https://aka.ms/PowerUp  

Tuesday Tip | How to Report Spam in Our Community

It's time for another TUESDAY TIPS, your weekly connection with the most insightful tips and tricks that empower both newcomers and veterans in the Power Platform Community! Every Tuesday, we bring you a curated selection of the finest advice, distilled from the resources and tools in the Community. Whether you’re a seasoned member or just getting started, Tuesday Tips are the perfect compass guiding you across the dynamic landscape of the Power Platform Community.   As our community family expands each week, we revisit our essential tools, tips, and tricks to ensure you’re well-versed in the community’s pulse. Keep an eye on the News & Announcements for your weekly Tuesday Tips—you never know what you may learn!   Today's Tip: How to Report Spam in Our Community We strive to maintain a professional and helpful community, and part of that effort involves keeping our platform free of spam. If you encounter a post that you believe is spam, please follow these steps to report it: Locate the Post: Find the post in question within the community.Kebab Menu: Click on the "Kebab" menu | 3 Dots, on the top right of the post.Report Inappropriate Content: Select "Report Inappropriate Content" from the menu.Submit Report: Fill out any necessary details on the form and submit your report.   Our community team will review the report and take appropriate action to ensure our community remains a valuable resource for everyone.   Thank you for helping us keep the community clean and useful!

Users online (3,674)