Thursday, April 27, 2023

AEMaaCS: Migration of Assets from Non-AEM sources | Using Bulk Import tool

 OOTB Bulk import tool facilitates a sophisticated content migration experience for non-AEM assets. This tool allows even non-tech users to import assets into AEM from cloud storage. To use this tool, you need all your source assets to be uploaded to a single cloud storage server i.e. Azure Blob Storage or Amazon S3, Google cloud storage etc. The process can be divided into 5 stages to simplify entire process:

1. AEM Pre-migration tasks- Like: Define/ Create base folder hierarchy, Define/ create taxonomy, Define/ Create Metadata Schema and apply those on migration folders.

2. Source Pre-migration tasks: Reorganize DAM hierarchy, Content cleanup, Delete unused/ test assets

3.  Upload assets to a cloud storage server i.e. Azure Blob Storage or Amazon S3. Bulk import tool ingests assets in AEM in the same structure that you put in cloud storage.

4. Configure and Run the Bulk Import

5. Prepare for the metadata import (Assuming that the assets ingested in step 3 did not contain necessary metadata added) and run metadata import in AEM

In order to configure Bulk Import which is an option available on AEMaaCS cloud servers (not available in local SDK) follow below:

a. Go to Tools -> Assets -> Bulk Import -> Create

b. Fill in necessary information to your cloud storage like- bucket id, access key, secret key/ token etc.



 c. Save the settings and click on "check" to test the connection. 


With this you set be all set to run the asset ingestion into AEM. You can even schedule it to tun at specific time as per business need. While configuring the import tool, you can also, configure how to handle existing assets in same location:


Refer this link for more information on this- https://experienceleague.adobe.com/docs/experience-manager-learn/cloud-service/migration/bulk-import.html

Monday, April 10, 2023

Enable SMTP host and port in AEM Cloud Service

AEM Cloud Service blocks communication to any external host and port by default. As SMTP run on external servers, it need to be allow listed.  Sample SMTP email configuration:

{
"smtp.host": "$[env:AEM_PROXY_HOST;default=proxy.tunnel]",
"smtp.port": 30587,
"smtp.user": "$[env:EMAIL_USERNAME]",
"smtp.password": "$[secret:EMAIL_PASSWORD]",
"from.address": "xxxx@xxxx.com",
"smtp.ssl": false,
"smtp.starttls": true,
"smtp.requiretls":true
}

This article just talks about setting up host and port of SMTP configuration, rest configuration should be done using OSGi configuration file and environment variables.

SMTP User Name and Password should be stored as environment variables as shown below:

SMTP host and port is set using advance networking option which is explained in this article below. Necessary configurations are done through the Advance Networking Options to your cloud service program. Follow below steps to do that: 

Step 1- Create a new project in Adobe I/O - . Inside that add an API integration -> select type as Cloud Manager. 

Step 2- Open the integration and click on Edit Product Profiles. Select appropriate access like below:

Step 3- In left menu, click on "Service Account (JWT). On this screen generate a public private key pair. Download the certificate details.

Step 4- Using this private key, "generate access token" as shown in Step 2.

Step 5- Use this access token to configure Advance Networking Options to your cloud service program and environments.

Step 6- You can use Postman to enable these network settings. The actions are in below sequence:
a. Figure out your server's primary region. Go to Cloud Manager -> Environment Details. This is needed to create primary network. Get region id from this API - API Link.

GET https://cloudmanager.adobe.io/api/program/{program-id}/regions


e.g. region id might be "va7" for East US.

b. Next thing check if Primary Network has been created or not. 

GET https://cloudmanager.adobe.io/api/program/{program-id}/networkInfrastructures

If network infrastructure has been created, you will see response like below:


c. If you don't see primary region network infrastructure in previous step then go ahead and create a new one using this - Create network infrastructure

POST https://cloudmanager.adobe.io/api/program/{program-id}/networkInfrastructures

Your post body should follow below format:

{
"kind": "flexiblePortEgress",
"region": "va7", #Set to value found in step 6#a
"isPrimaryRegion": true
} 

d. First check if advanced networking exists or not for your particular environment using this API.

GET https://cloudmanager.adobe.io/api/program/{program-id}/environment/{environment-id}/advancedNetworking
e. If networkingConfigurations is not configured or you do not see portForwards details in previous step d, then create a networkingConfiguration using Enable Environment Advanced Networking Configuration API.

PUT https://cloudmanager.adobe.io/api/program/{program-id}/environment/{environment-id}/advancedNetworking

Your post body should be in below format. Change smtp host and port values under portForwards as per your SMTP details. Sample Format:
{
"nonProxyHosts": [
"*.my-website.com"
],
"portForwards": [
{
"name": "your-smtp-server.com",
"portDest": 587,
"portOrig": 30587
}
]
}
That's it! Now you can test email functionality in your AEM application. Also, check logs for any further
debugging.

Saturday, January 7, 2023

Asset Insights with Adobe Analytics

What is Asset Insights?

Asset Insights feature in AEM is an armour to the modern day marketers which enables them to keep an eye on asset’s effectiveness and impact on their business across the IOT. It helps to track down usage statistics of the images that are used in third-party websites, Social channels, marketing campaigns, and Adobe’s creative solutions including AEM sites.



Adobe Analytics is an integral part of this solution, so the license has to be purchased separately if customer does not have an existing account. AEM is then integrated with Adobe Analytics which captures user activity details on the assets, such as the number of times an image is rated, clicked, and impressions (number of times an image is loaded on the website). Then, based on these statistics AEM assigns scores to images. The scores and performance statistics are used to select popular images for inclusion in catalogs, marketing campaigns, and so on. We can even formulate archival and license renewal policies based on these statistics.

Architecture

The following diagram illustrates the solution design using Adobe Launch:



Implementation

3 products i.e. Analytics, Launch and AEM has to configured along with installation of core components. Skip the piece which is already present in the existing implementation.

Analytics

Launch

  1. Login to Launch : https://activation.adobe.com
  2. Create new web property
  3. Enable Adobe Analytics extension and attach the report suite created
  4. Go to Rules – Create New Rule
        Events – Library Loaded
        Actions- Custom Code – HTML 
        <script type="text/javascript" src="http://localhost:4503/etc.clientlibs/dam/clientlibs/assetinsights/pagetracker.js"></script>
  5. Add one more rule:
       Events- Dom Ready
       Actions- Custom Code – Java script
       Add tracker javascript-  dom-ready-tracker.js
       Add one more action - image-click.js
  6. Publish all changes
  7. Integrate Launch with AEM- https://console.adobe.io/home
  8. Create Integration -> Access an API -> Experience Platform Launch API
  9. Follow article here for all steps- https://docs.adobe.com/content/help/en/experience-manager-learn/assets/analytics/asset-insights-launch-tutorial-setup.html

AEM

  1. Go to Tools -> Assets -> Insights Configuration

    Username/ Shared secret is found at Analytics > Admin > Company Settings > Web Services
  2. Check Embed options
  3. Go to Tools -> Cloud Services -> Legacy -> Analytics -> performance
  4. If Asset Id not created- Use JMX Mbean to fix it: http://localhost:4502/system/console/jmx/com.day.cq.dam%3Atype%3DAssociate+Asset+IDs
  5. Launch (or DTM) Integration: Tools -> Cloud Services -> Adobe Launch Configurations

      Validate Header and Footer code that of Embed from Launch - it should be same.

  6. Go to /content/we-retail.html -> page properties and setup cloud services to use Launch
  7. Install latest Core components- https://github.com/adobe/aem-core-wcm-components/releases 
  8. Install sample image component supporting insights tracking:
    https://docs.adobe.com/content/help/en/experience-manager-learn/assets/analytics/assets/aem-assets-insights-sample.zip 
  9. Use sample component on an AEM page to enable asset tracking.
Once the 3 products are configured, AEM sites will start sending analytics data to Adobe Analytics and "Get Embed Code" button enabled in Assets admin UI.

Data from Adobe Analytics server is synced with AEM by default. If we want to change the schedule, it can be done from this OSGi configuration:

Wednesday, July 20, 2022

Jenkins/ Git/ CVS : Syncing / Pushing a branch from one repo to another repo

 If you want to sync or push a branch from one repo to another on certain git events like merge or push, Jenkin provides a "Git Publisher" step which you can utilize to sync or push your branch code to another repo. Steps are given below:


1. Create a new job in Jenkins

2. Configure "Source Code Management". Configure 2 repos : one for source repo and other for target repo. In my case- Source repo name is - "adobe-git" and Target repo name is - "ams-git"

For each repo define 3 things:

a. Repository URL- Depending on credentials type, you have two options: either enter ssh URL or https URL. For simplicity - I recommend using https URL format of your repo like this- https://myrepo.github.com/myorg/myreponame/

b. Credentials: Select the Add option provided to save repo credentials so that Jenkin can authenticate the repo to perform sync operation. Here you will see multiple option. For simplicity - I recommend using "Username with Password" option. If 2 factor auth is enabled for your git account- Create a Personal Access Token in git account and use that as a password. In password field use your Personal Access Token.

c. Git your each repo a custom name e.g. adobe-git. You can use this name in rest of configuration to point your specific repo.





3. Optionally, you can also setup branches to build if you want to push happen only when source branch build is successful to avoid any breaking build to have been pushed to target repo. In this option set the value in this format: {source repo name}/{source branch name}


4.  Configure "Build Triggers". If you want Jenkin to automatically poll to source repo and push any new commits to target repo, you can configure "Poll SCM" with some schedular cron e.g. H/10 * * * *

This cron expression means job will automatically run every 10 mins. If there is any change (if new PRs were merged in the source branch) in source repo, it will push to target repo.



5. Configure "Build Environment". Enable "Delete workspace before build starts" option.

6. Optionally, Configure "Build". 



7. Configure "Post Steps". Enable "Run only if build succeeds".

8. Configure "Post-build Actions". Add a "Git Publisher" step and configure it to point to target repo and target branch.

In case the target branch does not exist configure the "Branch to push" in this format- "refs/heads/develop".

That's all. Save the Job and test it.


Friday, July 8, 2022

Sonarqube on Docker with AEM plugin

 1. Install docker

2. Install Sonarqube Image with this command- 

    docker pull sonarqube

     https://hub.docker.com/_/sonarqube

3. Once docker image is ready, Run it with following settings:


Make sure to enter Ports value like: 9000

4. Once server is up and running, Open the Sonar server in your browser

http://localhost:9000

5. Go to administration -> Marketplace and enable AEM Rules


6. Run the sonar build on project

mvn sonar:sonar -Dsonar.login=admin -Dsonar.password=admin

CDN | Clearing Cloudflare cache

In order to clear Cloudflare cache automatically via code, follow below steps: 1. Develop Custom TransportHandler Develop a custom Trans...