This is the manual for the provisioning of a Windows virtual machine on Azure using Terraform.
Despite of having an Azure subscription, install following:
I'd like to refer to following to links, which I've used for for that example:
Hashicorp - azurerm - Windows Virtual Machine
Hashicorp - azurerm - public ip
I recommend to conduct all commands in VS Code using a new Terminal.
Run following command to start the login to Azure:
az login
A new browser session pops up, use the login credentials of your account:
After that, switch back to VS Code, you should see logs similar in the picture shown below:
You can prove whether you are using the right subscription using the following command:
az account show
This shows you the current subscription:
The first Terraform command is the "init" command:
terraform init
The logs in the picture below show a successful execution of the command:
As next, run the "format" command, to ensure that all files of your configuration stick to specific language style conventions:
terraform fmt
After that, ensure that your Terraform coniguration is valid by executing:
terraform validate
Create now a Terraform plan file, by running:
terraform plan -out tfplan
This creates a file named "tfplan" in your directory:
Finally, the command can be executed for deploying the virtual machine on Azure - it uses the Terraform plan named "tfplan" as an argument:
terraform apply "tfplan"
The deployment was successful if following log message appears:
Prove the deployment of the virtual machine in the Azure portal:
The virtual machine can be destroyed using the following command:
terraform destroy
https://developer.hashicorp.com/terraform/tutorials/azure-get-started/azure-build