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
The previous action updates the App Configuration instance whenever `appsettings.json` is updated. This action inserts a dynamic label on each sync, ensuring that each sync can be uniquely identified and allowing code changes to be mapped to config changes.
62
-
63
-
The first section of this workflow specifies that the action triggers *on* a *push* containing `appsettings.json` to the *master* branch. The second section runs a job that creates a unique label for the config update based on the commit hash. The job then updates the App Configuration instance with the new values and the unique label for this update.
60
+
## Use strict sync
61
+
By default the GitHub action does not enable strict mode, meaning that the sync will only add key-values from the configuration file to the App Configuration instance (no key-value pairs will be deleted). Enabling strict mode will mean key-value pairs that aren't in the configuration file are deleted from the App Configuration instance, so that it matches the configuration file. If you are syncing from multiple sources or using Azure Key Vault with App Configuration, you'll want to use different prefixes or labels with strict sync to avoid wiping out configuration settings from other files (see samples below).
64
62
65
63
```json
66
64
on:
@@ -74,10 +72,6 @@ jobs:
74
72
syncconfig:
75
73
runs-on: ubuntu-latest
76
74
steps:
77
-
# Creates a label based on the branch name and the first 8 characters
When strict mode is enabled, the sync ensures that the App Configuration instance matches the configuration file for the given prefix and label exactly. Key-value pairs with the same prefix and label that aren't in the configuration file are deleted.
96
-
97
-
If strict mode isn't enabled, the sync will only set key-values from the configuration file. No key-value pairs will be deleted.
91
+
If your configuration is in multiple files, you can use the pattern below to trigger a sync when either file is modified. This pattern uses the glob library https://www.npmjs.com/package/glob
92
+
93
+
```json
94
+
on:
95
+
push:
96
+
branches:
97
+
- 'master'
98
+
paths:
99
+
- 'appsettings.json'
100
+
- 'appsettings2.json'
101
+
102
+
jobs:
103
+
syncconfig:
104
+
runs-on: ubuntu-latest
105
+
steps:
106
+
# checkout done so that files in the repo can be read by the sync
Specifying prefixes or labels in your sync action will sync only that particular set. This is important for using strict sync with multiple files. Depending on how the configuration is set up, either a prefix or a label can be associated with each file and then each prefix or label can be synced separately so that nothing is overwritten. Typically prefixes are used for different applications or services and labels are used for different environments.
119
+
120
+
Sync by prefix:
121
+
122
+
```json
123
+
on:
124
+
push:
125
+
branches:
126
+
- 'master'
127
+
paths:
128
+
- 'appsettings.json'
129
+
130
+
jobs:
131
+
syncconfig:
132
+
runs-on: ubuntu-latest
133
+
steps:
134
+
# checkout done so that files in the repo can be read by the sync
135
+
- uses: actions/checkout@v1
136
+
- uses: azure/appconfiguration-sync@v1
137
+
with:
138
+
configurationFile: 'appsettings.json'
139
+
format: 'json'
140
+
# Replace <ConnectionString> with the name of the secret in your repository
The following action inserts a dynamic label on each sync, ensuring that each sync can be uniquely identified and allowing code changes to be mapped to config changes.
175
+
176
+
The first section of this workflow specifies that the action triggers *on* a *push* containing `appsettings.json` to the *master* branch. The second section runs a job that creates a unique label for the config update based on the commit hash. The job then updates the App Configuration instance with the new values and the unique label for this update.
98
177
99
178
```json
100
179
on:
@@ -108,6 +187,10 @@ jobs:
108
187
syncconfig:
109
188
runs-on: ubuntu-latest
110
189
steps:
190
+
# Creates a label based on the branch name and the first 8 characters
Developers using Azure Key Vault with AppConfiguration should use two separate files, typically an appsettings.json and a secretreferences.json. The secretreferences.json will contain the url to the key vault secret.
The GitHub Action can then be configured to do a strict sync on the appsettings.json, followed by a non-strict sync on secretreferences.json. The following sample will trigger a sync when either file is updated:
215
+
216
+
```json
217
+
on:
218
+
push:
219
+
branches:
220
+
- 'master'
221
+
paths:
222
+
- 'appsettings.json'
223
+
- 'secretreferences.json'
224
+
225
+
jobs:
226
+
syncconfig:
227
+
runs-on: ubuntu-latest
228
+
steps:
229
+
# checkout done so that files in the repo can be read by the sync
230
+
- uses: actions/checkout@v1
231
+
- uses: azure/appconfiguration-sync@v1
232
+
with:
233
+
configurationFile: 'appsettings.json'
234
+
format: 'json'
235
+
# Replace <ConnectionString> with the name of the secret in your repository
0 commit comments