DEV Community

Cover image for PACX ⁓ Connect to Dataverse environment
Riccardo Gregori
Riccardo Gregori

Posted on

PACX ⁓ Connect to Dataverse environment

We introduced PACX here, as a toolbelt containing commands to streamline the application development on Dataverse environments.

In order to run a command, PACX must be aware of the Dataverse environment where you want to run the command. This can be achieved using commands under pacx auth namespace.


Create a new auth profile

The pacx auth create command can be used to create a new connection vs a Dataverse environment. It takes as inputs:

  • --name (-n): a meaningful name for the connection
  • --conn (-cs): a valid dataverse connection string that can be used to connect to the desired dataverse environment.

Please remember to enclose the connection string in double quotes "...": some terminal handles the semicolon (;) in the connection string as a command delimiter. This causes an error while trying to connect to dataverse.

Once executed, the command will try to use the provided connection string to connect to the environment and executes a WhoAmI request to ensure that the connection works properly. If succeeded, it creates and saves on the local machine an authentication profile called as specified in the --name argument, and sets it as default for the next command executions.

You can create as many authentication profiles as you need. pacx auth list command can be used to list all of them, while pacx auth select allows to select which auth profile must be use in the subsequent commands.

List all auth profiles

The pacx auth list command can be used to list all the authentication profiles stored in the local machine. It does not require any argument, and will provide the following output

pacx auth list sample output

The first column contains the name of the auth profile, while the second column contains the connection string.

Peek the right auth profile

The pacx auth select command can be used to select which auth profile must be used from now on (until another pacx auth select changes your decision).

It accepts a single argument --name (-n) containing the name of the auth profile you want to set as default.

pacx auth select sample output

Other useful info

This namespace provides a few other useful commands:

  • pacx auth rename: can be used to rename an auth profile. It accepts 2 arguments:
    • --old (-o): the old name of the auth profile to rename
    • --new (-n): the new name of the auth profile
  • pacx auth delete: deletes a specific auth profile. It accepts a single argument:
    • --name (-n): the name of the auth profile to delete
  • pacx auth ping: tests the connection vs the current default auth profile. No argument required

You can simply type pacx auth in the console to get the list of available commands. Moreover, you can just type the name of a command followed by --help if you need help on that specific command arguments.

References

Top comments (0)