X

The latest cloud infrastructure announcements, technical solutions, and enterprise cloud insights.

Try It! Use Cloud Shell to learn the CLI and SDKs

Zack Menegakis
Senior Product Manager

Last year, Oracle Cloud created Cloud Shell to help developers, engineers, and admins work more easily with cloud infrastructure and services. Cloud Shell provides a Bash shell (command line) in your web browser, and it’s accessible immediately after logging in to the Oracle Cloud Console. With Cloud Shell, you can enter Oracle Cloud Infrastructure (OCI) CLI commands into a familiar Unix-like shell and perform quick tasks.

You might not know that we recently included the OCI software development kits (SDK) in Cloud Shell. They’re preinstalled and configured to authenticate using your account. This simplification allows you to skip the prerequisites and immediately test out commands and code snippets, so you can focus on learning what makes your app work best. We’ve also introduced the Cloud Shell Try It button in our documentation, which lets you immediately try out a CLI command to test its behavior. I describe both of these topics in this post. If you don’t already have an account and want to follow along, you can sign up for one.

Try the OCI SDKs in Cloud Shell

The great thing about using the SDKs in Cloud Shell is that each SDK is already working properly, and your session is authenticated for you. You don’t need to spend time setting up the SDK and provisioning an API Key in the console as you would normally when working on your local system.

To start using the SDKs in Cloud Shell, it takes a few commands. First, pick your favorite SDK from the SDK Quick Starts with Cloud Shell page. We currently have SDKs for Java, Python, Typescript, .NET, Go, and Ruby. Now open up Cloud Shell by clicking the button indicated in the following screenshot. A new session starts in the bottom part of the web page.

A screenshot of the Oracle Cloud Shell Get Started page with green arrows pointing to a white button in the top-right menu.

In the example, I set up the Python SDK in Cloud Shell with a handful of commands. Then I can start tinkering in Python.

Start the Python3 Interpreter by typing python3.

user@cloudshell:oci (us-phoenix-1)$ python3
Python 3.6.8 (default, Oct  1 2020, 20:32:44) 
[GCC 4.8.5 20150623 (Red Hat 4.8.5-44.0.3)] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> 

Now enter the following lines of commands in succession:


import oci
object_storage_client = oci.object_storage.ObjectStorageClient(oci.config.from_file())
result = object_storage_client.get_namespace()
print("Current object storage namespace: {}".format(result.data))

Your Cloud Shell session displays the following result:

A screenshot of the resulting code running in Oracle Cloud Shell.

These commands print the name of the tenancy, which is useful in building an app and as a test to determine that the commands work properly before adding them to a code snippet. Cloud Shell also includes PowerShell, a powerful IT management tool for day-to-day tasks and running DevOps scripts.

Try CLI commands from the Oracle Cloud documentation

You might have recently noticed that in the Oracle Cloud documentation, you can now find the Try It button. When reading about a technical topic, such as a specific command, you can quickly try it out in Cloud Shell. The button looks like the following on the Getting Started with Cloud Shell page.

In the example page, clicking the Try It button opens a browser tab with Cloud Shell and copies the oci os ns get command into your clipboard. When the Cloud Shell session starts, paste the text onto your command line. Press enter to discover the following results:

A screenshot of Cloud Shell running the example command.

Over time, plan to see more places of these buttons in our documentation.

Try it on your own

We hope that these two new features with Cloud Shell save you extra time and make you more productive when working with Oracle Cloud. Contact us with your feedback on these features with a comment. Now Try It on your own!

Be the first to comment

Comments ( 0 )
Please enter your name.Please provide a valid email address.Please enter a comment.CAPTCHA challenge response provided was incorrect. Please try again.Captcha