Customize the behaviour of generated resource

In an ideal world, the code generated resource will work out of the box with no changes. However, in practice, this is not always the case.

There are some variations in the way different product groups implement their resources.

To support these variations, ASO has extension points for resources that allow the behaviour to be modified.

For example, some resource providers will return a BadRequest error when a prerequisite is not met. Normally, ASO will treat BadRequest as a permanent failure, but this can be reclassified as a warning by using the ErrorClassifier extension point.

Other extension points allow blocking reconciliation attempts until a prerequisite is met, additional API calls after a successful reconciliation, or even modifying the resource before it is sent to Azure.

For most resource extensions, any implementation will go in the customizations folder generated for each resource group.

It’s often unclear which extensions are needed until you start testing the resource. The best approach is to start with the generated resource, and then add extensions as needed. Reach out to us if you want some guidance on which (if any) extension points are appropriate for your resource.

Available extension points

Extension pont Purpose Example
ARMResourceModifier Provides a hook allowing resources to modify the payload that will be sent to ARM just before it is sent. Used by KeyVault Vaults to allow specifying create modes like createOrRecover.
Claimer Customize how the reconciler claims a resource
Deleter Customize how the reconciler deletes a resource
ErrorClassifier Customize how the reconciler reacts to specific errors returned by Azure Used by DocumentDB SqlRoleAssignment to retry assignments that fail because the referenced identity is not yet available.
Importer An optional interface that can be implemented by resource extensions to customize the import process in asoctl
KubernetesSecretExporter Implemented when a resource needs to export a Kubernetes secret Used by EventHub NamespacesEventhubsAuthorizationRule to publish requested secrets to the cluster.
PostReconciliationChecker Implemented when a resource needs to perform additional checks after reconciliation against Azure
PreReconciliationChecker implemented by resources that want to do extra checks before proceeding with a full ARM reconcile.
SuccessfulCreationHandler Implemented by resources that need to perform additional actions after a successful creation

Whether or not you’ve implemented any extensions, our next step is to verify that the resource works as expected by writing a test.