Azure-Finops

This repository contains Azure ARM templates to create runbooks that run scripts aimed at cost optimization

Prerequisites

All scripts assume an automation account was created and it has a service principal assigned to it.
the user running the template must be an automation contributor or owner.

Table of Contents

  1. ARM-Templates - Policies
  2. ARM-Templates - Runbooks

ARM-Templates - Policies

Deploy to azure Hybrid benefit(SQL-Managed instance) policy:

Description
    This template implement policy at management group scope to to force Hybrid benefit for Managed SQL instance.

Deploy to azure Hybrid benefit(SQL-Managed instance)

Deploy to azure Hybrid benefit(SQL) policy:

Description
    This template implement policy at management group scope to to force Hybrid benefit for SQL Databases.

Deploy to azure Hybrid benefit(SQL) policy

Deploy to azure Hybrid benefit(Vms) policy:

Description
    This template implement policy at management group scope to to force Hybrid benefit for Vms and Vmss

Deploy to azure Hybrid benefit(Vms) policy

Deploy To Azure tag resources with created at timestamp:

Description
    This template implement policy at management group scope to to force resources that are created with a tag name "Created_at" and tag value of the date he was created. NOTE - Need to change the value of tag in policy definition(to "utcNow()") after ARM is deployed.

Deploy To Azure find unused subscriptions

ARM-Templates - Runbooks

Deploy to azure Auto Scale Vmss:

Description
    This template implement an ARM-Template , creating two python 3 packages, 4 variables and two runbooks in an already exist automation account the "list" runbook is creating a csv of all VMSS that not belongs to AKS and are manual scale as candidate for automate scale the "modify" runbook is modifying not excluded VMSS (by tags and by not being AKS) to automate scale
Deploy to azure Auto Scale Vmss

Deploy to Azure tag last modified:

Description
    This template implement a runbook that look for Vms and Disks who got modified in the past two weeks and tag them with tag name "last_modified" with tag value of the Caller id.

Deploy To Azure tag last modified

Deploy to Azure tag reserved disks and deallocated Vms:

Description
    This template implement a runbook that look for Vms that in "deallocated/stopped" state over X days and tag them with tag "Candidate - DeleteMe" and all the disks with over X size related to the vm also with "Candidate - DeleteMe".

Deploy To Azure tag unattached disks and deallocated VMs

Deploy to Azure delete reserved disks and deallocated Vms:

Description
    This template implement a runbook that look for vms and disks with tag "Candidate - DeleteMe" and delete them.

Deploy To Azure delete unattached disks and deallocated VMs

Deploy to Azure tag created by and created on date:
Deploy To Azure created by and created on date

Deploy to Azure right sizing:
Deploy To Azure right_sizing

Deploy to Azure cpu & memory utilization:
Deploy To Azure cpu & memory utilization

Deploy To Azure get unused subscriptions:

Description
    This template implement a runbook script that loops over all the subscriptions and looks for activity logs of users with full user principal names and IP addresses to validate if the subscriptions have been in use in the time defined. If unused subscriptions have been found the script exports them to a CSV file in the configured blobs accounts.

Deploy To Azure get unused subscriptions

Deploy To Azure service bus premium metrics:

Description
    This template implement a runbook script that loops over all the subscriptions and looks for service bus (Premium only) metrics - CPU and Memory , If CPU utilization is less than X then he gets tagged with key name=candidate and key value=resize.

Deploy To Azure service bus premium metrics