Skip to content

TechMeToTheCloud/Azure-Cost-Management

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

18 Commits
 
 
 
 
 
 

Repository files navigation

Azure-Cost-Management with Powershell

A cool way to save costs on Azure (convenience for a sandbox) before the big sentence aka DELETING 😱 resource(s).

The example will focus on Synapse Pool and Stream analytics job. However the script could be used as a template and be leveraged to suit different use cases.

Step 1 Identify what resources cost the most in the subscription

image

In the case above, Synapse pools are the resources costing the most in the subscription (https://azure.microsoft.com/en-us/services/cost-management/#overview)

Step 2 Understand how any resource(s) identified in step 1 is/are priced and how you could modify the resource(s) to make the cost cheaper

Step 3 Create a Powershell script that "minimizes" the costs based on the options identified in Step 2

In this case, Synapse Pools are the main "problem".

Let's minimize the cost for those resources.

The stream analytic job will be also modified.

What we will be doing for:

  • Synapse

    • Suspend the pool with the command Suspend-AzSynapseSqlPool
  • Stream Analytic job

    • Stop the job with the command Stop-AzStreamAnalyticsJob

The script will iterate through all the resources in the subscription.

Each Synapse Pool running will be paused.

Each Streamin Analytic job running will be stopped.

Step 4 Create a runbook and schedule it to run on a regular basis

The following link will guide you to create and schedule a runbook: https://docs.microsoft.com/en-us/azure/automation/learn/automation-tutorial-runbook-textual-powershell When creating the job, make sure you add any module required (see the example provided)

The final step is to decide the frequency of the job. For example, run the runbook everyday at 10pm.

After running the script in a runbook, you can verify what has been modified: image

About

A cool way to save costs on Azure

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published