Hi, I am facing Authorization issue while deploying code via CI CD into the Azure functions.

Mohamed Arif Gangavaram 25 Reputation points
2024-12-20T05:02:10.75+00:00

We have provisioned a Azure function in Private Endpoint and Gitlab runner in Gitlab CI CD.

While we are trying to deploy the code we are getting the following Error:

Code: Authorization

Message: The Client 'client ID of service principal' with a object ID 'object id' does not have authorization to perform the action 'Microsoft.web/sites/functions/read' over scope /subscriptions/'subscription ID'/resourceGroups/'resourcegroupname'/Microsoft.web/sites/'functionappname'/functions/'nameoffunction'

or scope is invalid. If access was recently granted, please refresh the credentials.

  • The Service principal is access on the resource group level with the customized admin with Microsoft.web/, Microsoft.web/sites/ and Microsoft.web/sites/functions/*

Kindly let us know is there any other place that i missed the granting the access.

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

Accepted answer
  1. Vinodh247 26,371 Reputation points MVP
    2024-12-21T16:08:18.2466667+00:00

    Hi ,

    Thanks for reaching out to Microsoft Q&A.

    The error indicates that the service principal does not have sufficient permissions to perform the requested action (Microsoft.web/sites/functions/read) on the Azure Function app. Even though you mentioned granting permissions at the resource group level, there are a few areas to verify and potential adjustments you can make:

    1. Check Role Assignment Scope
      • Ensure the service principal has the correct role assignment at the appropriate scope.
      • Use the Azure Role Assignments blade or az role assignment list command to confirm the following:
      • The service principal is assigned the necessary role at the resource group, subscription, or specific resource level.
      • Roles to verify:
      • Contributor or
      • Custom role with permissions for Microsoft.Web/*.
      Validate Custom Role Permissions If you are using a custom role, ensure it includes the following Action permissions. Missing specific actions such as listkeys/action can lead to errors during deployments.

      "Microsoft.Web/sites/read", "Microsoft.Web/sites/functions/read", "Microsoft.Web/sites/functions/write", "Microsoft.Web/sites/functions/listkeys/action"

      Validate Identity Authentication
      • Confirm the Azure CLI/SDK credentials or tokens being used in the GitLab runner reflect the updated permissions: If permissions were granted recently, refresh tokens:

        az account clear az login

    Private Endpoint Configuration

    • Ensure the GitLab Runner (deployed externally) has proper network access to the Function App's private endpoint.
    • The GitLab Runner needs connectivity to the Function App's DNS through the private endpoint.
      • Verify if your Azure DNS Private Zone is configured and linked to the Virtual Network used by the GitLab Runner.

    Common Missing Permissions

    Ensure the following permissions are explicitly added if using a custom role:

    • Microsoft.Web/sites/functions/read
    • Microsoft.Web/sites/functions/write
    • Microsoft.Web/sites/functions/listkeys/action

    Please feel free to click the 'Upvote' (Thumbs-up) button and 'Accept as Answer'. This helps the community by allowing others with similar queries to easily find the solution.

    1 person found this answer helpful.

1 additional answer

Sort by: Most helpful
  1. Mohamed Arif Gangavaram 25 Reputation points
    2024-12-24T06:13:32.3766667+00:00

    Thanks Vinod!! for your valuable inputs, with the API permission and contributor role to the service principal, the sample code is successfully deployed to the Azure function.

    1 person found this answer helpful.

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.