Skip to main content

Cloud Custodian - Azure Support

Project description

Cloud Custodian - Azure Support

This a plugin to Cloud Custodian that adds Azure support.

Install Cloud Custodian and Azure Plugin

The Azure provider must be installed as a separate package in addition to c7n.

$ git clone https://github.com/cloud-custodian/cloud-custodian.git
$ virtualenv custodian
$ source custodian/bin/activate
(custodian) $ pip install -e cloud-custodian/.
(custodian) $ pip install -e cloud-custodian/tools/c7n_azure/.

Write your first policy

A policy specifies the following items:

  • The type of resource to run the policy against
  • Filters to narrow down the set of resources
  • Actions to take on the filtered set of resources

For this tutorial we will add a tag to all virtual machines with the name "Hello" and the value "World".

Create a file named custodian.yml with this content:

policies:
    - name: my-first-policy
      description: |
        Adds a tag to all virtual machines
      resource: azure.vm
      actions:
        - type: tag
          tag: Hello
          value: World

Run your policy

First, choose one of the supported authentication mechanisms and either log in to Azure CLI or set environment variables as documented in Authentication.

custodian run --output-dir=. custodian.yml

If successful, you should see output similar to the following on the command line

2016-12-20 08:35:06,133: custodian.policy:INFO Running policy my-first-policy resource: azure.vm
2016-12-20 08:35:07,514: custodian.policy:INFO policy: my-first-policy resource:azure.vm has count:1 time:1.38
2016-12-20 08:35:08,188: custodian.policy:INFO policy: my-first-policy action: tag: 1 execution_time: 0.67

You should also find a new my-first-policy directory with a log and other files (subsequent runs will append to the log by default rather than overwriting it).

Links

Running Tests

If you'd like to help with the development of Azure support, you'll need uv installed. It provides a pip-compatible interface, & will handle all the dependencies needed for you.

You can then run the unit tests like this:

# Assuming you're in the `cloud-custodian` top-level directory...
$ cd tools/c7n_azure

$ uv run pytest tests_azure

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distributions

No source distribution files available for this release.See tutorial on generating distribution archives.

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

c7n_azure-0.7.48-py3-none-any.whl (214.5 kB view details)

Uploaded Python 3

File details

Details for the file c7n_azure-0.7.48-py3-none-any.whl.

File metadata

  • Download URL: c7n_azure-0.7.48-py3-none-any.whl
  • Upload date:
  • Size: 214.5 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.14.0

File hashes

Hashes for c7n_azure-0.7.48-py3-none-any.whl
Algorithm Hash digest
SHA256 77874d90c326e05193bfffca5367cf9c42eebd49f693b0c0eb9a1d7c36925293
MD5 67e08e52a23e52091e10b0c258c543ab
BLAKE2b-256 2bcaa72ae4bcb804ccc00a2ab9507aa3f85dca3988b2d8ca470008af57c7878d

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page