Advance your Data & AI career with 50 days of live learning, dataviz contests, hands-on challenges, study groups & certifications and more!
Get registeredGet Fabric Certified for FREE during Fabric Data Days. Don't miss your chance! Request 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 Guys,
new idea for it:
https://community.fabric.microsoft.com/t5/Fabric-Ideas/Skip-Credential-Validation-for-Queries-Exclud...
Please vote!
It means that you can exclude query to be refreshed not only in power bi desktop - also within power bi service without failing because of data source credentials.
Best,
Jacek
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
sourceWith 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
translation and formatting supported by AI
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?
Check out the November 2025 Power BI update to learn about new features.
Advance your Data & AI career with 50 days of live learning, contests, hands-on challenges, study groups & certifications and more!