Show Menu
Cheatography

Sitecore XM Cloud CLI Cheat Sheet by

Sitecore XM Cloud CLI Cheat Sheet To contribute, please reach out. https://www.linkedin.com/in/nehemiahj/

XM Cloud CLI - Login & Logout

To login to XM Cloud Organi­zation using a device code flow with writing allowed
dotnet sitecore cloud login --allow-write
Can access the XM Cloud Deploy API and the CM instance APIs of all enviro­nments in an organi­zation
To login to XM Cloud Organi­zation using a creden­tials flow (Organ­ization Creden­tials)
dotnet sitecore cloud login --allow-write --client-credentials --client-id <Org-Client-Id> --client-secret <Org-Client-Secret>
Can access the XM Cloud Deploy API and the CM instance APIs of all enviro­nments in an organi­zation
To login to XM Cloud Enviro­nment using a creden­tials flow (Autom­ation Creden­tials)
dotnet sitecore cloud login --allow-write --client-credentials --client-id <Automation-Client-Id> --client-secret <Automation-Client-Secret>
Can access the CM instance APIs of a specific enviro­nment. No Deploy API Access.
To login to XM Cloud Organi­zation using a creden­tials flow including authority and audience (Organ­ization Creden­tials)
dotnet sitecore cloud login --allow-write --authority https://auth.sitecorecloud.io/ --audience https://api.sitecorecloud.io --client-id <Org-Client-Id> --client-secret <Org-Client-Secret> --client-credentials
Can access the XM Cloud Deploy API and the CM instance APIs of all enviro­nments in an organi­zation
To login to Edge admini­str­ation using a creden­tials flow (Edge Admini­str­ation Creden­tials)
dotnet sitecore cloud login --allow-write --client-credentials --client-id <Edge-Client-Id> --client-secret <Edge-Client-Secret>
Can manage the Experience Edge for XM Cloud settings of an enviro­nment
To logout of an XM Cloud Enviro­nment
dotnet sitecore cloud logout
Same for all type of login flow.

XM Cloud CLI - Organi­zation

Need Organi­zation Creden­tials for using Client Creden­tials or Use code flow. Automation or Edge Admini­str­ation creden­tials will return forbidden error.
 
To display inform­ation about the current user's organi­zations
dotnet sitecore cloud organization info --organization-id <id>
-
To display inform­ation about the current user's organi­zations as JSON
dotnet sitecore cloud organization info --organization-id <id> --json
Output as Json
To display the health status of the organi­zat­ion's resources
dotnet sitecore cloud organization health --organization-id <id>
-
To display the health status of the organi­zat­ion's resources as JSON
dotnet sitecore cloud organization health --organization-id <id> --json
Output as Json
To download the organi­zat­ion's license to the current folder
dotnet sitecore cloud organization license --organization-id <id>
-

XM Cloud CLI - Project

Need Organi­zation Creden­tials for using Client Creden­tials or Use code flow. Automation or Edge Admini­str­ation creden­tials will return forbidden error.
 
To list all the XM Cloud projects
dotnet sitecore cloud project list
-
To list all the XM Cloud projects as JSON
dotnet sitecore cloud project list --json
Output as Json
To get inform­ation about a XM Cloud Project
dotnet sitecore cloud project info --project-id <Project-Id>
-
To get inform­ation about a XM Cloud Project as JSON
dotnet sitecore cloud project info --project-id <Project-Id> --json
Output as Json
To create a new XM Cloud Project
dotnet sitecore cloud project create --name "<Project-Name>"
-
To update the XM Cloud Project details
dotnet sitecore cloud project update --project-id <Project-Id> --name "Nehem"
Only one attribute (name) can be updated at this time.
To delete the XM Cloud Project
dotnet sitecore cloud project delete --project-id <Project-Id>
Cannot delete the project if 1 or more active enviro­nments. Should delete all the enviro­nment at first and then project can be deleted.

XM Cloud CLI - Deployment

To create a deployment request
dotnet sitecore cloud deployment create --envi­ron­ment-id <En­vir­onm­ent­-Id>
Deployment request created and started immedi­ately for the enviro­nment.
To queue a deployment request
dotnet sitecore cloud deployment create --envi­ron­ment-id <En­vir­onm­ent­-Id> --no-start
Need to call
deployment start
to start the deployment
To create the deployment request without showing the status in CLI Console
dotnet sitecore cloud deployment create --envi­ron­ment-id <En­vir­onm­ent­-Id> --no-watch
-
To create the deployment request and upload the assets from current working directory
dotnet sitecore cloud deployment create --envi­ron­ment-id <En­vir­onm­ent­-Id> --upload
-
To create the deployment request and upload the assets from a custom working directory
dotnet sitecore cloud deployment create --envi­ron­ment-id <En­vir­onm­ent­-Id> --upload --work­ing-dir "­C:­\Art­ifa­cts­"
-
To view the existing deployment request inform­ation
dotnet sitecore cloud deployment info --depl­oym­ent-id <De­plo­yme­nt-­Id>
-
To list all the deployment requests on an XM Cloud Enviro­nment
dotnet sitecore cloud deployment list --envi­ron­ment-id <En­vir­onm­ent­-Id>
-
To start a deployment which is in queue
dotnet sitecore cloud deployment start --depl­oym­ent-id <En­vir­onm­ent­-Id>
-
To start the deployment and watch the post actions in CLI Console
dotnet sitecore cloud deployment start --depl­oym­ent-id <En­vir­onm­ent­-Id> --wait­For­Pos­tAc­tions
-
To watch the status of the deployment request in Console
dotnet sitecore cloud deployment watch --depl­oym­ent-id <De­plo­yme­nt-­Id>
Will attach the console to see the status realtime
To view the deployment log in console
dotnet sitecore cloud deployment log --depl­oym­ent-id <De­plo­yme­nt-­Id>
-
To download the deployment log to a specific folder
dotnet sitecore cloud deployment log --depl­oym­ent-id <De­plo­yme­nt-­Id> --outp­utpath .
Downloads the deployment log to the current working folder.
Output of the log file will be saved in the current folder in this format. Deploy­men­t_<­DEP­LOY­MEN­TID­>_l­ogs.json

XM Cloud CLI - Enviro­nment

To list all XM Cloud Enviro­nment for a project
dotnet sitecore cloud environment list --project-id <Project-Id>
Need specific Project ID
To list all XM Cloud Enviro­nment for a project as JSON
dotnet sitecore cloud environment list --project-id <Project-Id> --json
Output as JSON
To get the inform­ation
dotnet sitecore cloud environment get --environment-id <Environment-Id>
-
To get the inform­ation as JSON
dotnet sitecore cloud environment info --environment-id <Environment-Id> --json
Output as JSON
To create a new XM Cloud Enviro­nment
dotnet sitecore cloud environment create --name "QA" --project-id <Project-Id>
Need specific Project ID under which Enviro­nment will be created
To create a new XM Cloud Production Enviro­nment
dotnet sitecore cloud environment create --name "Production" --project-id <Project-Id> --prod
Need --prod to indicate that it is a production Enviro­nment
To create a new XM Cloud Enviro­nment as JSON
dotnet sitecore cloud environment create --name "QA" --project-id <Project-Id> --json
Output as JSON
To update an XM Cloud Enviro­nment
dotnet sitecore cloud environment update --environment-id <Environment-Id> --name "<New-Name>"
Need the specific Enviro­nment ID. Only name can be updated as of now
To delete an XM Cloud Enviro­nment
dotnet sitecore cloud environment delete --environment-id <Environment-Id>
Need the specific Enviro­nment ID
To connect current Sitecore solution to an XM Cloud Enviro­nment
dotnet sitecore cloud environment connect --environment-id <Environment-Id> --name "Staging"
Establish connection info for an XM Cloud Enviro­nment (updates endpoints in user.j­son). Add a new endpoint in user.json with name. --name is optional.
To disconnect current Sitecore solution to an XM Cloud Enviro­nment
sitecore cloud environment disconnect --environment-id <Environment-Id> --name "Staging"
Remove connection info for an XM Cloud Enviro­nment (updates endpoints in user.j­son). --name is optional.
To promote a deployment to another XM Cloud Enviro­nment
dotnet sitecore cloud environment promote --environment-id <Environment-Id> --source-id <Deployment-Id>
Similar to Deployment Create command. Need the source deployment ID which should be promoted to. Can create the promotion deployment request without starting it.
 
dotnet sitecore cloud environment promote --environment-id <Environment-Id> --source-id <Deployment-Id> --no-start
Similar to deployment create command, deployment can be queued.
 
dotnet sitecore cloud environment promote --environment-id <Environment-Id> --source-id <Deployment-Id> --no-watch
Will not show the deployment progress in CLI
 
dotnet sitecore cloud environment promote --environment-id <Environment-Id> --source-id <Deployment-Id> --waitForPostActions
Will show the Post Actions progress in the CLI. Be default, post actions are not shown in real time in CLI. --no-watch has high precedence than --wait­For­Pos­tAc­tions
To list all the available logs from an XM Cloud Enviro­nment
dotnet sitecore cloud environment log list --environment-id <Environment-Id>
-
 
dotnet sitecore cloud environment log list --environment-id <Environment-Id> --latest
Gets only the latest set of log files
 
dotnet sitecore cloud environment log list --environment-id <Environment-Id> --latest --json
Get the latest log files in a JSON format and it has the API path property to get the log file.
To download the specific log file
dotnet sitecore cloud environment log download --environment-id <Environment-Id> --logfile <LogFile> --outputpath .
Downloads in the current folder (.)
To view the log file in the console
dotnet sitecore cloud environment log view --environment-id <Environment-Id> --logfile <LogFile>
Similar to Download except it is rendered in console. There is no tail option.
To get the health of the enviro­nment
dotnet sitecore cloud environment health --environment-id <Environment-Id>
Calls https:­//<­Env­iro­nme­nt-­Hos­t>/­hea­lth­z/ready and provides whether it is healthy or not. /healt­hz/­ready. Healthy if 200 and Unhealthy if 503 response code.
To list all the enviro­nment variables of an Enviro­nment
dotnet sitecore cloud environment variable list --environment-id <Environment-Id>
To print all the variables in the Console
 
dotnet sitecore cloud environment variable list --environment-id <Environment-Id> --json
Output as JSON

- Creati­ng/­Upd­ati­ng/­Del­eting Enviro­nment Variable requires a rebuil­d/r­edeploy of XM Cloud enviro­nment for the changes to take effect.
To create­/update an enviro­nment variable of an Enviro­nment
dotnet sitecore cloud environment variable upsert --environment-id <Environment-Id> --name "Variable-Name" --value "Variable-Value"
-
 
dotnet sitecore cloud environment variable upsert --environment-id <Environment-Id> --name "Variable-Name" --value "Variable-Value" --target CM
Target this variable for CM only
 
dotnet sitecore cloud environment variable upsert --environment-id <Environment-Id> --name "Variable-Name" --value "Variable-Value" --target <Rendering-Host-Name>
Target this variable for Rendering Host
 
dotnet sitecore cloud environment variable upsert --environment-id <Environment-Id> --name "Variable-Name" --value "Variable-Value" --secret
This bool sets the variable encrypted
To delete an enviro­nment variable
dotnet sitecore cloud environment variable delete -environment-id <Environment-Id> --name "Variable-Name"
-
To restart an enviro­nment
dotnet sitecore cloud environment restart --environment-id <environment-id>
Enviro­nment will be restarted without any interv­ention to CM instance.
   
 

Comments

No comments yet. Add yours below!

Add a Comment

Your Comment

Please enter your name.

    Please enter your email address

      Please enter your Comment.

          Related Cheat Sheets

          Android Package Manager (pm) Cheat Sheet
          Basic Cisco IOS Commands Cheat Sheet
          Sitecore XM Cloud CLI Commands List Cheat Sheet

          More Cheat Sheets by nehem87

          Sitecore XM Cloud CLI Commands List Cheat Sheet