Skip to content

Commit 56a3a11

Browse files
Add ImportOnStartup documentation
1 parent cc1466d commit 56a3a11

File tree

3 files changed

+456
-222
lines changed

3 files changed

+456
-222
lines changed

13/umbraco-deploy/getting-started/deploy-settings.md

Lines changed: 152 additions & 74 deletions
Original file line numberDiff line numberDiff line change
@@ -33,60 +33,69 @@ For illustration purposes, the following structure represents the full set of op
3333
...
3434
"Umbraco": {
3535
"Deploy": {
36-
"Settings": {
37-
"ApiKey": "<your API key here>",
38-
"ApiSecret": "<your API secret here>",
39-
"Edition": "Default",
40-
"ExcludedEntityTypes": [],
41-
"RelationTypes" : [],
42-
"ValueConnectors": [],
43-
"SessionTimeout": "0.0:20:00",
44-
"SourceDeployTimeout": "0.0:20:00",
45-
"DatabaseCommandTimeout": "0.0:20:00",
46-
"EnableSignatureCacheReads": true,
47-
"HttpClientTimeout": "0.0:20:00",
48-
"DiskOperationsTimeout": "0.0:05:00",
49-
"SourceDeployBatchSize": null,
50-
"PackageBatchSize": null,
51-
"UseDatabaseBackedTransferQueue": true,
52-
"IgnoreBrokenDependenciesBehavior": "Restore",
53-
"AcceptInvalidCertificates": false,
54-
"TransferFormsAsContent": true,
55-
"TransferDictionaryAsContent": false,
56-
"IgnoreMissingLanguagesForDictionaryItems": false,
57-
"SetEmptyDictionaryItemsOnTransfer": true,
58-
"AllowMembersDeploymentOperations": "None",
59-
"TransferMemberGroupsAsContent": false,
60-
"ExportMemberGroups": true,
61-
"ReloadMemoryCacheFollowingDiskReadOperation": false,
62-
"AllowDomainsDeploymentOperations": "None",
63-
"AllowWebhooksDeploymentOperations": "None",
64-
"TrashedContentDeploymentOperations": "Import",
65-
"PreferLocalDbConnectionString": false,
66-
"MediaFileChecksumCalculationMethod": "PartialFileContents",
67-
"NumberOfSignaturesToUseAllRelationCache": 100,
68-
"ContinueOnMediaFilePathTooLongException": false,
69-
"SuppressCacheRefresherNotifications": false,
70-
"ResolveUserInTargetEnvironment": false,
71-
"Suspensions": {
72-
"DiskRead": "All",
73-
"PartialRestore": "All",
74-
"Restore": "All",
75-
"Deploy": "All",
76-
"Import": "All",
77-
"Export": "All"
78-
},
79-
"HideConfigurationDetails": false,
80-
"HideVersionDetails": false
81-
}
36+
"Settings": {
37+
"ApiKey": "<your API key here>",
38+
"ApiSecret": "<your API secret here>",
39+
"Edition": "Default",
40+
"ExcludedEntityTypes": [],
41+
"RelationTypes" : [],
42+
"ValueConnectors": [],
43+
"SessionTimeout": "0.0:20:00",
44+
"SourceDeployTimeout": "0.0:20:00",
45+
"DatabaseCommandTimeout": "0.0:20:00",
46+
"EnableSignatureCacheReads": true,
47+
"HttpClientTimeout": "0.0:20:00",
48+
"DiskOperationsTimeout": "0.0:05:00",
49+
"SourceDeployBatchSize": null,
50+
"PackageBatchSize": null,
51+
"UseDatabaseBackedTransferQueue": true,
52+
"IgnoreBrokenDependenciesBehavior": "Restore",
53+
"AcceptInvalidCertificates": false,
54+
"TransferFormsAsContent": true,
55+
"TransferDictionaryAsContent": false,
56+
"IgnoreMissingLanguagesForDictionaryItems": false,
57+
"SetEmptyDictionaryItemsOnTransfer": true,
58+
"AllowMembersDeploymentOperations": "None",
59+
"TransferMemberGroupsAsContent": false,
60+
"ExportMemberGroups": true,
61+
"ReloadMemoryCacheFollowingDiskReadOperation": false,
62+
"AllowDomainsDeploymentOperations": "None",
63+
"AllowWebhooksDeploymentOperations": "None",
64+
"TrashedContentDeploymentOperations": "Import",
65+
"PreferLocalDbConnectionString": false,
66+
"MediaFileChecksumCalculationMethod": "PartialFileContents",
67+
"NumberOfSignaturesToUseAllRelationCache": 100,
68+
"ContinueOnMediaFilePathTooLongException": false,
69+
"SuppressCacheRefresherNotifications": false,
70+
"ResolveUserInTargetEnvironment": false,
71+
"Suspensions": {
72+
"DiskRead": "All",
73+
"PartialRestore": "All",
74+
"Restore": "All",
75+
"Deploy": "All",
76+
"Import": "All",
77+
"Export": "All"
78+
},
79+
"HideConfigurationDetails": false,
80+
"HideVersionDetails": false
81+
},
82+
"ImportOnStartup": {
83+
"Enabled": true,
84+
"Files": ["~/umbraco/Deploy/import-on-startup.zip"],
85+
"FileAction": "Delete",
86+
"WarningsAsErrors": false,
87+
"EntityTypes": [],
88+
"Cultures": [],
89+
"Username": null
90+
}
8291
}
8392
}
8493
}
8594
```
8695

8796
Some configuration is applied via code rather than application settings. Where this is the case is also discussed in the sections to follow.
8897

89-
## Configuration Via Application Settings
98+
## Configuration via application settings
9099

91100
### ApiKey or ApiSecret
92101

@@ -116,9 +125,9 @@ This setting allows you to exclude a certain type of entity from being deployed.
116125

117126
This setting allows you to manage how relations are deployed between environments. You will need to specify an alias and a mode for each relation type. The mode can be either:
118127

119-
* `Exclude` - This causes the relation to be excluded and not transferred on deployments.
120-
* `Weak` - This causes the relation to be deployed if both content items are found on the target environment.
121-
* `Strong` - This requires the content item that is related is set as a dependency, so if anything is added as a relation it would also add it as a dependency.
128+
* `Exclude` - This causes the relation to be excluded and not transferred on deployments
129+
* `Weak` - This causes the relation to be deployed if both content items are found on the target environment
130+
* `Strong` - This requires the content item that is related is set as a dependency, so if anything is added as a relation it would also add it as a dependency
122131

123132
```json
124133
"RelationTypes": {
@@ -176,8 +185,8 @@ An error message of "The remote API has returned a response indicating a platfor
176185

177186
If encountering this issue, there are two batch settings that can be applied with integer values (for example 500). This will cause Deploy to transfer items in batches, up to a maximum size. This will allow each individual batch to complete within the time available. The higher the value, the bigger the batches.
178187

179-
* `SourceDeployBatchSize` - applies a batch setting for the transfer of multiple selected items to an upstream environment (such as a media folder with many images).
180-
* `PackageBatchSize` - applies a batch setting to the processing of a Deploy "package", which contains all the items selected for a Deploy operation, plus all the determined dependencies and relations.
188+
* `SourceDeployBatchSize` - applies a batch setting for the transfer of multiple selected items to an upstream environment (such as a media folder with many images)
189+
* `PackageBatchSize` - applies a batch setting to the processing of a Deploy "package", which contains all the items selected for a Deploy operation, plus all the determined dependencies and relations
181190

182191
### UseDatabaseBackedTransferQueue
183192

@@ -257,22 +266,22 @@ To configure the behavior you prefer, amend this value to either `None`, `Transf
257266
For example, using the following settings, you will have an installation that ignores broken dependencies when restoring from an upstream environment. It will however still prevent deployment and report any dependency issues when attempting a transfer to an upstream environment.
258267

259268
```json
260-
"IgnoreBrokenDependenciesBehavior": "Restore",
269+
"IgnoreBrokenDependenciesBehavior": "Restore",
261270
```
262271

263272
When configuring for Deploy 9, an additional `IgnoreBrokenDependencies` setting existed that took a value of `true` or `false`. To achieve the same result as the example above, the following configuration was required:
264273

265274
```json
266-
"IgnoreBrokenDependencies": true,
267-
"IgnoreBrokenDependenciesBehavior": "Restore",
275+
"IgnoreBrokenDependencies": true,
276+
"IgnoreBrokenDependenciesBehavior": "Restore",
268277
```
269278

270279
### Memory cache reload
271280

272281
Some customers have reported intermittent issues related to Umbraco's memory cache following deployments, which are resolved by a manual reload of the cache via the _Settings > Published Status > Caches_ dashboard. If you are running into such issues and are able to accommodate a cache clear after deployment, this workaround can be automated via the following setting:
273282

274283
```json
275-
"ReloadMemoryCacheFollowingDiskReadOperation": true,
284+
"ReloadMemoryCacheFollowingDiskReadOperation": true,
276285
```
277286

278287
By upgrading to the most recent available version of the CMS major you are running, you'll be able to benefit from the latest bug fixes and optimizations in this area. That should be your first option if encountering cache related issues. Failing that, or if a CMS upgrade is not an option, then this workaround can be considered.
@@ -282,7 +291,7 @@ By upgrading to the most recent available version of the CMS major you are runni
282291
Culture and hostname settings, defined per content item for culture invariant content, are not deployed between environments by default. They can be opted into via configuration.
283292

284293
```json
285-
"AllowDomainsDeploymentOperations": "None|Culture|AbsolutePath|Hostname|All",
294+
"AllowDomainsDeploymentOperations": "None|Culture|AbsolutePath|Hostname|All",
286295
```
287296

288297
To enable this, set the configuration value as appropriate for the types of domains you want to allow:
@@ -298,7 +307,7 @@ Combinations of settings can be applied, e.g. `Hostname,AbsolutePath`.
298307
When deploying content items, public access rules based on member groups are transferred. You can amend this behavior using this setting.
299308

300309
```json
301-
"AllowPublicAccessDeploymentOperations": "None|AddOrUpdate|Remove|All",
310+
"AllowPublicAccessDeploymentOperations": "None|AddOrUpdate|Remove|All",
302311
```
303312

304313
* `None` - no public access rules will be transferred
@@ -313,13 +322,13 @@ When deploying content items, public access rules based on member groups are tra
313322
Webhooks may be considered environment specific or schema information that you would like to synchronize between environments. As such, by default, Umbraco Deploy does not include webhooks in schema deployment operations.
314323

315324
```json
316-
"AllowWebhooksDeploymentOperations": "None|All",
325+
"AllowWebhooksDeploymentOperations": "None|All",
317326
```
318327

319328
If you would like you include them you can adjust this setting:
320329

321-
* `None` - webhooks are not deployed and are expected to be managed independently in each environment.
322-
* `All` - webhooks included in schema deployments.
330+
* `None` - webhooks are not deployed and are expected to be managed independently in each environment
331+
* `All` - webhooks included in schema deployments
323332

324333
## Deployment of trashed content
325334

@@ -394,27 +403,27 @@ Deploy operations suspend scheduled publishing, Examine indexing, document cache
394403

395404
Each setting within this section represents a Deploy operation. For each, the suspensions that are carried out can be amended with one or more of following values:
396405

397-
- `DiskRead` - `None, ScheduledPublishing, Examine, DocumentCache, All`,
398-
- `PartialRestore` - `None, ScheduledPublishing, Examine, DocumentCache, All`,
399-
- `Restore` - `None, ScheduledPublishing, Examine, DocumentCache, Signatures, All`,
400-
- `Deploy` - `None, ScheduledPublishing, All`,
401-
- `Import` - `None, ScheduledPublishing, Examine, DocumentCache, All`,
402-
- `Export` - `None, ScheduledPublishing, All`
406+
* `DiskRead` - `None, ScheduledPublishing, Examine, DocumentCache, All`
407+
* `PartialRestore` - `None, ScheduledPublishing, Examine, DocumentCache, All`
408+
* `Restore` - `None, ScheduledPublishing, Examine, DocumentCache, Signatures, All`
409+
* `Deploy` - `None, ScheduledPublishing, All`
410+
* `Import` - `None, ScheduledPublishing, Examine, DocumentCache, All`
411+
* `Export` - `None, ScheduledPublishing, All`
403412

404413
The default value for all suspension settings is `All`.
405414

406415
So for example if you wanted to remove Examine indexing suspension and resumption during partial restore operations, you could set the following:
407416

408417
```json
409-
"Suspensions": {
410-
"PartialRestore": "ScheduledPublishing, DocumentCache"
411-
}
418+
"Suspensions": {
419+
"PartialRestore": "ScheduledPublishing, DocumentCache"
420+
},
412421
```
413422

414423
It's also possible to set the values for all operations by setting `Suspensions` to a value instead of an object, for example:
415424

416425
```json
417-
"Suspensions": "ScheduledPublishing, DocumentCache, Signatures"
426+
"Suspensions": "ScheduledPublishing, DocumentCache, Signatures",
418427
```
419428

420429
If you prefer configuration in code, operators overloads on the settings class make this process straightforward, as shown in the following example:
@@ -423,7 +432,7 @@ If you prefer configuration in code, operators overloads on the settings class m
423432
using Umbraco.Cms.Core.Composing;
424433
using Umbraco.Deploy.Core.Configuration.DeployConfiguration;
425434

426-
internal class DeploySuspensionComposer : IComposer
435+
internal sealed class DeploySuspensionsComposer : IComposer
427436
{
428437
public void Compose(IUmbracoBuilder builder)
429438
=> builder.Services.Configure<DeploySettings>(options =>
@@ -448,7 +457,76 @@ If set to `true` the configuration details shown on the setting's dashboard will
448457

449458
If set to `true` the version details shown on the setting's dashboard will be hidden.
450459

451-
## Configuration Via Code
460+
### Import on startup
461+
462+
Deploy can import content and/or schema previously exported from another Umbraco installation on start-up. This can be used to quickly setup a baseline/starter kit or as a workaround for large ZIP archives that can't be (easily) uploaded via the backoffice.
463+
464+
The default configuration will look for the ZIP archive `umbraco\Deploy\import-on-startup.zip` on start-up and if it exists, run an import and delete the file on successful completion. This can be customized by changing the `Umbraco:Deploy:ImportOnStartup` settings (note that this is directly below the `Deploy` section and not nested below `Settings`):
465+
466+
* `Enabled` - this feature is enabled by default, but can be disabled (e.g. to prevent importing on specific environments)
467+
* `Files` - the files that are imported on start-up (relative to the project content root, defaults to `umbraco\Deploy\import-on-startup.zip`), which are checked individually (files that do not exist are skipped and a warning will be logged)
468+
* `FileAction` - `None` will leave the file on disk (and potentially import it again on the next start-up), `Archive` renames the file to end with `.imported` and `Delete` (the default) will remove the file on successful import
469+
* `WarningsAsErrors` - indicates whether warnings should be considered as errors
470+
* `EntityTypes` - sets the entity types to import, note that the default import validation will return warnings for entity types in the ZIP archive that are skipped due to this setting
471+
* `Cultures` - the ISO codes of content variants that should be imported
472+
* `Username` - the email address of the user that performs the import (used for auditing), uses the 'super-user' administrator account if not set
473+
474+
This feature is extensible via a provider based model by implementing `IArtifactImportOnStartupProvider` and registering it using `builder.DeployArtifactImportOnStartupProviders()`. The default `Umbraco.Deploy.Infrastructure.SettingsArtifactImportOnStartupProvider` implementation uses the above settings and inherits from `Umbraco.Deploy.Infrastructure.ArtifactImportOnStartupProviderZipArchiveBase` (which can be used for your own custom implementation).
475+
476+
An example of an import on start-up provider that imports from a physical directory (instead of ZIP archive) is shown below:
477+
478+
```csharp
479+
using Umbraco.Cms.Core;
480+
using Umbraco.Cms.Core.Composing;
481+
using Umbraco.Cms.Core.Extensions;
482+
using Umbraco.Deploy.Core;
483+
using Umbraco.Deploy.Core.OperationStatus;
484+
using Umbraco.Deploy.Infrastructure.Extensions;
485+
486+
internal sealed class DeployImportOnStartupComposer : IComposer
487+
{
488+
public void Compose(IUmbracoBuilder builder)
489+
=> builder.DeployArtifactImportOnStartupProviders()
490+
.Append<PhysicalDirectoryArtifactImportOnStartupProvider>();
491+
492+
private sealed class PhysicalDirectoryArtifactImportOnStartupProvider : IArtifactImportOnStartupProvider
493+
{
494+
private readonly IArtifactImportExportService _artifactImportExportService;
495+
private readonly ILogger _logger;
496+
private readonly string _artifactsPath;
497+
498+
public PhysicalDirectoryArtifactImportOnStartupProvider(IArtifactImportExportService artifactImportExportService, ILogger<PhysicalDirectoryArtifactImportOnStartupProvider> logger, IHostEnvironment hostEnvironment)
499+
{
500+
_artifactImportExportService = artifactImportExportService;
501+
_logger = logger;
502+
_artifactsPath = hostEnvironment.MapPathContentRoot("~/umbraco/Deploy/ImportOnStartup");
503+
}
504+
505+
public Task<bool> CanImportAsync(CancellationToken cancellationToken = default)
506+
=> Task.FromResult(Directory.Exists(_artifactsPath));
507+
508+
public async Task<Attempt<ImportArtifactsOperationStatus>> ImportAsync(CancellationToken cancellationToken = default)
509+
{
510+
_logger.LogInformation("Importing Umbraco content and/or schema import at startup from directory {FilePath}.", _artifactsPath);
511+
512+
Attempt<ImportArtifactsOperationStatus> attempt = await _artifactImportExportService.ImportArtifactsAsync(_artifactsPath, default, null, cancellationToken);
513+
514+
_logger.LogInformation("Imported Umbraco content and/or schema import at startup from directory {FilePath} with status: {OperationStatus}.", _artifactsPath, attempt.Result);
515+
516+
return attempt;
517+
}
518+
519+
public Task OnImportCompletedAsync()
520+
{
521+
Directory.Delete(_artifactsPath, true);
522+
523+
return Task.CompletedTask;
524+
}
525+
}
526+
}
527+
```
528+
529+
## Configuration via code
452530

453531
### Webhook Events
454532

@@ -458,7 +536,7 @@ Umbraco Deploy can optionally register events that you can use with Umbraco webh
458536
using Umbraco.Cms.Core.Composing;
459537
using Umbraco.Deploy.Infrastructure.Extensions;
460538

461-
public class RegisterDeployWebhooksComposer : IComposer
539+
internal sealed class DeployWebhookEventsComposer : IComposer
462540
{
463541
public void Compose(IUmbracoBuilder builder)
464542
=> builder.WebhookEvents().AddDeploy(deployBuilder => deployBuilder.AddTask());

0 commit comments

Comments
 (0)