Domain 3 of 3 · Chapter 6 of 7

Create and use environment variables

Unlock the complete study guide + 1,040 practice questions across 16 full exams.

Bundled into the existing Designing and Building Integrated AI Agent Solutions in Copilot Studio premium course — no separate purchase.

14-day money-back guarantee — no questions asked.

Included in this chapter:

  • Where a value stops belonging to the agent
  • Two records, one variable, and which value wins
  • Picking the data type, and the label that is contested
  • Data source variables are not connections
  • Secret variables and the Azure Key Vault chain
  • Reading an environment variable inside the agent
  • When a changed value actually reaches the agent
  • Getting values across the environment border
  • What goes wrong with environment variables
  • Where this page stops

The six environment variable data types, and what each one is actually for

Data Type at creationType in Copilot StudioWhat the variable holdsReaches a published agentPick it when
TextText (maps to String)A plain string value stored in DataverseAt publish time; republish after a changeAn endpoint, a portal address, a region code, any per-environment string
Decimal numberDecimal number (maps to Number)A numeric value stored in DataverseAt publish time; republish after a changeA retry count, a threshold, a numeric tuning value
Two optionsYes/No (maps to Boolean)A two-state value stored in DataverseAt publish time; republish after a changeA feature switch the agent branches on. The label differs between the two articles; see the page body
JSONJSON (type detected from the value)A structured value; a non-JSON value raises an Unspecified validation errorAt publish time; republish after a changeSeveral related settings that always change together as one unit
Data sourceData source (maps to String)Connector parameters such as a SharePoint site and list, or a SQL server and database. Never the credentialAt publish time; republish after a changeA connector target that differs per environment and is reached with identity-based authentication
SecretSecret (maps to String)The subscription, resource group, vault, and secret name of an Azure Key Vault secret. Never the secret itselfAt runtime; no republish needed, but the Dialog runtime caches a read for five minutesA credential that must rotate independently of releases

Decision tree

Where does this piece of configuration belong?Is the value a connector credential, orpart of a connection string?Connection referencethe connection carries the credentialIs it a secret the agent presents, heldin Azure Key Vault?Secret environment variableretrieved at runtime; no republish neededIs it a Dataverse table in this sameenvironment?No environment variable neededthe table name resolves in every environmentIs it a connector target: site, list,server, or database?Data source environment variableconnector parameters, never the credentialDo several settings always changetogether as one unit?JSON environment variableone prompt for settings that move togetherText, Decimal number, or the boolean typeone plain value, captured at publish timeyesyesyesyesyesnonononono

Cheat sheet

  • Environment variables separate configuration from agent components
  • Choose the environment-variable type that matches the configuration
  • Current value takes precedence over default value
  • Transport the definition and supply the target-specific value
  • Reuse one environment variable for shared configuration
  • Use data-source variables for target references, not credentials
  • Grant the Copilot Studio service access to Key Vault secrets
  • Account for Key Vault secret cache windows
  • Treat agent edit rights as secret disclosure rights
  • Deployment prompts for environment variables that lack values
  • Remove a source current value when targets must provide their own
  • Edit an agent environment variable's current value in Power Apps

Unlock with Premium — includes all practice exams and the complete study guide.

Also tested in

References

  1. Use environment variables in Power Platform solutions - Power Apps
  2. Variables overview - Microsoft Copilot Studio
  3. Establish an Application Lifecycle Management (ALM) strategy - Microsoft Copilot Studio
  4. Use data source environment variables in canvas apps - Power Apps
  5. Use environment variables for Azure Key Vault secrets - Power Apps
  6. Work with variables - Microsoft Copilot Studio
  7. Key concepts - Publish and deploy your agent - Microsoft Copilot Studio