You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: docs/deployment/aspire-deploy/local-deployment-state.md
+56-9Lines changed: 56 additions & 9 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -11,9 +11,11 @@ The `aspire deploy` command manages deployment state through cached configuratio
11
11
12
12
## Default behavior
13
13
14
+
The `aspire deploy` command automatically manages deployment state based on whether cached configuration exists for your application and target environment.
15
+
14
16
### First deployment
15
17
16
-
When you run `aspire deploy` for the first time, the command:
18
+
When you run `aspire deploy` for the first time, or for the first time in a target `--environment`, the command:
17
19
18
20
1. Prompts for provisioning information (subscription ID, resource group name, location).
19
21
1. Prompts for deployment parameters (for example, API keys, connection strings).
@@ -24,14 +26,16 @@ When you run `aspire deploy` for the first time, the command:
24
26
25
27
On subsequent `aspire deploy` executions, the command:
26
28
27
-
1. Detects the existing deployment state file at `~/.aspire/deployments/{AppHostSha}/production.json`.
29
+
1. Detects the existing deployment state file at _~/.aspire/deployments/{AppHostSha}/production.json_.
28
30
1. Notifies you that settings will be read from the cached file.
29
31
1. Prompts for confirmation to load the cached settings.
30
32
1. Loads the configuration from the cached file into the configuration provider.
31
33
1. Proceeds with deployment using the cached values (no re-prompting).
32
34
33
35
## Environment-specific deployments
34
36
37
+
Different deployment environments (such as development, staging, and production) typically require different configurations, resource names, and connection strings. The `aspire deploy` command supports environment-specific deployments, ensuring that each environment maintains isolated deployment state.
38
+
35
39
### Specify an environment
36
40
37
41
Use the `--environment` flag to deploy to different environments:
- Prompts for all provisioning and parameter information.
46
-
- Saves deployment state to `~/.aspire/deployments/{AppHostSha}/{environment}.json` (for example, `staging.json`).
50
+
- Saves deployment state to _~/.aspire/deployments/{AppHostSha}/{environment}.json_ (for example, _staging.json_).
47
51
48
52
**Subsequent deployments:**
49
53
@@ -63,6 +67,8 @@ This behaves identically to using the `--environment` flag, loading the appropri
63
67
64
68
## Cache management
65
69
70
+
The `aspire deploy` command provides mechanisms to manage cached deployment state, giving you control over when to use cached values and when to start fresh.
71
+
66
72
### Clear the cache
67
73
68
74
Use the `--clear-cache` flag to reset deployment state:
@@ -74,7 +80,7 @@ aspire deploy --clear-cache
74
80
**Behavior:**
75
81
76
82
1. Prompts for confirmation before deleting the cache for the specified environment.
77
-
1. Deletes the environment-specific deployment state file (for example, `~/.aspire/deployments/{AppHostSha}/production.json`).
83
+
1. Deletes the environment-specific deployment state file (for example, _~/.aspire/deployments/{AppHostSha}/production.json_).
78
84
1. Prompts for all provisioning and parameter information as if deploying for the first time.
79
85
1. Proceeds with deployment.
80
86
1.**Does not save the prompted values** to cache.
@@ -87,17 +93,58 @@ The `--clear-cache` flag respects the environment context:
87
93
aspire deploy --environment staging --clear-cache
88
94
```
89
95
90
-
This clears only the `staging.json` cache file while leaving other environment caches (like `production.json`) intact.
96
+
This clears only the _staging.json_ cache file while leaving other environment caches (like _production.json_) intact.
-**AppHostSha:** A hash value representing the application host configuration, ensuring deployment states are specific to each application configuration.
97
103
104
+
## Use deployment state in CI/CD pipelines
105
+
106
+
When using the `aspire deploy` command in continuous integration and deployment (CI/CD) pipelines, you might want to persist deployment state across pipeline runs. This approach can be useful for maintaining consistent deployment configurations without manual intervention.
107
+
108
+
### GitHub Actions example
109
+
110
+
The following example demonstrates how to cache deployment state in a GitHub Actions workflow using the `actions/cache` action:
This workflow caches the _~/.aspire/deployments_ directory, using the AppHost project file hash and branch reference as cache keys. Subsequent workflow runs restore the cached deployment state, allowing automated deployments without re-prompting for configuration values.
141
+
142
+
> [!CAUTION]
143
+
> When caching deployment state in CI/CD pipelines, ensure that your pipeline has appropriate access controls and secret management practices in place, as the cached state might contain sensitive configuration values.
144
+
98
145
## Security considerations
99
146
100
-
The deployment state files are stored locally on your machine in the `~/.aspire/deployments` directory. These files contain provisioning settings and parameter values, including secrets that might be associated with parameter resources. The `aspire deploy` command follows the same security pattern as .NET's user secrets manager:
147
+
The deployment state files are stored locally on your machine in the _~/.aspire/deployments_ directory. These files contain provisioning settings and parameter values, including secrets that might be associated with parameter resources. The `aspire deploy` command follows the same security pattern as .NET's user secrets manager:
101
148
102
149
- Files are stored outside of source code to mitigate against accidental secret leaks in version control.
103
150
- Secrets are stored in plain text in the local file system.
@@ -106,7 +153,7 @@ The deployment state files are stored locally on your machine in the `~/.aspire/
106
153
Consider these security best practices:
107
154
108
155
- Ensure your local machine has appropriate security measures in place.
109
-
- Be cautious when sharing or backing up files from the `~/.aspire/deployments` directory.
156
+
- Be cautious when sharing or backing up files from the _~/.aspire/deployments_ directory.
110
157
- Use the `--clear-cache` flag when you need to change sensitive parameter values.
0 commit comments