This blog is a follow up to the Azure Automation blog by configuring a Logic App to implement user defined scheduling of start and stop /snoozing on azure virtual machine scale set instances as part of FinOps.
Deployment Plan
Step 1 – Create your Logic App
Step 2 – Enable the System Assigned Managed Identity
Step 3 – Assign the SAMI Role
Part 1 – Start vmss instances
Step 4 – Create your START Schedule
Step 5 – Create a Connection
Step 6 – Target your vmss instance
Part 2 – Stop vmss instances
Step 7 – Create a Shut Down Schedule
Deployment Steps
Step 1 - Create your Logic App
Go to your Azure Portal > search for Logic apps > Add >
Basic tab:
Populate your subscription and resource group fields,
Create a unique Logic App name,
Region > select your region,
Enable log analytics = determine whether you want to collect analytics
Plan > selected a consumption plan (as per your requirements),
Zone Redundancy > as per your requirements
Review and Create,
Create,
Step 2 - Enable the System Assigned Managed Identity
On your Logic App > go to Identity >
On the System Assigned tab > toggle to ON > Yes > Save
Step 3 - Assign the SAMI Role
Assign the SAMI a role scope based on the PoLP.
On the Logic App > Identity > SAMI > click on the Azure Role assignments > + Add role assignment (Preview) >
select scope,
select subscription,
select role,
save,
Step 4 - Create your START Schedule
Open your Logic App >
Select Logic App designer >
Select a blank logic app >
Choose an operation > Add a trigger > search for and select schedule >
then search for and select Recurrence >
Click on the Recurrence button >
Click on Add new parameter:
Edit the interval, Frequency, Time Zone, On these Days (available if you choose the Weekly Frequency), Hours and Minutes boxes,
Now click on the + in the centre pane > Add an action > search for scale set > select Start virtual machine in a VM scale set
Populate the scription id, resource group, vm scale set and vmss instance,
Step 5 - Create a Connection
At this point you are prompted to sign into the domain with an AD account.
Select your tenant,
If you plan to use the SAMI, click on the link Connect with managed identity ,
In the connection name, copy and paste the SAMI objectID from the System Assigned tab (from step 2),
Create
Step 6 - Target your vmss instance
Enter the details of where your target instances reside:
Subscription ID,
Resource Group,
Virtual Machine Scale Set,
Instance ID (which you will get from the instance overview page).
————This completes the workflow to startup your scale set instances————–
To extend this Logic App to also shut down the virtual machine scale set instances after hours:
Step 7 - Create a Shut Down Schedule
Continuing in the main page of your designer > click on + Add an action >
Add a trigger > search for and select schedule >
then search for and select Delay schedule >
In your count parameter > select the number of hours to delay the start from the first Recurrence trigger
(my first trigger was set to fire at 08:00 and I want my instances to shut down at 18:00 so im going to use 10 hours)
In the main page of your designer > click on + Add an action >
Search for scale set > select Power off virtual machine in a VM scale set
Configure the target instances to stop.
To add the 2nd vmss instance to the shutdown schedule, click on the last + and select Add a parallel branch
Choose an operation,
Search for scale set > select Power off virtual machine in a VM scale set
Configure the 2nd target instances to stop.
This will complete the weekday startup and shut down of your virtual machine scale set instances.
–End—
you have got an ideal weblog here! would you wish to make some invite posts on my blog?
I think this web site contains very fantastic composed written content posts.