Set Up Azure Cloud Shell
Learn how to set up Azure Cloud Shell — get a browser-based terminal with authenticated access to your Azure resources. This lesson covers the basics, step-by-step setup, and common troubleshooting.
Focus: set up azure cloud shell
You’ve probably pasted the same az command into your local terminal a hundred times, only to hit an authentication error or a version mismatch that wastes ten minutes. That friction disappears when you set up Azure Cloud Shell — a browser-based terminal that comes pre-authenticated, pre-configured, and always up to date. In this lesson, you’ll stop fighting your local environment and start working with Azure from anywhere, in seconds.
The problem this lesson solves
Local Azure tooling is a constant source of pain. You install the Azure CLI, az login pops open a browser, and then you discover your CLI is outdated or your shell profile is missing the right extensions. On a shared machine, you might not even have permission to install anything. When you’re on a training call or debugging a production incident, the last thing you want is to wrestle with your environment.
Azure Cloud Shell eliminates that entire class of problems. It’s a terminal hosted by Microsoft that runs in your browser, with the Azure CLI, PowerShell, and common tools already installed. It’s tied to your Azure account, so you’re already authenticated. It persists files in an Azure storage account, so your scripts and configs survive reboots and device changes.
By the end of this lesson, you’ll be able to open Azure Cloud Shell, map its components to your Azure subscription, and run your first commands without touching a local install.
Core concept / mental model
Think of Azure Cloud Shell as a disposable, pre-loaded workstation you summon from any browser. You don’t install anything — you just open a URL and you’re in a shell that has:
- The Azure CLI (
az) and PowerShell with Azure modules - A home directory of 5 GB backed by Azure Files
- A built-in code editor (yes, you can edit files right in the browser)
- Secure automatic authentication — no
az loginneeded
Why is this a game-changer? Because your shell is now stateless in setup, stateful in files. The underlying virtual machine changes per session, but your cloud drive persists. You get a consistent environment without maintaining it.
A common comparison is a Docker container: ephemeral compute, persistent volume. Here the container is Azure’s infrastructure, and the persistent volume is your storage account.
How it works step by step
The setup happens in a logical order. Follow this mental model, and you’ll never lose track:
- Azure subscription — Cloud Shell requires an active subscription to create the storage account that backs your home directory.
- Storage account and file share — The first time you open Cloud Shell, Azure asks you to create or associate a storage account. This holds your files across sessions.
- Shell choice — Bash or PowerShell. You can switch anytime, but your cloud drive stays the same.
- Session initialization — Each session boots a fresh VM with your tools and mounts your cloud drive.
- Daily use — You run
az,kubectl,terraform, etc. Everything is already authenticated.
What happens when you first open it?
When you open the Cloud Shell, you’ll see a prompt to create storage. If you already have a storage account, choose it; otherwise let Azure create a new one in a supported region. That’s it. The shell appears in a frame at the bottom of the portal, or in a full browser tab.
Hands-on walkthrough
Let’s get you running. Follow these steps — they take about two minutes.
Step 1: Open Azure Cloud Shell
Go to shell.azure.com or click the Cloud Shell icon (a terminal icon) in the Azure portal top bar. You’ll see a welcome screen.
Step 2: Choose your shell and create storage
You’ll be prompted to select Bash or PowerShell. For this tutorial, choose Bash. Then you’ll see a message about creating a storage account. Click Create storage. If you’ve used Azure before, you can also pick an existing resource group and storage account.
# After the shell opens, verify your identity and subscription
echo "Hello from Azure Cloud Shell"
whoami
az account show
Expected output: your username (likely your Azure login), and a JSON block with your subscription details like id, name, and tenantId.
Step 3: Confirm the Azure CLI version
az --version
Expected output: a list of Azure CLI modules and their versions. You’ll see azure-cli with a recent version number (e.g., 2.60.0).
Step 4: Test file persistence
Create a file in your home directory, close the shell, and reopen it. The file should still be there.
cd ~
echo "Cloud Shell rocks" > hello.txt
cat hello.txt
# Close the browser tab, reopen shell.azure.com, then:
cat ~/hello.txt
If you see Cloud Shell rocks, your cloud drive is working.
Step 5: Install a tool (no admin needed)
Because you’re on a fresh VM, you can use apt to install packages without sudo every time — but they won’t survive a session. For persistent tools, add them to your cloud drive or use a startup script.
# Install a utility temporarily
sudo apt-get update && sudo apt-get install -y jq
# Use it
echo '{"key":"value"}' | jq .key
Compare options / when to choose what
| Option | Authentication | Persistence | Use case |
|---|---|---|---|
| Azure Cloud Shell (Bash) | Automatic, via Azure login | Cloud drive (5 GB) | Quick CLI work, demos, training |
| Azure Cloud Shell (PowerShell) | Automatic, via Azure login | Cloud drive (5 GB) | Azure PowerShell scripts, ARM templates |
| Local Azure CLI | az login every machine |
Local files, but no sync | Long-running automation, offline work |
| Azure CLI in Docker | az login inside container |
Docker volumes only | CI/CD pipelines, reproducible environments |
When to choose what:
- Cloud Shell is perfect for ad-hoc tasks, learning, and when you need a consistent environment across devices.
- Local CLI is better when you need tight integration with local scripts or offline access.
- Docker is great for CI/CD to ensure the exact CLI version in pipelines.
Troubleshooting & edge cases
Even with Cloud Shell, things can go sideways. Here’s how to fix the common issues:
“You have no storage account” or “must create storage”
This appears when you haven’t associated a storage account. Click Create storage and choose a region close to you. If you don’t see that button, check that your subscription is active and you have owner or contributor rights.
“Your session has expired”
Cloud Shell sessions have a timeout (around 20 minutes of inactivity). You’ll be prompted to restart. Your files are safe — just click Reconnect.
“You need to create a new storage account” after you already have one
If you’re using a subscription that isn’t the default, Cloud Shell might not find your previous storage. Switch to the correct subscription using the subscription selector in the portal or run az account set --subscription <id> in the shell.
Azure CLI not found after switching shells
You might be in an old session. Use the refresh button in the Cloud Shell toolbar to restart the session. If that fails, log out and back in.
Bash vs. PowerShell confusion
Remember that your cloud drive is shared, but your shell history and installed tools are per-session. If you install a package in Bash, it won’t be there in PowerShell.
What you learned & what's next
You now know how to set up Azure Cloud Shell, how it stores files, and how to run your first commands. You can explain the core idea behind Cloud Shell, complete a hands-on exercise, and connect it to your Azure subscription.
What’s next? In the next lesson, you’ll use Cloud Shell to create resources like resource groups and virtual machines. You’ll apply the same environment to manage your infrastructure without ever leaving the browser.
Practice recap
Open shell.azure.com, create your storage, then run az account show to confirm your subscription. Create a file on your cloud drive, close the tab, reopen, and verify it’s still there. Finally, try installing jq and using it to parse a JSON response from az group list -o json.
Common mistakes
- Forgetting to create a storage account the first time — you can’t use Cloud Shell without one.
- Assuming installed tools persist across sessions — they don’t; only your cloud drive does.
- Using Cloud Shell for long-running background jobs — it times out after ~20 minutes of inactivity.
- Switching between Bash and PowerShell and expecting your shell history to carry over.
Variations
- Azure CLI in Docker containers for CI/CD pipelines.
- Local Azure CLI installation for offline or automated scripts.
- Azure Cloud Shell in full-screen mode for a more IDE-like experience.
Real-world use cases
- Quickly run Azure CLI commands to check resource status from any machine without installing anything.
- Experiment with Azure PowerShell scripts in a sandboxed environment that resets each session.
- Use Cloud Shell as a temporary jump box to manage AKS clusters via kubectl without local config.
Key takeaways
- Azure Cloud Shell is a browser-based, pre-authenticated terminal with the Azure CLI and PowerShell.
- Your 5 GB cloud drive persists files across sessions; installed packages do not.
- First-time setup requires creating a storage account; choose an existing one if you have it.
- You can switch between Bash and PowerShell, but they share the same cloud drive.
- Troubleshoot common issues like expired sessions by reconnecting or switching subscriptions.
- Use Cloud Shell for quick, context-aware Azure tasks; use local CLI for long-running automation.
Keep learning
Related tutorials, quizzes, and articles for this topic.
Discussion
Questions, corrections, and tips help everyone reading this page.
0 comments
Add a comment
No comments yet — start the thread.