The automation of virtual machines is usually done using Resource Manager Model (ARM) templates. A deployment using ARM contains a template file, parameter file and the code to execute it (CLI, PowerShell, .NET or Ruby).

You can get started with the templates and the parameter files from a number of places.

1. Any previously completed deployment from the Azure portal. Just download an existing one and start tweaking it. This is the easiest one to start with.

2. Get a list of templates from GitHub. In Azure portal, go to Template Deployment, then Create. You will be able to search the GitHub quick start repo for a suitable template.

3. Use VS Code add-in for ARM and start creating the templates.

4. Create a new Azure Resource Group project in Visual Studio and visually add required resources to the template. This can be deployed using the included PowerShell script, but more conveniently just let Visual Studio deploy it.

If using PowerShell to deploy then change the execution policy using this: