Note
Access to this page requires authorization. You can try signing in or changing directories.
Access to this page requires authorization. You can try changing directories.
[This article is prerelease documentation and is subject to change.]
Sign in to the CLI and choose your Copilot Studio environment before you create projects or contact cloud services. Start with the installed CLI, an authorized work or school account, and the intended tenant and environment IDs from your administrator.
Sign in to the intended account
Run authentication login:
msagent auth loginYou can also specify the account, tenant, and cloud explicitly. Replace the sample account and tenant with your values:
msagent auth login --account 'developer@contoso.com' ` --tenant '<tenant-id>' --cloud prodComplete the operating-system broker account picker. When the broker is unavailable, the CLI reports the reason and falls back to device code. Canceling sign-in doesn't trigger fallback. If your policy permits device code and you need to bypass the broker, use device-code login:
msagent auth login --device-codeTo cancel the device-code sign-in flow and terminate the command, press Ctrl+C in the terminal.
Inspect authentication status:
msagent auth statusCheck account, tenant, and ring. Status reads saved sign-in information; it doesn't acquire a token, open identity UI, or verify current service access.
Select an accessible development environment
Use the environment list:
msagent env listThis service request tests access more directly than saved authentication status. If your environment is missing, verify the tenant, ring, and permissions with the administrator. The CLI doesn't provision environments.
Copy the intended environment ID and use environment select:
msagent env select '<development-environment-id>'Recheck authentication status. Success means the saved account, tenant, ring, and selected environment match your intended development context.
Important
Selecting an environment doesn't retarget existing project records, workspace connections, or deployment records. Inspect those separately. Evaluations can resolve a project's home environment, deployment operations use the selected deployment, and agent pull uses its existing workspace connection.
Switch accounts, tenants, or rings
Use authentication switch for an account already stored locally, followed by environment list and environment select:
msagent auth switch --account 'release@contoso.com' --cloud prod
msagent env list
msagent env select '<release-environment-id>'
Switching doesn't sign in or acquire tokens. If the account isn't stored, use authentication login with the intended tenant. An ambiguous username requires the exact stored home-account ID.
--cloud selects the Power Platform API ring: prod, preprod, or test. It isn't a sovereign-cloud selector or tenant selector. Only use a nonproduction ring when your preview owner directs you to it. For example, ring switching is:
msagent auth switch --cloud preprod
The next CLI invocation uses the new ring. Switching alone doesn't satisfy consent or Conditional Access for that ring; use authentication login with --cloud preprod when an authorized interactive sign-in is required. Invalid rings fail rather than falling back to production.
Omitting the ring at login preserves the named account's ring, otherwise inherits the active account's ring; the first login defaults to prod. Account, tenant, or ring changes clear persisted environment selections across rings. Switching back doesn't restore an old selection. Signing in again as the same account in the same tenant and ring retains it.
Sign out and recover access
On shared machines, use authentication logout:
msagent auth logout
Logout clears all local CLI profiles, not only the active one, and best-effort clears the CLI token cache. It doesn't sign out the operating-system broker or other apps. Stored environment selections can't be used while signed out.
For expired credentials or missing consent, reauthenticate interactively with the intended account and tenant, then verify service access and targeting again. Don't disable organizational identity protections or enable an unprotected cache as a default recovery action.
The CLI rejects authentication login with non-interactive mode, even if a token might be available silently. That flag doesn't provide application or service-principal login.