Register now to learn Fabric in free live sessions led by the best Microsoft experts. From Apr 16 to May 9, in English and Spanish.
The first step as data source is a Python script which collects the data from an Azure DevOps Server on-premise. In order to use the OData feed of the server I have to pass an authentication token. To make later change easier, I would like to pass the URL of the server as well as the authentication token from Power BI into the Python script.
Here comes a short snippet from the advanced editor:
let
Source = Python.Execute("import pandas as pd#(lf)import numpy as np#(lf)import requests#(lf)import json#(lf)import os#(lf)import sys#(lf)import pathlib#(lf)import ppr
The related Python code looks like:
import pandas as pd
import numpy as np
import requests
import json
import os
import sys
import pathlib
import pprint
import configparser
from requests.auth import HTTPBasicAuth
from decimal import Decimal
# Read parameter from environment (Power BI) -> does not work at the moment as first step (hardcoded for now)
#ados_url = "&Text.From(ADOSServer)&"
#personal_access_token = "&Text.From(AccessToken)&"
ados_url = "http://xxx/_odata/v2.0/"
personal_access_token = "yyyyyyyyyyyyy"
There a a couple of examples available, but in these examples the parameter are used not as first step inside the data source. As soon as I try to use the parameter already within the Source= statement, the parameter are never expanded.
I tried up to now the following examples:
ados_url = """ & ADOSServer """
ados_url = '"&Text.From(ADOSServer)&"'
ados_url = "&Text.From(ADOSServer)&"
None of them worked. I got always the string after the assignment.
Any ideas?
Any other solution here? I am on the same boat.
Hi,
Please help me with this, I am facing this same issue.
Thanks
@Kobold67 , Refer if this can help
https://docs.microsoft.com/en-us/power-bi/desktop-python-in-query-editor
The article does not help me. The solution is working, however the only problem at the moment is, that I like to move out the server URL and access token from the python script. Otherwise I have to re-enter this after expiration (token last for around a year) in all data sources provided from the script.
Covering the world! 9:00-10:30 AM Sydney, 4:00-5:30 PM CET (Paris/Berlin), 7:00-8:30 PM Mexico City
Check out the April 2024 Power BI update to learn about new features.
User | Count |
---|---|
113 | |
97 | |
80 | |
69 | |
59 |
User | Count |
---|---|
150 | |
119 | |
104 | |
87 | |
67 |