Join us for an expert-led overview of the tools and concepts you'll need to pass exam PL-300. The first session starts on June 11th. See you there!
Get registeredPower BI is turning 10! Letโs celebrate together with dataviz contests, interactive sessions, and giveaways. Register now.
Hi Team,
Iโm developing a Power BI Custom Connector and would like to implement a mechanism to switch between Staging and Production environments dynamically.
Is it possible to design a build where the connector determines the environment (staging or production) at runtime using:
A system environment variable, or
A local configuration file like .txt or .json
Iโm looking for a reliable approach using M language within the connector logic to support this kind of setup.
Has anyone implemented such functionality in their custom connector or can recommend a best practice?
Appreciate your help and insights!
Thanks,
Solved! Go to Solution.
Hi @Ravindra_,
Thank you for reaching out to the Microsoft Fabric Forum Community.
For your scenario implementing environment switching in a Power BI Custom Connector the recommended best practice is to use user-defined parameters via the connector UI. This approach ensures:
If this information is helpful, please โAccept it as a solutionโ and give a "kudos" to assist other community members in resolving similar issues more efficiently.
Thank you.
Hi @Ravindra_,
Thank you for reaching out to the Microsoft Fabric Forum Community.
For your scenario implementing environment switching in a Power BI Custom Connector the recommended best practice is to use user-defined parameters via the connector UI. This approach ensures:
If this information is helpful, please โAccept it as a solutionโ and give a "kudos" to assist other community members in resolving similar issues more efficiently.
Thank you.
Hi Ravindra,
It is possible to implement a mechanism to switch between Staging and Production environments dynamically while developing a Power BI Custom Connector. You can achieve this using M language. Here are two suggestions:
Using System Environment Variable:
Using Local Configuration File:
{
"environment": "Staging"
}
โ
Example M Code:
let
// Reading environment variable
environment = Environment.GetVariable("Environment"),
// Reading configuration file
config = Json.Document(File.Contents("config.json")),
environment = config[environment],
// Connection strings based on environment
source = if environment = "Staging" then
"https://staging.api.example.com/data"
else
"https://production.api.example.com/data"
in
source
With these methods, you can dynamically determine which environment your Power BI Custom Connector is running in and use the appropriate connection strings. I hope this helps!
Thanks
I have a question related to the second approach (using a local configuration file.) Are there special permissions I need to set? Because I get a security error when trying to read a file placed in the C:\documents\Public folder.
Why not just use parameters to swap connection string or schema like you would with other connectors?
This is your chance to engage directly with the engineering team behind Fabric and Power BI. Share your experiences and shape the future.
Check out the June 2025 Power BI update to learn about new features.
User | Count |
---|---|
81 | |
76 | |
61 | |
37 | |
33 |
User | Count |
---|---|
99 | |
56 | |
51 | |
42 | |
40 |