question

JPAlfaro-2014 avatar image
0 Votes"
JPAlfaro-2014 asked ·

Best way to automate actions on newly created VMs

Hello experts,

I would like for some guidance regarding the best ways to automate actions on newly created virtual machines.

What I would like to do is to develop someway to automate the creation of managed system identities, install certain extensions, or enabling diagnostic settings as soon as a new VM is created.

My initial thought was to use log analytics to create an alert that runs every 5 minutes and queries for newly created VMs, then use an automation runbook as the action group, to run a piece of powershell code to enable the desired features.

Would anyone suggest a better approach to accomplish my requirement?

azure-virtual-machines
· 2
10 |1000 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.

Do you want to do these automations while creating the VM's

Or Once the VM is created?

0 Votes 0 ·

HI,

i need to do it after the VM is created.

0 Votes 0 ·
stan avatar image
1 Vote"
stan answered ·

The best way to automate this is to use Azure Policy. With deployIfNotExists effect you can deploy some resources when certain things do not exits (not compliant). I would still recommend if you are deploying these resources trough some automation like CI/CD and ARM Templates is to deploy these additional settings along with the actual deployment of resources.

· Share
10 |1000 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.

JPAlfaro-2014 avatar image
0 Votes"
JPAlfaro-2014 answered ·

Hi Stan,

Thank you for your suggestion.

I don't seem to be able to find for a way to automate the deployIfNotExists remediation.

Do you know if that is possible?

· Share
10 |1000 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.