Skip to content

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 import requires a Pro license tier. Run xg license status to verify your tier.


Terminal window
xg env import <FILE_PATH>

ArgumentRequiredDescription
<FILE_PATH>YesPath to the JSON file containing the environment configuration(s) to import.

env import has no optional flags beyond the required positional argument above. Global options (e.g. --help) apply as normal.

FlagTypeDefaultDescription
--helpboolfalseDisplay help text for this command and exit.

The command accepts two JSON shapes:

{
"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 ClientSecret field is deliberately excluded from files produced by xg env export (it is marked [JsonIgnore] during export). If the import file does not contain a ClientSecret and the environment uses ClientSecret authentication, 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.


If an environment with the same FriendlyName already exists in the local store, the command presents an interactive prompt with the following choices:

ChoiceBehaviour
SkipThe conflicting environment is left unchanged. The import counter increments skipped.
OverwriteThe 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.


CodeMeaning
0Command completed (may include skipped entries).
1Fatal error: file not found, file read failure, or JSON parse error.

Terminal window
xg env import ./environments/dev.json

Import multiple environments from a bulk export

Section titled “Import multiple environments from a bulk export”
Terminal window
xg env import ./all_environments.json
Terminal window
xg env import /home/user/configs/xrmghost-envs.json

  • 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 xg CLI, command groups, and how this documentation is organised.