Share via

How to make an Azure Function available on SharePoint pages for editors only?

Roland Rickborn 1 Reputation point
2026-05-26T07:24:50.8533333+00:00

Hello,

I have an Azure Function which processes SharePoint pages. For this, the function has the mandatory parameter pageID.

Currently, I'm showing a button in the page details of the pages which links to my Azure Function. For this, I'm configuring the properties layout with an extended header:

{
    "elmType": "div",
    "attributes": {
        "class": "ms-bgColor-white"
    },
    "style": {
        "flex": "none",
        "display": "inline-grid"
    },
    "children": [
        {
            "elmType": "button",
            "attributes": {
                "class": "ms-bgColor-themePrimary"
            },
            "style": {
                "width": "130px",
                "height": "35px",
                "border-radius": "5px",
                "cursor": "pointer",
                "display": "flex",
                "align-items": "center",
                "justify-content": "space-evenly",
                "margin": "5px",
                "padding-top": "1px",
                "padding-left": "5px",
                "padding-right": "5px",
                "padding-bottom": "5px"
            },
            "children": [
                {
                    "elmType": "a",
                    "txtContent": "Do something with the page",
                    "style": {
                        "text-decoration": "none"
                    },
                    "attributes": {
                        "href": "= 'https://xxx.azurewebsites.net/api/workflow?pageId=' + [$ID]",
                        "target": "_self",
                        "class": "ms-fontColor-white"
                    }
                }
            ]
        }
    ]
}

This is how it looks in action:

image (1)

Although this solution works already very good it has some disadvantages like it is visible for any page visitor.

My question:
Is there any SharePoint solution (it must not be a customized header in the page details) which allows to show a button to a specific target group?

I tried already SPFx generator's WebPart and Extension (application customizer, field customizer, and ListView command set).

I'd be grateful for any advice - Thank you.

Microsoft 365 and Office | SharePoint | Development
0 comments No comments

2 answers

Sort by: Most helpful
  1. Vergil-V 13,380 Reputation points Microsoft External Staff Moderator
    2026-05-26T09:39:06.42+00:00

    Hi Roland Rickborn

    Based on my research, it appears that the SPFx Application Customizer is still suitable for your scenario. You may want to review whether the following logic has already been implemented in your setup, and whether it can apply to your case: 

    // pageContext.listItem.id gives you the dynamic pageId   
    const pageId = this.context.pageContext.listItem?.id;   
       
    // Check permissions first   
    const canEdit = await checkEditPermission();   
       
    if (canEdit) {   
    // Show button with dynamic pageId   
    renderButton(pageId);   
    }   
    

    In addition, I found that an approach using audience targeting together with an SPFx web part could also work. However, this would require manually adding the web part to each page where the button is needed. 

    For further insight, you may consider reaching out to the broader technical community through https://techcommunity.microsoft.com/ and https://github.com/orgs/community/discussions. These forums often include discussions from engineers and partners who have worked through similar use cases and can share practical insights.   

    I hope this provides some additional insight.


    Note: Please follow the steps in our documentation to enable e-mail notifications if you want to receive the related email notification for this thread.

    Was this answer helpful?

    1 person found this answer helpful.

  2. AI answer

    2026-05-26T07:25:06.78+00:00

    No supported mechanism in the provided material describes conditionally showing such a button only to editors (or any other audience) from within page details formatting or another out‑of‑the-box SharePoint construct.

    The available guidance in the context focuses on:

    • Using Azure Functions as HTTP endpoints (for webhooks or provisioning scenarios) and obtaining their URLs.
    • General SharePoint page concepts (layouts, content types, theming, etc.).

    None of these cover role‑ or audience‑targeted UI elements for page details or other page chrome that would allow exposing the Azure Function link only to editors.


    References:

    AI-generated content may be incorrect. Read our transparency notes for more information.

    Was this answer helpful?

Your answer

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