I am trying to set up a mechanism to shut down my Azure Functions app if a cost alert gets thrown. I have created an automation account, a powershell runbook, and an action group. I went into Cost + Billing in for my tenant in azure and created a Cost Alert. I tried to associate the alert with an Action Group, but I couldn’t find a way. I don’t know if this was ever possible in the interface. Next I tried another way: I started setting up a Logic App to kick off when I receive the alert email but there is no "Free" cost plan. Is there a way to stop my app if a price threshold is met for free?
2
Answers
The "Manage Action Groups" link was not displayed becuase the context I was looking at in Billing was an account and not my subscription. When I changed to my subscription the link appeared on the "Set Alerts" tab.
Create an Azure Cost Budget and filter the Scope with your Function Apps like below:-
Select the Creation and Expiration date for the budget:-
In the Alert condition I selected 80% which means when the cost reaches 80% of my Budget Amount, I will receive an alert and Action group will be triggered:-
Select Manage action group> Create a new Action Group and select any of the method like Automation account or Logic App to stop your function app:-
In the Notification Enter your email to get notified for this Budget:-
Create Action and select the Automation Runbook to stop the Function app once the Alert is triggered:-
Select > Next > Tags > Review + create > Create the Budget.
I have created one
Azure Automation account> Created Powershell script to stop the Function Apps
from my Subscription like below:-My Automation runbook script:-
Output:-