Skip to main content
cancel
Showing results for 
Search instead for 
Did you mean: 

Be one of the first to start using Fabric Databases. View on-demand sessions with database experts and the Microsoft product team to learn just how easy it is to get started. Watch now

Reply
12angrymentiger
Advocate III
Advocate III

Need to grab the Workspace Name from the System Variables

In ADF and Synapse you can get the Workspace name from the System Variables in the Expression Builder as seen below.  But in Fabric Data Factory pipelines you only get the workspace ID which is a GUID.

 

I really need to be able to grab the workspace name as that is used to dynamically set a variable as the workspace name contains the env in the name (DEV/UAT/PRD). The workspace name is also helpful for us to dynamically pull from those different storage accounts and an email is sent when the pipeline fails detailing which workspace was run etc...

 

 

Synapse Pipelines:

 

12angrymentiger_2-1701897209807.png

 

 

 

ADF Pipelines:

 

12angrymentiger_3-1701897245523.png

 

 

 

 

Microsoft Fabric:

 

12angrymentiger_0-1701896841006.png

 

1 ACCEPTED SOLUTION
Anonymous
Not applicable

Hi @12angrymentiger ,
Thanks for using Fabric Community.
Currently this option is not available but we are open for feedback to improve our product.

Appreciate if you could share the feedback on our feedback channel. Which would be open for the user community to upvote & comment on. This allows our product teams to effectively prioritize your request against our existing feature backlog and gives insight into the potential impact of implementing the suggested feature.

Hope this helps. Please let me know if you have any further queries.

View solution in original post

5 REPLIES 5
Scaevola
Regular Visitor

You can use a notebook NB_GetWorkspaceNameById to convert ID into name. In a notebook you can use the Fabric API to get info on a workspace by ID.

Workspaces - Get Workspace - REST API (Core) | Microsoft Learn

 

However you need an access token with user interaction to use Fabric API. I currently have pipelines that need you to get an access token in NB_GetAccessToken before running the pipeline.

Maybe you could even do it without notebook and in the pipeline with a web activity:
Re: Fabric API - Service Principle alternatives - Microsoft Fabric Community


NB_GetWorkspaceNameById

 

# parameter cell start #
workspace_id = ''
access_token = ''
# parameter cell end #


import requests

url = f'https://api.fabric.microsoft.com/v1/workspaces/{workspace_id}'
headers = {
    'Authorization': f'Bearer {access_token}'
}
response = requests.get(url, headers=headers)

response_json = response.json()
print(response.status_code)
print(response_json)

workspace_name = response_json['displayName']

 


NB_GetAccessToken

 

# parameter cell start #
tenant_id = ''
client_id = ''
# parameter cell end #


import requests
import json
from msal import PublicClientApplication
from datetime import datetime, timedelta
import pytz

app = PublicClientApplication(
  client_id = client_id,
  authority = 'https://login.microsoftonline.com/' + tenant_id
)

print("json response:")
scopes = ['https://api.fabric.microsoft.com/Workspace.ReadWrite.All https://api.fabric.microsoft.com/Item.ReadWrite.All']
json_response = app.initiate_device_flow(scopes = scopes)
print(json_response)

# Return the token as soon as user completes her/his part of device code flow
response_dict = app.acquire_token_by_device_flow(json_response)

try:
  access_token = response_dict['access_token']
  print("\naccess token:")
  print(access_token)
  expiration_time = datetime.now(pytz.timezone('Europe/Amsterdam')) + timedelta(seconds=response_dict['expires_in'])
  print(f"\nexpiration time: {expiration_time}")
except:
  print('\nSomething went wrong')
  print(response_dict['error_description'])

 

 

dowsk
Regular Visitor

Really need this now that data pipelines are git-supported.

 

Being able to reference a resource (ex. lakehouse inside of a notebook) that belongs to the same workspace that the data pipeline is associated with is essential for limiting execution scope. Before pipelines became supported, you could hard code the workspace name as a pipeline parameter since the pipelines weren't associated with each other.

Anonymous
Not applicable

Hi @12angrymentiger ,
Thanks for using Fabric Community.
Currently this option is not available but we are open for feedback to improve our product.

Appreciate if you could share the feedback on our feedback channel. Which would be open for the user community to upvote & comment on. This allows our product teams to effectively prioritize your request against our existing feature backlog and gives insight into the potential impact of implementing the suggested feature.

Hope this helps. Please let me know if you have any further queries.

Hello,

 

I have created an idea of this:
https://ideas.fabric.microsoft.com/ideas/idea/?ideaid=2b777168-fc47-ef11-b4ad-000d3a0f9a18

Please, go to vote for it, so it will get implemented faster.

Hi,

 

The feedback channel link is not working. I also need to get the workspace name dynamically in one of the data pipelines so that I could use this workspace name to send notifications to the correct teams channel. 

Helpful resources

Announcements
Las Vegas 2025

Join us at the Microsoft Fabric Community Conference

March 31 - April 2, 2025, in Las Vegas, Nevada. Use code MSCUST for a $150 discount!

Dec Fabric Community Survey

We want your feedback!

Your insights matter. That’s why we created a quick survey to learn about your experience finding answers to technical questions.

ArunFabCon

Microsoft Fabric Community Conference 2025

Arun Ulag shares exciting details about the Microsoft Fabric Conference 2025, which will be held in Las Vegas, NV.

December 2024

A Year in Review - December 2024

Find out what content was popular in the Fabric community during 2024.