ProvisioningComponent class

Base class for all tree nodes in the library object model.

Example

import { ProvisioningComponent } from "@azure/provisioning-core";
import { KeyVault, Secret } from "@azure/provisioning-keyvault";

class DataTier extends ProvisioningComponent {
  readonly vault: KeyVault;
  readonly secret: Secret;

  constructor(parent: ProvisioningComponent, tenantId: string, secretValue: string) {
    super(parent);
    this.vault = new KeyVault(this, {
      name: "kv-my-app",
      location: "eastus",
      properties: { tenantId, sku: { family: "A", name: "standard" } },
    });
    this.secret = new Secret(this.vault, {
      name: "database-password",
      properties: { value: secretValue },
    });
  }
}

Remarks

Both Stack and Resource extend ProvisioningComponent. It provides parent-child tree tracking and deployment context lookup — walking up the tree to find the nearest context set by a Stack or ResourceGroup.

Subclass ProvisioningComponent directly to create reusable groupings of resources that don't correspond to an ARM resource. For ARM resources, extend Resource instead.

Properties

children
deploymentContext

The effective deployment context inherited from ancestors, resolved by walking up the parent chain (this node's own local contribution is intentionally excluded — a node's contribution flows to its descendants, not to itself). Each field is resolved per its own rule:

  • location: nearest ancestor with a value wins.
  • namingPolicy: nearest ancestor with a value wins.
  • tags: flat-merged across all ancestors; innermost wins on key conflict.

Returns an object whose fields may all be undefined if no ancestor contributed anything.

parent
self

Public identity for this node.

Methods

isChildOf(ProvisioningComponent)
transform((component: ProvisioningComponent) => void)

Applies a callback to every descendant component/resource that matches the given constructor, including this when it matches.

transform<TComponent>(ProvisioningComponentConstructor<TComponent>, (component: TComponent) => void)
visit((component: ProvisioningComponent) => boolean | void)

Depth-first visit of this node and all descendants. Return false from the callback to skip visiting that node's children.

Constructor Details

ProvisioningComponent(ProvisioningComponent)

new ProvisioningComponent(parent?: ProvisioningComponent)

Parameters

Property Details

children

children: ProvisioningComponent[]

Property Value

deploymentContext

The effective deployment context inherited from ancestors, resolved by walking up the parent chain (this node's own local contribution is intentionally excluded — a node's contribution flows to its descendants, not to itself). Each field is resolved per its own rule:

  • location: nearest ancestor with a value wins.
  • namingPolicy: nearest ancestor with a value wins.
  • tags: flat-merged across all ancestors; innermost wins on key conflict.

Returns an object whose fields may all be undefined if no ancestor contributed anything.

DeploymentContext deploymentContext

Property Value

parent

parent: ProvisioningComponent | undefined

Property Value

ProvisioningComponent | undefined

self

Public identity for this node.

this self

Property Value

this

Method Details

isChildOf(ProvisioningComponent)

function isChildOf(component: ProvisioningComponent): boolean

Parameters

Returns

boolean

transform((component: ProvisioningComponent) => void)

Applies a callback to every descendant component/resource that matches the given constructor, including this when it matches.

function transform(callback: (component: ProvisioningComponent) => void): this

Parameters

callback

(component: ProvisioningComponent) => void

Returns

this

transform<TComponent>(ProvisioningComponentConstructor<TComponent>, (component: TComponent) => void)

function transform<TComponent>(ctor: ProvisioningComponentConstructor<TComponent>, callback: (component: TComponent) => void): this

Parameters

callback

(component: TComponent) => void

Returns

this

visit((component: ProvisioningComponent) => boolean | void)

Depth-first visit of this node and all descendants. Return false from the callback to skip visiting that node's children.

function visit(callback: (component: ProvisioningComponent) => boolean | void)

Parameters

callback

(component: ProvisioningComponent) => boolean | void