As a developer, knowing the best way to save time is partly about knowing the best tools for the job.
Specifically, when you’re developing in Visual Studio Code, having to navigate away from your IDE to do some quick task on your local terminal can quickly become an annoying hassle.
If you find yourself using the IBM Cloud CLI while also developing on Visual Studio Code, try this handy shortcut. The revamped IBM Cloud CLI Extension for Visual Studio Code provides access to capabilities from the IBM Cloud CLI directly within the Visual Studio Code editor’s Command Palette. This enables you to quickly access a subset of ibmcloud
commands, including to view a targeted environment, modify Kubernetes clusters, build and deploy cloud-native applications and more — all without the need to leave the editor’s context.
To get started, just install the IBM Cloud CLI VS Code extension in VS Code and type ibmcloud
in the Command Palette to see a list of all the available commands.
Installation
The fastest way to install the IBM Cloud CLI extension is to open VS Code’s Quick Open (⌘P for Mac and Ctrl+P for Windows/Linux) and enter the ext install IBM Cloud CLI
command.
You can also install the IBM Cloud CLI extension by opening the Extensions sidebar inside of the VS Code editor and searching for IBM Cloud CLI
. From there, click Install. You’ll also need IBM Cloud CLI plugin installed on your system.
Usage
To begin using the IBM Cloud CLI, go to View > Command Palette (⇧⌘P for Mac and Ctrl+Shift+P for Windows/Linux) and type ibmcloud
to see the list of all available commands.
You’ll need to log in to interact with IBM Cloud. If you’re already logged in by using the CLI in a terminal window, you won’t have to log in again.
Here are some main IBM Cloud CLI commands that you can utilize in the VS Code Command Palette:
-
ibmcloud login
: Log in to the IBM Cloud CLI. -
ibmcloud target
: View targeted IBM Cloud org, space, account, and resource group. -
ibmcloud regions
: View the information for all regions on IBM Cloud. -
ibmcloud ks
: View and modify your Kubernetes clusters and worker nodes.
How to build/deploy an app using the IBM Cloud dev workflow
Prerequisite tools:
- IBM Cloud CLI: The command-line interface to interact with IBM Cloud API.
- Docker: You need Docker to deliver and run software in packages called containers — this is required for ibmcloud dev.
Before you begin, make sure you’ve done the following:
- Installed the IBM Cloud CLI Extension for VS Code.
- Logged into IBM Cloud:
- Open the VS Code Command Palette (⇧⌘P for Mac and Ctrl+Shift+P for Windows/Linux).
- Use the
ibmcloud login
command to log in to IBM Cloud (using your IBM Cloud credentials).
To get started:
- Create a project on IBM Cloud by typing
ibmcloud dev create
in the VS Code integrated terminal and following the steps. For more information, visit the IBM Cloud CLI Documentation. - Open the project’s folder in VS Code (File > Open Folder or ⌘O for Mac, Ctrl+O for Windows).
- Begin building, running and deploying your app by using the following commands in the VS Code Command Palette:
- Use the
ibmcloud dev build
command to build the app into a Docker image. - Use the
ibmcloud dev debug
command to debug the app in local Docker for development. - Use the
ibmcloud dev run
command to run the app in local Docker in release mode. - Use the
ibmcloud dev deploy
command to deploy the app (in the Docker container) to IBM Cloud. - Use the
ibmcloud dev view
command to open your deployed project on IBM Cloud in a web browser. - Use the
ibmcloud dev console
command to open the IBM Cloud console for your project in a web browser.
- Use the
What’s next?
Now, it’s time to try it out for yourself and build amazing things on IBM Cloud.
If you find a bug or have a feature request, then let us know by opening an issue. For additional support, you can also find us on Slack.