xg env import
xg env import
Section titled “xg env import”Import environment configurations from a JSON file into the local XrmGhost environment store. Supports both a single environment object and a bulk import file (array wrapped in an environments key). When an imported environment already exists by FriendlyName, the command interactively prompts to Skip or Overwrite the conflict.
License requirement:
env importrequires a Pro license tier. Runxg license statusto verify your tier.
Synopsis
Section titled “Synopsis”xg env import <FILE_PATH>Arguments
Section titled “Arguments”| Argument | Required | Description |
|---|---|---|
<FILE_PATH> | Yes | Path to the JSON file containing the environment configuration(s) to import. |
Options
Section titled “Options”env import has no optional flags beyond the required positional argument above. Global options (e.g. --help) apply as normal.
| Flag | Type | Default | Description |
|---|---|---|---|
--help | bool | false | Display help text for this command and exit. |
Input File Format
Section titled “Input File Format”The command accepts two JSON shapes:
Single environment object
Section titled “Single environment object”{ "FriendlyName": "My Dev Environment", "EnvironmentUrl": "https://myorg.crm.dynamics.com", "AuthenticationMethod": "ClientSecret", "ClientId": "00000000-0000-0000-0000-000000000001", "MetadataCacheLifecycle": "7.00:00:00"}Bulk import file (array wrapped in environments)
Section titled “Bulk import file (array wrapped in environments)”{ "environments": [ { "FriendlyName": "Dev", "EnvironmentUrl": "https://dev.crm.dynamics.com", "AuthenticationMethod": "ClientSecret", "ClientId": "00000000-0000-0000-0000-000000000001", "MetadataCacheLifecycle": "7.00:00:00" }, { "FriendlyName": "QA", "EnvironmentUrl": "https://qa.crm.dynamics.com", "AuthenticationMethod": "ClientSecret", "ClientId": "00000000-0000-0000-0000-000000000002", "MetadataCacheLifecycle": "7.00:00:00" } ]}Client secret handling: The
ClientSecretfield is deliberately excluded from files produced byxg env export(it is marked[JsonIgnore]during export). If the import file does not contain aClientSecretand the environment usesClientSecretauthentication, the command will interactively prompt you to enter it. To automate imports, pre-populate the field in the JSON before running the command in a non-interactive context.
Conflict Resolution
Section titled “Conflict Resolution”If an environment with the same FriendlyName already exists in the local store, the command presents an interactive prompt with the following choices:
| Choice | Behaviour |
|---|---|
| Skip | The conflicting environment is left unchanged. The import counter increments skipped. |
| Overwrite | The existing configuration is replaced with the imported one. The import counter increments overwritten. |
A third option, Rename, is currently shown in the prompt but is not yet implemented — selecting it results in a skip.
Exit Codes
Section titled “Exit Codes”| Code | Meaning |
|---|---|
0 | Command completed (may include skipped entries). |
1 | Fatal error: file not found, file read failure, or JSON parse error. |
Examples
Section titled “Examples”Import a single environment from a file
Section titled “Import a single environment from a file”xg env import ./environments/dev.jsonImport multiple environments from a bulk export
Section titled “Import multiple environments from a bulk export”xg env import ./all_environments.jsonImport from an absolute path
Section titled “Import from an absolute path”xg env import /home/user/configs/xrmghost-envs.jsonSee Also
Section titled “See Also”xg env template— Generate a blank environment configuration JSON ready to fill in and import.xg env list— List all currently registered Dataverse environments.- CLI Overview — Introduction to the
xgCLI, command groups, and how this documentation is organised.