Environment variables are solution components intended for configuration that changes between environments. They allow a solution to carry a definition while each target environment supplies its own current value.
Overview and use case
Use Dataverse environment variables to separate solution configuration from code and manage values across development, test and production.
Implementation steps
- Create an environment variable definition with a clear schema name and an appropriate data type.
- Set a development current value for local testing, but avoid committing environment-specific secrets into source control or solution packages.
- Reference the variable from Power Automate, apps or supported platform components rather than hard-coding environment URLs.
- During deployment, supply target-environment values using your deployment pipeline or solution deployment settings.
- Validate that the expected current value exists after import and that consumers handle missing values.
Example
// Retrieve an environment variable value with Dataverse Web API
GET https://<org>.crm.dynamics.com/api/data/v9.2/environmentvariabledefinitions?$select=schemaname,defaultvalue&$expand=environmentvariabledefinition_environmentvariablevalue($select=value)&$filter=schemaname eq 'new_ServiceEndpoint'
Common pitfalls
- Do not confuse the definition’s default value with an environment’s current value.
- Do not store secrets as plain-text environment variable values when a secret-aware mechanism is available.
- Remember to include the required definition in the solution and provide the target value during deployment.
Testing checklist
Import the solution into a clean test environment, set a different value, and verify each consumer reads the target environment’s configuration.
Conclusion
Apply the smallest permissions and configuration needed, test both expected and failure paths, and document how the implementation is operated in production.