Forum Discussion

chetanhiwale's avatar
chetanhiwale
Resolver I
1 year ago

Get Cloud Connection details in fabric using python

Hi Fabric Community, 

I am working with data pipelines, where I need to  retrive cloud connection details using python. These connection can be easily viewed from Setting -> Manage Connection and Gateways 

 

Below this we can view our connections. 
Is there any way by which i can get the details like connection ID, connection String, etc

8 Replies

    • chetanhiwale's avatar
      chetanhiwale
      Resolver I

      Thanks lbendlin, for posting your answer. For me, I am not able to view the gateway / gateway ID. Can you please help me to find gateway. Also to mention I am not using any on-prem connections. 

  • Anonymous's avatar
    Anonymous
    Not applicable

    Hi chetanhiwale

     

    Thank you very much lbendlin for your prompt reply.

     

    The REST API is a good way to do this. Most cloud services provide REST apis to manage connections and gateways. You can use these apis to get the details you need.

     

    You can also use the requests library in Python to make API calls.  

     

    First, you need to install the requests library.

     

    You can install it using the pip command. Open your command line terminal. Enter the following command and press Enter.

     

    Here’s a basic example:

     

    import requests
    
    # Replace with your API endpoint and necessary headers
    api_url = "https://api.yourcloudservice.com/connections"
    headers = {
        "Authorization": "Bearer YOUR_ACCESS_TOKEN",
        "Content-Type": "application/json"
    }
    
    response = requests.get(api_url, headers=headers)
    
    if response.status_code == 200:
        connections = response.json()
        for connection in connections:
            print(f"ID: {connection['id']}, Connection String: {connection['connectionString']}")
    else:
        print(f"Failed to retrieve connections: {response.status_code}")

     

     

    You can view the link below for more details:

     

    Requests: HTTP for Humans™ — Requests 2.32.3 documentation (python-requests.org)

     

    Python's Requests Library (Guide) – Real Python

     

    Regards, 

    Nono Chen 

    If this post helps, then please consider Accept it as the solution to help the other members find it more quickly. 

  • Anonymous's avatar
    Anonymous
    Not applicable

    Hi chetanhiwale 

     

    If you need to find the gateway ID specifically, you can use the Datasets - Get Datasources In Group REST API endpoint.  You’ll need your workspace /group and dataset ID, and you’ll get back the details of the dataset’s datasource.

     

    Solved: ID Gateway and datasource - Microsoft Fabric Community

     

    Datasets - Get Datasources In Group - REST API (Power BI Power BI REST APIs) | Microsoft Learn

     

    Regards,

    Nono Chen

    If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.