function-azresourcegraph

command module
v0.6.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Feb 6, 2025 License: Apache-2.0 Imports: 17 Imported by: 0

README

function-azresourcegraph

CI

A function to query Azure Resource Graph

Usage

See the examples for a variety of practical and testable use cases demonstrating this Function.

Example pipeline step:

  pipeline:
  - step: query-azresourcegraph
    functionRef:
      name: function-azresourcegraph
    input:
      apiVersion: azresourcegraph.fn.crossplane.io/v1alpha1
      kind: Input
      query: "Resources | project name, location, type, id| where type =~ 'Microsoft.Compute/virtualMachines' | order by name desc"
      target: "status.azResourceGraphQueryResult"
    credentials:
      - name: azure-creds
        source: Secret
        secretRef:
          namespace: upbound-system
          name: azure-account-creds

The Azure Credentials Secret structure is fully compatible with the standard Azure Official Provider

Example XR status after e2e query:

apiVersion: example.crossplane.io/v1
kind: XR
metadata:
...
status:
  azResourceGraphQueryResult:
  - id: /subscriptions/f403a412-959c-4214-8c4d-ad5598f149cc/resourceGroups/us-vm-zxqnj-s2jdb/providers/Microsoft.Compute/virtualMachines/us-vm-zxqnj-2h59v
    location: centralus
    name: us-vm-zxqnj-2h59v
    type: microsoft.compute/virtualmachines
  - id: /subscriptions/f403a412-959c-4214-8c4d-ad5598f149cc/resourceGroups/us-vm-lzbpt-tdv2h/providers/Microsoft.Compute/virtualMachines/us-vm-lzbpt-fgcds
    location: centralus
    name: us-vm-lzbpt-fgcds
    type: microsoft.compute/virtualmachines
QueryRef

Rather than specifying a direct query string as shown in the example above, the function allows referencing a query from any arbitrary field within the Context or Status.

Context Query Reference
  • Simple context field reference
      queryRef: "context.azResourceGraphQuery"
  • Get data from Environment
      queryRef: "context.[apiextensions.crossplane.io/environment].azResourceGraphQuery"
XR Status Query Reference
  • Simple XR Status field reference
      queryRef: "status.azResourceGraphQuery"
  • Get data from nested field in XR status. Use brackets if key contains dots.
      queryRef: "status.[fancy.key.with.dots].azResourceGraphQuery"
Targets

Function supports publishing Query Results to different locations.

Context Target
  • Simple Context field target
      target: "context.azResourceGraphQueryResult"
  • Put results into Environment key
      target: "context.[apiextensions.crossplane.io/environment].azResourceGraphQuery"
XR Status Target
  • Simple XR status field target
      target: "status.azResourceGraphQueryResult"
  • Put query results to nested field under XR status. Use brackets if key contains dots
      target: "status.[fancy.key.with.dots].azResourceGraphQueryResult"

Documentation

Overview

Package main implements a Composition Function.

Directories

Path Synopsis
input
v1beta1
Package v1beta1 contains the input type for this Function +kubebuilder:object:generate=true +groupName=azresourcegraph.fn.crossplane.io +versionName=v1alpha1
Package v1beta1 contains the input type for this Function +kubebuilder:object:generate=true +groupName=azresourcegraph.fn.crossplane.io +versionName=v1alpha1

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL
JackTT - Gopher 🇻🇳