MOFAKH.COM
← Back to profile
Azure Fundamentals

Setting up your machine: a safe account, the Azure CLI and local emulators

Nov 20, 202612 min readWritten

A working Azure setup is two halves: a real account with guard rails so it cannot run up a bill, and a set of local tools so most work never needs the cloud at all. This part creates the free account and a budget, installs and signs in to the Azure CLI, then sets up Azurite, Functions Core Tools, Docker and the editor extensions, ending with a smoke test of every piece.

This is the fifth part of the Azure series, and the first hands-on one. Parts 1 to 4 built the concepts: what a cloud is, the hierarchy, the physical layout, Resource Manager. This part builds the workbench that the rest of the path uses.

The setup has two halves, and the split is deliberate:

  • A real Azure account, used sparingly: for the few services that cannot run locally, and to see that local code behaves the same in the cloud. It gets guard rails before anything else.
  • Local tools and emulators, used for nearly everything. They are free, fast, work offline, and cannot produce a bill.

Part one: an Azure account with guard rails

The free account

Microsoft offers a free account for new customers. At the time of writing, its terms have three layers (check the current terms when you sign up, as they change):

LayerWhat you get
Credita sum of credit (USD 200 or the local equivalent) to spend on almost any service during the first 30 days
12 months freemonthly free amounts of selected popular services, for the first 12 months
Always freesmall monthly amounts of a long list of services, for as long as you have the account

Signing up needs a phone number and a credit or debit card. The card is for identity verification; the free account does not charge it unless you choose to upgrade. When the 30-day credit runs out or expires, the subscription is disabled rather than charged, until you decide whether to move to pay-as-you-go.

Two details that catch people out:

  • The "12 months free" amounts are monthly quantities, not unlimited use. Go over the amount in a month and the excess is billed at normal rates (from the credit, or later from the card once upgraded). Unused amounts do not roll over.
  • After you upgrade to pay-as-you-go, nothing is disabled automatically any more. From then on, the budget below is your main protection.

If your employer or school already gives you an Azure subscription (many developer programmes include monthly credit), use that instead; everything in this path works the same.

Set a budget before creating anything

The first thing to do in a new subscription, before creating a single resource, is to create a budget. In the portal: search for Cost Management, open Budgets, choose Add, and set:

SettingLearner-friendly value
Scopeyour subscription
Amounta small number, for example 5 or 10 in your currency
Reset periodmonthly
Alertsat 50%, 90% and 100% of actual cost, plus 100% of forecasted cost
Alert recipientsyour email address

The forecast alert is the most useful one: it fires when Azure predicts you will go over by the end of the month, often days before you actually do.

Important
A budget notifies you; it does not stop or delete anything. Azure keeps running your resources past the budget, and you keep paying. The budget is an alarm, not a circuit breaker. The habit that actually prevents bills is the one below: delete what you are not using.

The one habit that prevents bills

Every experiment in this path follows the same lifecycle, built on Part 2's rule that deleting a resource group deletes everything in it:

  1. Create a resource group for the experiment.
  2. Create everything for the experiment inside it.
  3. When done, delete the resource group.
bash
az group create --name rg-learn-storage --location westeurope
# ... experiment ...
az group delete --name rg-learn-storage --yes --no-wait

Nothing can be forgotten, because nothing exists outside a resource group. Part 6 covers what costs money while idle, but this habit alone removes nearly all the risk.

Part two: the Azure CLI

The Azure CLI (az) is the command-line client for Resource Manager from Part 4. It runs on Windows, macOS and Linux, and this path uses it constantly because commands can be read, copied and repeated in a way portal clicks cannot.

Install it

bash
# Windows (winget)
winget install --exact --id Microsoft.AzureCLI
 
# macOS (Homebrew)
brew update && brew install azure-cli
 
# Debian or Ubuntu
curl -sL https://aka.ms/InstallAzureCLIDeb | sudo bash

Open a new terminal afterwards so it picks up the updated PATH, then check:

bash
az version

The CLI updates often. az upgrade updates it in place.

Sign in

bash
az login

This opens a browser (or, on Windows, a system sign-in window) where you sign in with your Azure account. Behind the scenes it is the OAuth flow from the Azure Identity series: you authenticate with Entra ID, and the CLI receives tokens it caches in your user profile (the .azure folder in your home directory) and refreshes automatically. Recent versions then show a list of your subscriptions and ask which one to use.

On a machine without a browser, such as a remote server or a container, use the device code flow instead: the CLI prints a short code, and you enter it on another device's browser.

bash
az login --use-device-code

Check where you are

Before creating anything, always check which subscription is active. Running commands against the wrong subscription is a classic mistake once you have more than one:

bash
az account show --output table
az account list --output table
az account set --subscription "<subscription name or id>"

Reading the CLI's output

Every az command returns JSON by default. Three global options make it far more usable:

OptionWhat it doesExample
--output table (-o table)prints a readable table instead of JSONaz group list -o table
--output tsvprints bare values, ideal for scriptsaz group show -n rg-learn -o tsv --query id
--queryfilters and reshapes the JSON with a JMESPath expressionaz group list --query "[].name"

--query is worth learning early, because it turns any command into a precise question: az resource list --query "[?location=='westeurope'].name" lists the names of every resource in West Europe.

To make tables the default for your own interactive use:

bash
az config set core.output=table

Peek at the token (once, to see it is real)

To make Part 4 concrete, you can ask the CLI for the access token it attaches to Resource Manager requests:

bash
az account get-access-token --query expiresOn --output tsv

That query deliberately prints only the expiry time and leaves the token itself out. If you do print the raw accessToken, treat it like a password: anyone holding it can act as you until it expires. Pasting it into a JWT decoder you trust (one that decodes locally) shows the claims the Azure Identity series described: your identity, the tenant, the audience, the expiry.

Part three: local emulators

These tools let most of the path run with no Azure subscription involved at all.

Docker

Several emulators, as well as Redis, run most easily as containers. Install Docker Desktop (Windows or macOS) or Docker Engine (Linux), then check:

bash
docker version
docker run --rm hello-world

Azurite: Azure Storage on your machine

Azurite is Microsoft's open-source emulator for Azure Storage. It emulates three of the four storage services on fixed local ports:

ServiceLocal portEmulated?
Blob storage10000yes
Queue storage10001yes
Table storage10002yes
Azure Filesn/ano, Files is not emulated

The Azure Queue Storage series already used it. There are three ways to run it; pick one:

bash
# 1. As a Docker container (nothing else to install)
docker run -d --name azurite -p 10000:10000 -p 10001:10001 -p 10002:10002 \
  mcr.microsoft.com/azure-storage/azurite
 
# 2. As a global npm package (needs Node.js)
npm install -g azurite
azurite --silent --location ./azurite-data --debug ./azurite-data/debug.log
 
# 3. As the Azurite extension in VS Code (start it from the command palette)

Code and tools find Azurite through one special connection string that means "the local emulator, with its well-known development account":

Diagram
UseDevelopmentStorage=true

Azurite is a close emulation, not a perfect one. It does not implement every feature or enforce every limit of the real service, so anything subtle (performance, exact error behaviour, newer features) should be checked against a real storage account before relying on it.

Azure Storage Explorer

Azure Storage Explorer is a free desktop app for browsing storage accounts: containers, blobs, queues and tables. It connects to Azurite out of the box (under "Emulator & Attached") and to real storage accounts once you sign in. Being able to see the blob that your code just uploaded, or the message sitting in a queue, makes the Storage topic much easier to follow.

Azure Functions Core Tools

Core Tools (the func command) runs Azure Functions on your machine, with the same runtime the cloud uses. It is also how you create function projects and, later, deploy them. Install version 4:

bash
# Windows (winget)
winget install Microsoft.Azure.FunctionsCoreTools
 
# macOS (Homebrew)
brew tap azure/functions && brew install azure-functions-core-tools@4
 
# Any OS with Node.js
npm install -g azure-functions-core-tools@4

Check it with func --version. Functions that use storage triggers need a storage account even locally, and that is what Azurite provides: a local function app's settings point at UseDevelopmentStorage=true. The Functions topic starts from here.

Service Bus emulator and Redis (later topics)

Two more local services come up later; they only need Docker, so there is nothing to install now:

  • The Azure Service Bus emulator runs as a set of containers. Note that it keeps nothing when restarted: every restart starts with empty queues. The Messaging topic sets it up.
  • Redis runs as a single container (docker run -d --name redis -p 6379:6379 redis). The data services topic uses it.

The .NET SDK

The code in this path is C# on current .NET. Check the SDK is installed:

bash
dotnet --list-sdks

Part four: the editor

Visual Studio Code with a few extensions covers everything in this path (Visual Studio and JetBrains Rider work just as well):

ExtensionWhat it adds
C# Dev KitC# editing, debugging and test running
Azure Resourcesbrowse your subscriptions and resource groups in the sidebar
Azure Functionscreate, run, debug and deploy function apps
Azuritestart and stop the storage emulator from the editor
Bicepsyntax, validation and completion for Bicep files

The Azure extensions sign in with their own login, separate from the CLI's; sign in once from the Azure sidebar.

The smoke test

With everything installed, one short run confirms each piece works. None of it costs money, and the cloud part cleans up after itself.

bash
# 1. CLI and account: who am I, and which subscription is active?
az account show --output table
 
# 2. Resource Manager: create an empty resource group, list it, delete it.
#    An empty resource group costs nothing.
az group create --name rg-smoke-test --location westeurope
az group list --output table
az group delete --name rg-smoke-test --yes
 
# 3. Azurite: with the emulator running, create a container and upload a file.
echo "hello azure" > hello.txt
az storage container create --name smoke --connection-string "UseDevelopmentStorage=true"
az storage blob upload --container-name smoke --name hello.txt --file hello.txt \
  --connection-string "UseDevelopmentStorage=true"
az storage blob list --container-name smoke --output table \
  --connection-string "UseDevelopmentStorage=true"
 
# 4. Core Tools and .NET
func --version
dotnet --list-sdks

After step 3, open Azure Storage Explorer, look under the emulator's blob containers, and you should see smoke with hello.txt inside. That moment, a file sitting in "Azure Storage" that never left your machine, is the local-first idea this whole path relies on.

The checklist

ToolCheck withUsed for
Azure account with a budgetCost Management, Budgetsthe few cloud-only parts
Azure CLIaz version, az account showmanaging Azure from the terminal
Dockerdocker versionrunning emulators and Redis
AzuriteStorage Explorer shows the emulatorBlob, Queue and Table storage, locally
Azure Storage Exploreropens and connectsseeing what your code stored
Functions Core Toolsfunc --versionrunning functions locally
.NET SDKdotnet --list-sdksall the C# code
VS Code + extensionsAzure sidebar signed inediting, debugging, browsing

The one idea to hold onto

Use the cloud sparingly and safely; use your laptop for everything else. A real account gets a budget first (an alarm, not a brake) and the habit of one resource group per experiment, deleted afterwards. The Azure CLI is a scriptable client for Resource Manager, signed in through the same Entra OAuth flow as everything else. Azurite, Core Tools and Docker run Storage, Functions and the other services locally, so most of this path costs nothing and works offline.

Further reading

What comes next

The account has a budget, but a budget only tells you after money is being spent. Part 6 explains how Azure decides what to charge in the first place: meters, the dimensions every service is priced on, which resources keep costing money while doing nothing, how to estimate a bill before building anything, and the habits that keep a learning subscription at zero.