Azurite is an emulator for Azure blob, queue and table that can be used in a local development environment.
“Newer” Visual Studio installations should include this emulator. Whether it has started correctly or works as expected is hidden in mist.
So, I use these files to start azurite emulator from my Windows desktop.
If the default azurite ports in use, the related processes are automatically stopped.
Prerequisites: install Azurite to c:\azurite
Put the following 2 files in c:\azurite folder and create a shortcut for azurite.bat on your window desktop:
c:\azurite\azurite.bat:
@echo off pwsh -NoLogo -NoProfile -File "C:\azurite\azurite.ps1" pause
c:\azurite\azurite.ps1:
# --- Settings ---
# --- The path where azurite is installed
$azuriteRoot = 'C:\azurite'
$portsToFree = 10000, 10001, 10002 # Blob, Queue, Table
# --- Go to working folder ---
Set-Location -Path $azuriteRoot
# --- Show Azurite version ---
Write-Host "Running Azurite Version:" (azurite -v)
# --- Function: stop whatever is listening on specified ports ---
function Stop-ListeningProcessesOnPorts {
param([int[]]$Ports)
foreach ($p in $Ports) {
try {
# Find listeners on the port
$conns = Get-NetTCPConnection -LocalPort $p -State Listen -ErrorAction SilentlyContinue
if (-not $conns) {
Write-Host "Port $p is free."
continue
}
# Stop each owning process
foreach ($c in $conns) {
try {
$proc = Get-Process -Id $c.OwningProcess -ErrorAction Stop
Write-Host "Found process '$($proc.ProcessName)' (PID $($proc.Id)) already listening on port $p, shutting it down..."
Stop-Process -Id $proc.Id -Force
}
catch {
Write-Warning "Failed to stop PID $($c.OwningProcess) on port $p. $_"
}
}
}
catch {
Write-Warning "Could not query listeners on port $p. $_"
}
}
}
# --- Kill ports if needed ---
Write-Host "-----------------------------"
Write-Host "Checking ports needed by Azurite:"
Stop-ListeningProcessesOnPorts -Ports $portsToFree
Write-Host "-----------------------------"
# --- Start Azurite ---
azurite -l $azuriteRoot -d (Join-Path $azuriteRoot 'debug.log')
# --- Keep window open after Azurite exits ---
Read-Host "Press Enter to exit"
Docs:
https://learn.microsoft.com/en-us/azure/storage/common/storage-use-azurite
https://learn.microsoft.com/en-us/azure/storage/common/storage-install-azurite