Showing results for 
Search instead for 
Did you mean: 
Community Champion
Community Champion

Bad Gateway Azure SQL Stored Procedure

Getting a "Bad Gateway" error for a Flow. Aimed at Azure SQL, not on-prem. Where is the gateway?

Simple Flow:

- Push button

- Run Stored Procedure

- Will not run.



- I have the Azure SQL Server set to "Allow Azure services..."


Please advise.

Thank you

Community Champion
Community Champion

Here is the error after the Flow times out. Do I need to grant special perms to my Flow connection? Its an Active Directory user but I'm admin on the DB.

  "error": {
    "code": 502,
    "source": "",
    "clientRequestId": "redacted",
    "message": "BadGateway",
    "innerError": {
      "status": 502,
      "message": "Principal '@userNameParam' could not be found or this principal type is not supported.\r\nCannot add the principal ''@userNameParam'', because it does not exist or you do not have permission.\r\nclientRequestId: redacted",
      "error": {
        "message": "Principal '@userNameParam' could not be found or this principal type is not supported.\r\nCannot add the principal ''@userNameParam'', because it does not exist or you do not have permission."
      "source": ""


Hm... I can't figure out why this isn't working.


- Created a new role in the Azure SQL database

  - `CREATE ROLE powerappsAdmins`

- Granted execute permissions for the Stored Procedures to the new role

  - `GRANT EXECUTE ON dbo.sp_custom_addADUser TO powerappsAdmins;`

- Created a new SQL Connection in Flow

  - **NOTE:** Clicking "Add Connection" from the three dots does not allow a new AD Connection to be made. I had to click Data/Connections and add a new AD connection there.

Does the Stored Procedure action in Flow support AD USERS?



Looking at this, this will require some deep in-depth troubleshooting. You are getting quite a few conflicting errors here. I would suggest to open a case with Microsoft Support. I'll include a link below; on how to reach out to them. If any other communities members may have run into this feel free to chime in.


If you would like to create a ticket with Microsoft Customer Support here is a link on how to do so:








Community Support Team _ Alex Rezac
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

New Member

Hello,  if there is an error in the stored procedure it also could raise en error  as "BadGateway" . This confusing error mesage could misdirect you for finding gateway solution. Check to run your sp with same parameters in the pool or sql server query analyzer for the user that you made the connection in the logic app.

Helpful resources

Process Advisor

Introducing Process Advisor

Check out the new Process Advisor community forum board!

MPA User Group

Welcome to the User Group Public Preview

Check out new user group experience and if you are a leader please create your group

V3_PVA CAmpaign Carousel.png

Community Challenge - Giveaways!

Participate in the Power Virtual Agents Community Challenge

Carousel 2021 Release Wave 2 Plan 768x460.jpg

2021 Release Wave 2 Plan

Power Platform release plan for the 2021 release wave 2 describes all new features releasing from October 2021 through March 2022.

Top Kudoed Authors
Users online (3,041)