Azure function returns 403 error.

Ayush Shrivastava 60 Reputation points
2024-09-04T21:21:33.5466667+00:00

I am calling my azure function from ASD and the function returns 403.

I have configured it to send 401 in case of unauthorised requests.

I want to use managed identity to trigger the function.

Here is my function code.

package
import
import
import
import
import
import
import
import
import
/**
 * Azure Functions with HTTP Trigger.
 */
public
 /**
 * This function listens at endpoint "/api/HttpExample". Two ways to invoke it using "curl" command in bash:
 * 1. curl -d "HTTP Body" {your host}/api/HttpExample
 * 2. curl "{your host}/api/HttpExample?name=HTTP%20Query"
 */
 @
public
 @
name
methods
authLevel
HttpRequestMessage
final
context
// Parse query parameter
final
final
if
return
 } 
String
 {
 "name" : "response"
 }
 """
context
return
 }
 }
}

Here is my query -

DECLARE

EXEC
@url
@method
@credential
@response
SELECT
@response

I think I need to give my Sql servers managed identity some permissions but I am not able to figure what permission it needs.

Azure SQL Database
Azure Functions
Azure Functions
An Azure service that provides an event-driven serverless compute platform.
4,890 questions
{count} votes

2 answers

Sort by: Most helpful
  1. Nandan Hegde 32,026 Reputation points MVP
    2024-09-05T03:35:13.74+00:00

    For bare minimal testing, you can provide the Azure SQL server contributor role at the Azure function via RBAC and test out your execution.

    Note : This is some higher privelege

    You can follow the below link to create a custom role for least min privilege if need be :

    https://stackoverflow.com/questions/63610514/which-permission-allows-triggering-of-an-azure-function


  2. Ayush Shrivastava 60 Reputation points
    2024-09-05T16:30:36.7+00:00

    This is still not working. Can we do this over a quick call?

    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.