Custom Scripts
This article will take you through the development process of a custom script for CloudShell App deployment. CloudShell supports PowerShell scripts for Windows VMs, and bash or sh scripts for Linux VMs. When developing your script, we recommend you first simulate/debug it by running it manually on a similar machine.
Examples
Here are several examples of custom scripts to help you get started. If you are new to script development, feel free to test them out.
Hello World
A basic script, just to make sure we’re communicating with the VM and are able to run a script. When run with an App, the output should be shown in the sandbox diagram’s Output window.
Parameters
A basic script that prints out the parameter defined in an App template or API call (see below). This is useful for debugging the script and making sure the parameter is received with the correct value. Note that the parameters are stored as environment variables on the App instance in the sandbox.
-
Specified in the App template:
-
Specified in the ConfigureApps API method:
Note: Since this script uses parameters defined on the App template, it will not work when run manually outside of CloudShell. For this to work, you will need to edit the python code as follows:
- Update the CloudShell settings passed to the
session
variable, if needed. - Specify the ID of an active sandbox (in the
reservationId
field of the python code). - Replace ‘LinuxVmApp_9cb2-72d6’ with the App’s name.
Linux privilege escalation
If the deployed App resource is set with the credentials of a “regular” user, you may specify the root credentials in the parameters (see the Parameters example above), to use them in the script.