Skip to content

Latest commit

 

History

History
 
 

azure-delete-empty-loadbalancers

Removing unused resources in your Azure account (like load balancers) can help you avoid unnecessary charges on your monthly Azure bill. Whether it's just you picking up after yourself or the dozens of other teams in your company creating resources (and not deleting them ah hem) – this workflow can help to keep your Azure account clean.

This workflow will first look for all Azure load balancers in a Subscription (or optionally, resource group). Then, it will filter that list for the load balancers that have zero back end configurations. Then, it waits for your approval. Finally, once approval has been granted, it will delete the empty load balancers. Problem solved!

For more details, check out our blog post Save time and money by automatically deleting Azure Load Balancers.

Prerequisites

Before you run this workflow, you will need the following:

  • An Azure Subscription
  • An Azure Service Principal with permissions to manage load balancers.
  • One or more Azure Load Balancers with zero back end configurations.

Configure the workflow

Follow these steps to configure the workflow. Doing this will enable Relay to connect to your Azure account.

You may see a warning that you are missing a required connection. This means you will need to add your Azure credentials as a Connection.

  • Click Fill in missing connections or click Settings in the side nav.

Fill in missing connections

Click settings from side nav

  • Find the Connection named my-azure-account and click the plus sign (+).

Guide connections

  • Fill out the form:

    • Name - You can’t change this with the form. The name is supplied by the YAML. If you wanted to change it you would need to do so in the Code tab.
    • Subscription ID - Enter your Azure Subscription ID
    • Client ID - Enter your Azure Client ID associated with the service principal
    • Tenant ID - Enter your Azure Tenant ID associated with the service principal
    • Secret - Enter your Azure Secret associated with the service principal

TIP If you need help getting your Azure credentials, check out our blog post.

  • Click Save

Run the workflow manually

Follow these steps to run this workflow.

  • Click Run workflow and wait for the workflow run page to appear.

    Run workflow

  • Supply values for the parameters fields when the modal appears:

    Supply modal values

    • dryRun - true or false
      • true if you dont want to actually delete the resources. Use this to test the workflow and ensure it is behaving as expected.
      • false if you want the resources to be immediately deleted.

WARNING! Be careful setting dryRun to false. Though the workflow comes with an approval step, once approved the resources will be terminated. Please use caution.

Run the workflow on a schedule

Follow these steps to run this workflow on a schedule:

  • Un-comment out the included Trigger block in the workflow YAML. You can do this in the Code tab.

Code tab

TIP: If you're using the Relay code editor, highlight the triggers section and type ⌘ + / (Mac) or Ctrl + / (Windows) to uncomment.

# triggers:
# - name: schedule
#   source:
#     type: schedule
#     schedule: '0 * * * *'
#   binding:
#     parameters:
#       dryRun: true
  • Configure the schedule trigger:
    • Supply the run interval in cron format.
    • Configure the following parameter bindings:
      • Specify whether dryRun should be set to true or false.
  binding:
    parameters:
      dryRun: true
  • Click Save changes