Get workspace_id from workspace_name

Oscar Suarez 0 Reputation points
2024-07-29T22:20:30.7733333+00:00

How can I get the workspace_id from workspace_name? Example get_workspace_id(workspace_name)

Microsoft Fabric Training
Microsoft Fabric Training
Microsoft Fabric: A Microsoft unified data platform.Training: Instruction to develop new skills.
46 questions
{count} votes

1 answer

Sort by: Most helpful
  1. Rakesh Gurram 9,065 Reputation points Microsoft Vendor
    2024-07-30T05:20:04.3433333+00:00

    Hi Oscar Suarez,

    Thank you for reaching out to us on the Microsoft Q&A forum.

    To obtain the workspace_id from the workspace_name in Microsoft Fabric, you can use the sempy library. Here’s a step-by-step guide:

    %pip install -U semantic-link
    
    import sempy.fabric as fabric
    # Get the list of all workspacesworkspaces = fabric.list_workspaces()
    # Filter the workspace by name and get the IDworkspace_name = "your_workspace_name"workspace_row = workspaces[workspaces['Name'] == workspace_name]
    workspace_id = workspace_row['Id'].values[0]
    print(f"The workspace ID for {workspace_name} is {workspace_id}")
    

    This code will list all workspaces, filter by the given workspace_name, and then retrieve the corresponding workspace_id.

    I have created a repro for the same scenario. Please refer to the below screenshot:

    User's image

    You can refer to this link for more help: https://community.fabric.microsoft.com/t5/General-Discussion/Is-there-a-function-to-check-the-workspace-name-ID-in-Fabric/m-p/3800046

    Please don't hesitate to reach out to us if you have any other queries.

    If the information is helpful, please Accept Answer & Upvote so that it would be helpful to other community members.


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.