Resolving ‘Unauthorized Purge’ errors for CDN cache purge in AEM as a Cloud Service
This article explains how to resolve the Unauthorized Purge. Please setup a PURGE key via Configuration Pipeline. error that occurs when purging CDN cache in Adobe Experience Manager as a Cloud Service. The solution involves reviewing and correcting the CDN configuration file structure and purge key setup.
Description description
Environment
Adobe Experience Manager as a Cloud Service (AEMaaCS) (any environment type)
Symptoms
-
CDN purge requests (such as via curl) fail with a response similar to:
{ "status": "error", "reason": "Unauthorized Purge. Please setup a PURGE key via Configuration Pipeline." } -
The configuration pipeline completes successfully, and purge keys are present as environment variables.
-
The issue affects one or more environments depending on configuration file structure.
Cause
The most common cause is that the CDN configuration files aren’t organized according to the recommended environment-level structure, or there are duplicate or conflicting variable definitions. As a result, the purge authenticator isn’t applied, and purge requests are rejected as unauthorized.
Resolution resolution
Follow the steps below to resolve the issue:
-
Review your CDN configuration file structure in your code repository:
-
Ensure that CDN configuration files are organized according to Adobe’s recommended environment-level structure. For example, use a flat structure with one file per environment, such as
cdn-stage.yamlfor Staging andcdn-prod.yamlfor Production, each specifying the appropriateenvTypes. -
Avoid placing CDN configuration files in subfolders that aren’t evaluated by Cloud Manager for environment-level settings.
-
Remove any duplicate or conflicting CDN configuration files that may apply to the same environment.
-
-
Check purge key secret variable assignment:
-
Verify that the purge key secrets (For example:
CDN_PURGEKEY_PRIMARY,CDN_PURGEKEY_SECONDARY, or environment-specific equivalents) are configured as environment variables before running the configuration pipeline. -
Ensure that the
Service Appliedfield for these secrets is set to All and not limited to a specific service.
-
-
Remove duplicate variable definitions:
-
Don’t configure the same variable as both a pipeline variable and an environment variable. Use only one method for each variable.
-
If environment-specific variables are required, retain only the environment variables and remove the pipeline variables (or vice versa, if not required).
-
-
Redeploy the configuration using the Cloud Manager configuration pipeline.
- Wait for the deployment to complete successfully.
-
Validate purge functionality:
-
Retry the CDN purge request using the correct purge key in the
X-AEM-Purge-Keyheader. -
Example curl command:
code language-none curl -X PURGE "https:///content/..." \ -H "X-AEM-Purge-Key: " \ -H "X-AEM-Purge: soft"- Confirm that the response is successful (For example:
{ "status": "ok" }).
-