This post is a part of the AB-620: Designing and Building Integrated AI Agent Solutions in Copilot Studio Exam Prep Hub.
This topic falls under these sections:
Test and manage agents (20–25%)
--> Implement application lifecycle management (ALM) for agents in Copilot Studio
--> Create and use environment variables (in Microsoft Copilot Studio)
Note that there are 10 practice questions (with answers) at the end of each section to help you solidify your knowledge of the material. Also, there are 4 practice tests with 30 questions each available from the hub's main page below the exam topics section.
Introduction
As organizations move Copilot Studio agents from development to testing and production, many configuration settings change between environments. For example:
- API endpoints
- Azure AI Search service names
- Azure OpenAI or Azure AI Foundry resources
- Dataverse URLs
- SQL Server connection information
- SharePoint sites
- REST API base URLs
- Storage account names
- Feature flags
Hardcoding these values into an agent or Power Automate flow creates deployment challenges because developers must manually edit every component for each environment.
Environment variables solve this problem by allowing configuration values to be stored separately from the application. Components reference the environment variable rather than a fixed value. When the solution is imported into another environment, only the environment variable needs to be updated.
For the AB-620 exam, you should understand:
- What environment variables are
- Why they are important for ALM
- Types of environment variables
- How to create them
- How to use them in Copilot Studio
- How they work with solutions
- Their relationship to connection references
- Best practices for deployment
What Are Environment Variables?
An environment variable is a reusable configuration setting stored within a Power Platform solution.
Instead of embedding configuration values directly into application components, the components reference an environment variable.
Example:
Instead of:
https://dev-api.contoso.com
An agent references:
API_BaseURL
Each environment supplies its own value.
Why Environment Variables Matter
Organizations usually have multiple environments:
- Development
- Test
- User Acceptance Testing (UAT)
- Staging
- Production
Each environment typically uses different resources.
Example:
| Environment | API URL |
|---|---|
| Development | https://dev-api.contoso.com |
| Test | https://test-api.contoso.com |
| Production | https://api.contoso.com |
Without environment variables, every component would need to be edited during deployment.
With environment variables:
- The solution remains unchanged.
- Only the variable value changes.
Benefits of Environment Variables
Environment variables provide:
- Easier deployments
- Reusable configuration
- Improved portability
- Reduced manual work
- Better governance
- Fewer deployment errors
- Cleaner application design
- Improved ALM support
Environment Variables vs Hardcoded Values
Hardcoded Configuration
Agent
↓
https://dev-api.company.com
Problems:
- Difficult migration
- Manual editing
- Error-prone
- Poor ALM
Environment Variable Configuration
Agent
↓
API_URL
↓
Environment Variable
↓
Current Environment Value
Benefits:
- Flexible
- Reusable
- Easy deployment
Common Uses
Environment variables commonly store:
- REST API endpoints
- Azure AI Search service names
- Azure OpenAI endpoints
- Azure AI Foundry endpoints
- Azure Storage account names
- Dataverse URLs
- SharePoint URLs
- Cosmos DB endpoints
- SQL Server names
- Feature toggles
- Default language settings
- Prompt configuration values
Types of Environment Variables
Power Platform supports two primary pieces of information:
Environment Variable Definition
The definition contains:
- Variable name
- Display name
- Description
- Data type
- Default value
Example:
SearchServiceName
Environment Variable Value
The value changes by environment.
Development
contoso-search-dev
Testing
contoso-search-test
Production
contoso-search-prod
Supported Data Types
Environment variables support several data types.
Common types include:
- Text
- Decimal number
- Two options (Boolean)
- JSON
- Data source
- Secret (when integrated with Azure Key Vault)
The appropriate type depends on the configuration being stored.
Secrets and Azure Key Vault
Sensitive information should not be stored as plain text.
Examples include:
- API keys
- Client secrets
- Access tokens
- Passwords
Instead:
Environment Variable
↓
Azure Key Vault Secret
↓
Application
This approach improves security and simplifies secret rotation.
Creating an Environment Variable
General steps:
- Open the Power Apps Maker Portal.
- Open an unmanaged solution.
- Select New.
- Choose Environment Variable.
- Enter:
- Display Name
- Schema Name
- Data Type
- Default Value (optional)
- Save.
The variable is now available within the solution.
Using Environment Variables in Copilot Studio
Once created, environment variables can be referenced by:
- Copilot Studio agents
- Power Automate flows
- Custom connectors
- Plugins
- Dataverse components
- AI prompts
- REST API tools
- Azure integrations
Instead of storing a literal value, components reference the variable.
Example
Without environment variables:
REST APIhttps://dev-api.contoso.com/orders
With environment variables:
API_URL↓https://dev-api.contoso.com
The REST action builds the URL dynamically.
Environment Variables During Deployment
When exporting a solution:
Environment Variable Definition
↓
Solution Package
↓
Import
↓
Administrator enters Production Value
↓
Application works without modification
No changes to the agent are required.
Relationship to Solutions
Environment variables are solution components.
This means they:
- Export with the solution
- Import with the solution
- Support versioning
- Participate in ALM
- Work with managed solutions
- Work with Power Platform Pipelines
Environment Variables and Connection References
These concepts are commonly confused.
Environment Variables
Store:
Configuration values
Examples:
- URL
- Service name
- Feature flag
- Search index
- Region
Connection References
Store:
Authentication information
Examples:
- SQL connection
- SharePoint connection
- Dataverse connection
- Outlook connection
Think of it this way:
Environment Variable = What system should be used?
Connection Reference = How do I authenticate to that system?
Working with Power Platform Pipelines
Power Platform Pipelines automatically support environment variables.
Deployment process:
Development
↓
Export Solution
↓
Pipeline
↓
Import
↓
Assign Production Variable Values
↓
Application Ready
No manual editing of the agent is required.
Versioning
Environment variables participate in solution versioning.
Example:
Version 1.0
SearchServiceName
Version 1.1
SearchServiceNameNew Variable:FeatureToggle
Both variables become part of the upgraded solution.
Common Mistakes
Hardcoding URLs
Instead of:
https://company-dev-api.com
Use:
API_URL
Storing Secrets as Text
Never place passwords directly into text variables.
Use Azure Key Vault integration whenever possible.
Duplicating Variables
Avoid creating multiple variables for the same setting.
Instead, reuse existing variables.
Poor Naming
Avoid names like:
Variable1
Prefer:
AzureSearchEndpoint
or
OrdersAPIBaseURL
Ignoring Default Values
Default values can simplify development and testing while allowing administrators to override values during deployment.
Best Practices
Microsoft recommends:
- Create environment variables inside solutions.
- Use descriptive names.
- Use environment variables instead of hardcoded values.
- Store secrets in Azure Key Vault.
- Separate configuration from application logic.
- Reuse variables whenever possible.
- Document each variable.
- Test variable values after deployment.
- Use connection references for authentication.
- Use environment variables for configuration settings.
Exam Tips
Know the difference between:
| Concept | Stores |
|---|---|
| Environment Variable | Configuration values |
| Connection Reference | Authentication information |
| Managed Solution | Production deployment |
| Unmanaged Solution | Development |
| Azure Key Vault | Secrets |
Remember:
Environment variables make solutions portable.
Real-World Example
A company builds a customer support agent that uses:
- Azure AI Search
- REST APIs
- SharePoint
- SQL Server
Instead of hardcoding configuration:
https://dev-search.azure.comhttps://dev-orders-api.comhttps://dev.sharepoint.com
The solution defines:
SearchServiceURLOrdersAPISharePointSite
During deployment to production, administrators simply update the environment variable values without modifying the agent, topics, flows, or connectors.
Summary
Environment variables are a foundational ALM feature in Microsoft Power Platform and Copilot Studio. They allow developers to separate configuration settings from application logic, making solutions easier to deploy, maintain, and version across development, test, and production environments. By storing environment-specific values such as API endpoints, Azure AI Search resources, and feature flags in reusable variables, organizations reduce deployment errors and improve maintainability. Environment variables work alongside connection references, which manage authentication, while Azure Key Vault should be used for sensitive secrets.
Practice Exam Questions
Question 1
A Copilot Studio agent calls a REST API whose base URL is different in development, testing, and production. What is the recommended approach?
A. Create an environment variable for the API URL.
B. Hardcode all three URLs in the agent.
C. Create three separate agents.
D. Create separate topics for each environment.
Answer: A
Explanation: Environment variables allow configuration values such as API endpoints to vary by environment without modifying the agent.
Question 2
Which type of information is best stored in an environment variable?
A. OAuth access tokens
B. API base URLs
C. User conversation history
D. Dataverse records
Answer: B
Explanation: Environment variables are intended for configuration settings such as URLs, service names, and feature flags rather than runtime data or authentication tokens.
Question 3
What is the primary benefit of using environment variables?
A. They improve AI response quality.
B. They reduce token consumption.
C. They separate configuration values from application logic.
D. They automatically secure REST APIs.
Answer: C
Explanation: Separating configuration from application logic simplifies deployments and reduces maintenance.
Question 4
Which feature should be used to securely store sensitive information such as API secrets?
A. Text environment variables
B. Adaptive Cards
C. Power Automate variables
D. Azure Key Vault
Answer: D
Explanation: Azure Key Vault is the recommended service for securely storing secrets and can be integrated with Power Platform.
Question 5
What is the relationship between environment variables and solutions?
A. Environment variables cannot be included in solutions.
B. Environment variables are solution components and move with the solution.
C. Environment variables are created automatically during import.
D. Environment variables are only available in managed solutions.
Answer: B
Explanation: Environment variables are packaged within solutions and participate in ALM and deployment.
Question 6
Which statement correctly distinguishes environment variables from connection references?
A. Both store authentication credentials.
B. Environment variables store user conversations.
C. Environment variables store configuration values, while connection references store authentication information.
D. Connection references replace environment variables.
Answer: C
Explanation: Environment variables define configuration values, whereas connection references identify and manage authenticated connections.
Question 7
A developer hardcodes an Azure AI Search endpoint into an agent. What is the primary disadvantage?
A. The agent cannot use generative answers.
B. The endpoint must be manually updated when deploying to another environment.
C. The agent cannot be added to a solution.
D. The endpoint becomes encrypted automatically.
Answer: B
Explanation: Hardcoded values make deployments more difficult because they require manual changes for each environment.
Question 8
Which naming convention is considered a best practice for environment variables?
A. Variable1
B. Test123
C. Value
D. OrdersAPIBaseURL
Answer: D
Explanation: Descriptive names improve readability, maintenance, and long-term governance.
Question 9
When importing a managed solution into production, what typically happens with environment variables?
A. They are deleted automatically.
B. They cannot be modified.
C. Administrators provide production-specific values.
D. They are converted into connection references.
Answer: C
Explanation: During import, administrators typically assign values appropriate for the target environment.
Question 10
Which scenario is the best use case for an environment variable?
A. Storing the current user’s conversation transcript
B. Storing an Azure AI Search service name used by an agent
C. Storing Dataverse table records
D. Storing Power Automate execution history
Answer: B
Explanation: Azure AI Search service names are environment-specific configuration settings that are ideal candidates for environment variables.
Go to the AB-620 Exam Prep Hub main page
