During Public Preview you can use the Team plan for free, and get an early-adopter discount at GA. Sign in
Persistence
By default Locally starts empty every time - however when started with --persist, Locally keeps your Resources and their data across restarts.
This can help match a long-running environment, which has trade-offs (and is why this isn't the default) - but allows you to stop what you're doing in Locally and continue some other time. You can use this functionality alongside Locally Snapshots to save your state for later, or optionally send it to a team member too (on the Team plan).
Turning it on
$
locally build --persist
When Locally starts it'll load what was saved last time - and whilst it's running it'll save every 15 minutes (if something's changed) and again when you stop it. To quit without saving, press Ctrl-C a second time.
Changes to Locally are paused briefly during each save - meaning that requests will get a 503 (which the Azure SDKs and tools will retry automatically).
One saved state per project
By default --persist saves to a snapshot called default - however you can keep a separate one for each project by giving it a name:
$
locally build --persist=orders-api
Saved states appear in locally snapshot list alongside your other snapshots, and locally snapshot status shows what Persistence is doing.
Starting over
To discard the saved state and start from empty, you can use --clear-state:
$
locally build --persist --clear-state
If the saved state can't be loaded when Locally starts, Locally won't save again until it's restarted - which means your last good save isn't overwritten.
Loading a snapshot
You can load a snapshot using locally snapshot load whether or not Locally was started with --persist - however since loading a snapshot replaces everything in Locally, when using --persist this'll also replace your saved state the next time Locally saves. As such if you may want the current state back, take a snapshot of it first:
$
locally snapshot save --name before-load
What's kept
Everything a snapshot contains is kept - which includes your Subscriptions and Resources, the directory, role assignments and policy, and the data in the Data Plane Emulators (including applications you've deployed and databases). The keys Locally uses to sign tokens are kept too, meaning that tokens issued before a restart continue to work afterwards.
Saved states are stored alongside your other snapshots and contain your Resources' credentials - see Locally Snapshots for where these are kept.
Some things are kept regardless of whether you use --persist - your Tenant and Subscription IDs, the local CA, DNS configuration and installed plugins. Since your Subscription IDs don't change, you can also get back to where you were without --persist by re-running your Infrastructure as Code (e.g. terraform apply).
Plans and CI
Persistence requires the Standard plan or above - when using the Starter plan locally build --persist will stop before Locally starts and tell you which plan's required.
Note
locally ci doesn't support --persist - as such CI runs always start empty.Related
- Locally Snapshots - saving, loading, comparing and sharing snapshots.
- Machine Configuration - what Locally keeps in its config directory.
- Frequently Asked Questions
During Public Preview you can use the Team plan for free, and get an early-adopter discount at GA. Sign in