Global Navigation

  • Products
  • Overview
  • Getting Started
  • Guides
  • Resources
  • Console

Table of Contents

  • Introduction
    • App Builder Overview
    • What is App Builder
    • Business Case
    • FAQ
    • Community
  • Quick Start
    • App Builder Getting Started
      • Setting Up
      • Creating your First App
      • Publishing Your App
      • Troubleshooting
    • Runtime Getting Started
      • Overview
      • Activations
      • Deploy
      • Entities
      • How Runtime Works
      • Resources
      • Setup
      • Understanding Runtime
  • Develop
    • References
    • App Builder Guides
      • Architecture Overview
        • App Hooks
        • Introduction to React Spectrum
        • Using SDKs
      • Application State
      • Application Logging
        • Azure Log Analytics
        • New Relic
        • Splunk Cloud
        • Splunk Enterprise
      • Configuration
        • Webpack Configuration
      • Deployment
        • CI/CD for App Builder Apps
        • Credential Rotation
        • Setting Response Headers
      • Development
      • Distribution
      • Events
        • Webhooks
      • Exc App
        • Interfaces
          • Modules
          • Page ObjectWithHref
          • Page ObjectWithPath
          • Page PageAPI
          • Page PageAPIProperties
          • Runtime
          • TopBar Callback
          • TopBar CustomFeedbackConfig
          • TopBar CustomSearchConfig
          • TopBar ExternalFeedbackConfig
          • TopBar HelpCenterFeedbackConfig
          • TopBar Solution
          • TopBar TopBarAPI
          • TopBar TopBarAPIProperties
          • User UserAPI
          • User UserInfo
        • Migrate App to Exp Cloud SPA
        • Modules
          • Page
          • TopBar
          • User
      • Extensions
        • Extension Migration Guide
      • Optimization
      • Security
        • Understanding Authentication
      • Telemetry
    • Runtime Guides
      • Contribution Guide
      • Asynchronous Calls
      • Creating Actions
      • Creating REST APIs
      • CI/CD Pipeline
      • Debugging
      • Logging & Monitoring
      • Reference Docs
        • API Reference
        • CLI Usage
        • Configuring Proxy
        • Environment Variables
        • Feeds
        • Multiple Regions
        • Packages
        • Prepackages
        • Runtimes
        • Sequences & Compositions
        • Triggers & Rules
        • WSK Usage
      • Security General
      • Securing Web Actions
      • System Settings
      • Throughput Tuning
      • Tools
        • CLI Install
      • Troubleshooting
      • Using Packages
      • Using Runtime
    • Contribution Guide
  • Learning
    • Asset Compute Worker PS API
      • Requirements
      • Lesson 1: Create an app from Asset Compute template
      • Lesson 2: Configure the app
      • Lesson 3: Develop worker calling Photoshop API
      • Lesson 4: Integrate worker in AEMaaCS
      • Well done
    • Barcode Reader
      • Requirements
      • Lesson 1: Bootstrap a Headless App
      • Lesson 2: Writing a Serverless Action
      • Lesson 3: Unit and E2E Tests
      • Well done
    • Blog Articles
      • Blog Articles
    • CI/CD
      • Requirements
      • Lesson 1: Setup CI/CD
      • Lesson 2: Monitoring CI/CD
      • Lesson 3: Custom CI/CD workflow
      • Well done
    • Cron Jobs
      • Requirements
      • Lesson 1: Bootstrap a Headless App
      • Lesson 2: Set up Alarm Feed with Trigger and Rule
      • Lesson 3: Types of Alarm Feed
      • Well done
    • Custom Asset Compute Worker
      • Requirements
      • How AEM as Cloud assets works
      • Architecture of our worker
      • Configure services
      • Local environment setup
      • Implement the worker
      • Test the worker
      • Setup AEM to use the worker
      • Well Done
    • Customer Dashboard
      • Requirements
      • Lesson 1: Create a New App Builder App from Campaign Standard Template
      • Lesson 2: Explore the App Builder App
      • Lesson 3: Run the App Builder App Locally
      • Lesson 4: List All Customer Profiles on the UI
      • Lesson 5: Add Personalized Promotion Emails Triggering
      • Well Done
    • Debugging
      • Requirements
      • Lesson 1: Getting familiar with Debugger
      • Lesson 2: Debugging Application Code
      • Lesson 3: Managing Application Logs
      • Well Done
    • Event Driven
      • Requirements
      • Lesson 1: Create a New App Builder App from Template
      • Lesson 2: Register the App as Event Provider
      • Lesson 3: Fire an Event
      • Lesson 4: Consume Events
      • Well Done
    • Events Runtime
      • Requirements
      • Lesson 1: Step by Step Guide
      • Lesson 2: Verify the result
      • Well done
    • Journaling Events
      • Requirements
      • Lesson 1: Create an Event Provider using App Builder
      • Lesson 2: Create the Event Consumer using Journaling API
      • Lesson 3: End to end test
      • Well done
    • Sample Apps
      • Code Snippets
        • Caching HTTP responses
        • App Builder Files SDK
        • App Builder State SDK
        • I/O Events handler
        • Real-time data from Adobe Analytics API 1.4
    • Spectrum Introduction
      • Lesson 1: What is Spectrum ?
      • Lesson 2: Using Spectrum CSS
      • Lesson 3: Using React Spectrum
      • Lesson 4: Using React Spectrum in App Builder
      • Well done
    • Todo App
      • Requirements
      • Lesson 1: Create a New App Builder App with the React Spectrum template
      • Lesson 2: Setup Runtime actions
      • Lesson 3: Setup the CreateTodoList component
      • Lesson 4: Setup the Todo component
      • Lesson 5: Setup the TodoList component
      • Lesson 6: Bringing the pieces together to build the App
      • Well done
    • Videos
      • Overview
        • Introducing App Builder
        • Getting Started
        • Architecture
        • A Full Security Overview
        • User Journey
      • Exploring
        • Projects and Workspaces
        • React Spectrum
        • Custom Events
        • CI/CD
        • Debugging
        • Learning Resources
        • Dashboard Case Study
        • ODE Case Study
        • Deep Dive Use Cases
        • Live Wired Sneak
        • Softcrylic Partner Showcase
      • Developers Live
        • App Builder Deep Dive
        • Asset Compute Service Extensibility
        • Extend Adobe Experience Cloud

Lesson 3: Implement the Worker

Create a new application using the AIO CLI:

$> aio app init my-custom-worker

In answer to the questions application initialization will ask you:

  1. Select your Adobe Organization, the console project selection you created in previous steps, and a project workspace where you added the required services.
  2. Pick the components of the app: select only Actions: Deploy Runtime action.
  3. On the type of action, choose only Adobe Asset Compute worker.
  4. Provide the name of the worker, and wait for the npm to finish installing all the dependencies.

Once it's done, edit the .env file and add the environment variables the AIO CLI uses. In a production deployment, you can set them directly on your CI/CD pipelines as environment variables:

## A path to the private.key you obtained from Adobe Console ASSET_COMPUTE_PRIVATE_KEY_FILE_PATH=/path/to/the/private.key ## Azure blob storage container you created to simulate AEM binaries cloud storage AZURE_STORAGE_ACCOUNT=your-storage-account AZURE_STORAGE_KEY=your-storage-key AZURE_STORAGE_CONTAINER_NAME=source # Azure blob storage container used by the imgIX as assets source IMGIX_STORAGE_ACCOUNT=your-storage-account IMGIX_STORAGE_KEY=your-storage-key IMGIX_STORAGE_CONTAINER_NAME=imgix # A security token you obtained when setting up imgIX source IMGIX_SECURE_TOKEN=imgx-token # A imgix domain you defined when setting up imgIX source IMGIX_DOMAIN=your-subdomain.imgix.net

Edit the ext.config.yaml file inside the src/dx-asset-compute-worker-1/ folder and add the inputs object as shown below. This file describes the I/O Runtime action to be deployed. An input parameter sets the default parameters with values referenced to our environment variables. Those parameters are available in action JS as param object.

operations: workerProcess: - type: action impl: dx-asset-compute-worker-1/worker hooks: post-app-run: adobe-asset-compute devtool test: adobe-asset-compute test-worker actions: actions runtimeManifest: packages: dx-asset-compute-worker-1: license: Apache-2.0 actions: czeczek-worker: function: actions/worker/index.js web: 'yes' runtime: 'nodejs:14' limits: concurrency: 10 inputs: imgixStorageAccount: $IMGIX_STORAGE_ACCOUNT imgixStorageKey: $IMGIX_STORAGE_KEY imgixStorageContainerName: $IMGIX_STORAGE_CONTAINER_NAME imgixSecureToken: $IMGIX_SECURE_TOKEN imgixDomain: $IMGIX_DOMAIN annotations: require-adobe-auth: true final: true

We will also need to add two dependencies to our project. These are the libraries we will use to simplify access to the Azure blob storage and to generate signed URL for imgIX.

$> npm install @adobe/aio-lib-files imgix-core-js

Finally, edit the worker source code located under src/dx-asset-compute-worker-1/actions/<worker-name>/index.js, and replace it with:

'use strict'; const { worker } = require('@adobe/asset-compute-sdk'); //Convinient library provided by adobe that abstract away managing files on cloud storages const filesLib = require('@adobe/aio-lib-files'); const { downloadFile } = require('@adobe/httptransfer'); const ImgixClient = require('imgix-core-js'); exports.main = worker(async (source, rendition, params) => { //Initialize blob storage client used by imgix //We're reading the parameters we defined in manifest.yml const targetStorage = await filesLib.init({ azure: { storageAccount: params.imgixStorageAccount, storageAccessKey: params.imgixStorageKey, containerName: params.imgixStorageContainerName, }, }); //Copy source asset from the AEM binaries storage to the Azure blob storage for imgIX // localSrc:true means, the first parameters points to the file in the local file system (asset-compute-sdk abstracts the source blob storage so it's visible as local file) // Second arguments defines the path on the target blob storage. We use the same path just to simplify things await targetStorage.copy(source.path, source.path, { localSrc: true }); //Initialize imgix client responsible for generation of signed URLs //to our assets accessed via imgIX subdomain //We're getting the config params we defined in manifest.yml const client = new ImgixClient({ domain: params.imgixDomain, secureURLToken: params.imgixSecureToken, }); //Generate signed URL with the params send by AEM and sign it. //All the parameters send by AEM are available under rendition.instructions object const url = client.buildURL(source.path, JSON.parse(rendition.instructions.imgix)); //Finally, download a rendition from a given url and store in AEM azure blob storage so it will be visible in AEM as a rendition await downloadFile(url, rendition.path); });