-
Notifications
You must be signed in to change notification settings - Fork 168
Description
Proposed topic or title
Local deployment state
Location in table of contents.
/ Publish and Deploy / Azure deployment with Aspire / Local deployment state
Reason for the article
Starting in Aspire 13, we're introducing behavior that caches aspects of deployment state locally on the users machine to make repeated deployments faster. We should document this behavior so users are aware of the functionality.
Article abstract
Aspire Deploy Command: Deployment State Behavior
Overview
The aspire deploy
command manages deployment state through cached configuration files stored in ~/.aspire/deployments/{AppHostSha}/{environment}.json
. This caching mechanism streamlines repeated deployments by preserving provisioning settings and parameters.
Default Behavior
First Deployment
When running aspire deploy
for the first time:
- Prompts for provisioning information (subscription ID, resource group name, location)
- Prompts for deployment parameters (e.g., API keys, connection strings)
- Initiates the deployment process
- Saves all prompted values and deployment state to
~/.aspire/deployments/{AppHostSha}/production.json
Subsequent Deployments
On subsequent aspire deploy
executions:
- Detects the existing deployment state file at
~/.aspire/deployments/{AppHostSha}/production.json
- Notifies the user that settings will be read from the cached file
- Prompts for confirmation to load the cached settings
- Loads the configuration from the cached file into the configuration provider
- Proceeds with deployment using the cached values (no re-prompting)
Environment-Specific Deployments
Specifying an Environment
Use the --environment
flag to deploy to different environments:
aspire deploy --environment staging
First deployment to a specific environment:
- Prompts for all provisioning and parameter information
- Saves deployment state to
~/.aspire/deployments/{AppHostSha}/{environment}.json
(e.g.,staging.json
)
Subsequent deployments:
- Reads the environment-specific cached file
- Loads configuration from the cached state
- Uses cached values without prompting
Environment Variable Support
The deployment environment can also be specified using the DOTNET_ENVIRONMENT
environment variable:
export DOTNET_ENVIRONMENT=staging && aspire deploy
This behaves identically to using the --environment
flag, loading the appropriate cached configuration file.
Cache Management
Clearing the Cache
Use the --clear-cache
flag to reset deployment state:
aspire deploy --clear-cache
Behavior:
- Prompts for confirmation before deleting the cache for the specified environment
- Deletes the environment-specific deployment state file (e.g.,
~/.aspire/deployments/{AppHostSha}/production.json
) - Prompts for all provisioning and parameter information as if deploying for the first time
- Proceeds with deployment
- Does not save the prompted values to cache
Environment-Specific Cache Clearing
The --clear-cache
flag respects the environment context:
aspire deploy --environment staging --clear-cache
This clears only the staging.json
cache file while leaving other environment caches (like production.json
) intact.
File Storage Location
- Path pattern:
~/.aspire/deployments/{AppHostSha}/{environment}.json
- Default environment:
production
- AppHostSha: A hash value representing the application host configuration, ensuring deployment states are specific to each application configuration
Key Points
- Each environment maintains its own isolated deployment state
- Cached values persist across deployments unless explicitly cleared
- The
--clear-cache
flag performs a one-time deployment without persisting new values - Environment selection can be specified via flag or environment variable
- Users are prompted for confirmation when loading cached settings
- Cache files are stored per application (via AppHostSha) and per environment
Relevant searches
No response