Set the Tanzu CLI context to an organization

Before you can use the Tanzu CLI, you must set the Tanzu CLI context and authenticate the Tanzu CLI context with Tanzu Platform hub. The following steps set the Tanzu CLI context and authenticate to a specific organization in the hub.

Note

By default, the tanzu login command creates a CSP token from your CSP Default Organization. To create a token for an organization other than your default CSP organization, you must export the org ID as described in the following steps. If you do not export the org ID, the token for your context is set for your default organization.

  1. In Tanzu Platform hub, copy the organization ID.

    1. Log in to the hub.
    2. On the upper-right corner, click your user name.
    3. Click Change Organization, and then in the drop-down list, hover over the organization.
    4. Copy the value for Long ID from the display box.
  2. Run the following command to export the organization ID:

    export TANZU_CLI_CLOUD_SERVICES_ORGANIZATION_ID=<org-id>
    

    Where:

    <org-id> is the organization ID you copied in step 1.

  3. Log in with the tanzu CLI:

    tanzu login
    

After the command runs, you are redirected to a browser window to authenticate. After authentication is successful, you see the following message:

You have successfully logged in! You can safely close this window

A similar message also displays in the command output.

For more information about the tanzu login and how to manage Tanzu CLI contexts, see Create and manage CLI contexts.

check-circle-line exclamation-circle-line close-line
Scroll to top icon