Starting with CloudShell 9.2, it is possible to store information for later use in the sandbox using the API. This feature is related to this idea.
This capability can be used to store sandbox-specific information that is required for your orchestration processes and shells, like user details, unique IDs returned from 3rd party systems, or data created during the setup process that is needed for teardown.
The data is stored as key-value pairs in a container that is attached to the sandbox and can only be inserted/retrieved via CloudShell Automation API. Note that we don’t impose any limitations on the data and its format, and the data isn’t stored encrypted. Also, for completed sandboxes, the data is kept but cannot be modified.
The following API methods are provided:
SetSandboxData: sets the key-value pairs in the custom data container.
GetSandboxData: retrieves custom data from the sandbox
ClearSandboxData: clears the custom data container
Note that only sysadmins and domain admins can get/set/clear the sandbox data.
So let’s start by setting two key-value pairs: Key1 and Key2:
Now that we have some custom data on the sandbox, let’s learn how to retrieve it:
And finally, let’s learn how to remove the data we stored on the container:
Using custom sandbox data in JSON format
JSON is a very common data format so we figured we’d include some code samples.