Function To Get All The Fabric Tenant Settings With Descriptions

Simple Method to Get Fabric Tenant Settings and Descriptions

Sharing a function I have been using to get all the Fabric tenant settings and the description of each setting.

💡
You need to be a Fabric tenant admin to use this function. Run the following function in a Fabric notebook.
import sempy.fabric as fabric
from sempy.fabric.exceptions import FabricHTTPException
import pandas as pd
import json
from datetime import datetime

pd.set_option('display.max_columns', None)

def get_tenant_settings():
    """
    Author : Sandeep Pawar  |  Fabric.guru  |  May 19, 2024

    Function to get a list of all the tenant settings and the description of each setting.
    You need to be a Fabric tenant admin to get the settings.
    """

    client = fabric.PowerBIRestClient()
    try:
        response = client.get("v1/admin/tenantsettings")

        if response.status_code != 200:
            raise FabricHTTPException(response)

        data = json.loads(response.text)

        current_tenant_settings = pd.json_normalize(data['tenantSettings'])

        tenant_setting_desc = pd.concat(pd.read_html("https://learn.microsoft.com/en-us/fabric/admin/tenant-settings-index")).reset_index(drop=True)

        final_settings_df = (current_tenant_settings
                                .set_index("title")
                                .join(tenant_setting_desc.set_index("Setting name"))
                                .reset_index()
                                )[['tenantSettingGroup','title','settingName','Description','enabled','canSpecifySecurityGroups','enabledSecurityGroups']]

        final_settings_df['Settings As Of'] = datetime.now().strftime("%d/%m/%Y %H:%M")

        return final_settings_df

    except FabricHTTPException as e:
        print("Only tenant admins can use this function\n")
        return str(e)


df = get_tenant_settings()
df